Тёмный

Setting Up Drag Drop - WPF DRAG DROP TUTORIAL #1 

SingletonSean
Подписаться 23 тыс.
Просмотров 39 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@PanCave
@PanCave 2 года назад
I know this video isn't new anymore, but it really helped me a lot! Can you tell me, how to avoid that first jumping, when movng the mouse? I assume this happens, because we don't click on the most top left edge of the square and so it snaps to the position of the mouse. I guess you'd somehow have to calculate the mouse offset?
@PanCave
@PanCave 2 года назад
Actually I found a solution. In case anybody else is wondering about this: In the MouseDown EventHandler you can save an offsetLeft and offsetTop by getting e.GetPosition(frameworkElement).X and e.FetPosition(frameworkElement).Y respectively
@Brianboy9494
@Brianboy9494 Год назад
@@PanCave Thanks for the idea! I was wondering the same. If anyone wonders how to do this in more detail, you can declare a Point member currentMouseOffset and then in the rectangle's MouseDown event store e.GetPosition(rectangle) in there. Then, in the canvas's DragOver and Drop events you subtract that offset's x- and y-values from the mouse position to set the rectangles new position on the canvas. One must use the MouseDown event instead of the MouseMove event to obtain correct values for the offset.
@maxgdh7618
@maxgdh7618 Год назад
Hello Could you please also explain how to implement drag to the dynamically created elements? I tried to do that, but as soon as I try to move a rectangle it disappears, even though that I use single canvas
@SpellMenderDev
@SpellMenderDev Год назад
I can help with that. In the MouseMove event handler you'll want to use the object "sender" instead of the name reference. You'll need to cast it to a different object type. A UIElement would work. In my case I used a Shape object so I could change the fill color. Here's a simple example of what you want: --- private void Element_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { DragDrop.DoDragDrop((UIElement)sender, new DataObject(DataFormats.Serializable, sender), DragDropEffects.Move); } } --- I know you posted this 8 months ago, but I hope it helps someone.
@cyrildouglas9262
@cyrildouglas9262 3 года назад
Do you plan to show the ways to implement this using MVVM?
@SingletonSean
@SingletonSean 3 года назад
Definitely Cyril! That will be next 💪
@cyrildouglas9262
@cyrildouglas9262 3 года назад
Thank you so mcuh, that would be great.
@JarosawPietras
@JarosawPietras 3 года назад
UserControl is not serializable, how drag drop UserControl?
@mortuusars
@mortuusars 3 года назад
Would be interesting to see how to drag&drop from WPF app to another app window.
@SingletonSean
@SingletonSean 3 года назад
Good point Evgeny, I haven't tried this. I think it might be easier than expected since drag and drop is "global" on Windows OS.
@mortuusars
@mortuusars 3 года назад
@@SingletonSean I've tried to implement drag and drop from my app window to photoshop window. (As if I drag image from windows explorer) and it didn't work. I've not spent much time on this, but I think it has something to do with what "datatype" other window expects.
@evgeniilewicki5874
@evgeniilewicki5874 2 месяца назад
This seems to be useful information, but you chatter as if two people with whips are urging you on behind your back.
@matthiasmerz86
@matthiasmerz86 2 года назад
Hy. Can you show a Drag&Drop-Excample for a List? Based on your example, I would like to create these lists variably and then be able to move them among each other. In addition, it should still be possible to move the contents of the list among each other. could you show an example, please.
@boukriabdelkhalek6855
@boukriabdelkhalek6855 3 года назад
Thank you so much, I was gonna ask about the implementation in ListView, but you said that at the end of the video. I will be waiting for that and more.
@SingletonSean
@SingletonSean 3 года назад
Correct Boukri, that will be coming soon! 😄 I think the source code has the ListView implementation if you're interested in seeing it. I'll admit it's a bit complex.
@boukriabdelkhalek6855
@boukriabdelkhalek6855 3 года назад
@@SingletonSean I will check it after all :D
@EcuTester
@EcuTester Год назад
Good job! Thank you for YOUR WORK👍
@tjzIsMe
@tjzIsMe 3 года назад
Thanks for this! Wonderful timing too, I was just about to tackle this in my project! Appreciate your videos!
@SingletonSean
@SingletonSean 3 года назад
Woohoo, thanks Joe!
@minimalcoder3236
@minimalcoder3236 3 года назад
I was trying to create a custom reporting tool that customers can drog and drop labels, images or draw lines and rectangles, and save the report for later use. But could not find where to start. Do you have a suggestion for me ? liked & subbed
@feitan8745
@feitan8745 3 года назад
A builder tool?
@minimalcoder3236
@minimalcoder3236 3 года назад
@@feitan8745 yes you are correct
@gary6212
@gary6212 8 месяцев назад
Note: Set playback speed to .75 for human speed.
@SingletonSean
@SingletonSean 8 месяцев назад
👽👽👽
@Tyronblade
@Tyronblade 3 года назад
Great stuff thanks a lot! Ill be eagerly awaiting a video covering listview 😉
@SingletonSean
@SingletonSean 3 года назад
Thanks TIRAN! I think the source code has the ListView implementation if you're interested in checking it out, but I think the video will clarify a lot of the concepts.
@elkhayyat85
@elkhayyat85 3 года назад
Thank you Sir for your Tutorial... it's really awesome and so helpful... :) :) can you you make some tutorial about how to customize a GridView and make it with awesome look and functions.?
@TuberTugger
@TuberTugger 2 года назад
I can't get errverr how easy this was
@bonehead-lo2pi
@bonehead-lo2pi 2 месяца назад
😂😂😂😂
@SangTruongITE
@SangTruongITE Год назад
thank you very much! By the way, can you tell me why my rectangle can drag outside of the canvas?
@John-vv7ok
@John-vv7ok 2 года назад
is there any possiblitiy of doing this without XAML?
@GuildOfCalamity
@GuildOfCalamity 3 года назад
When you get time, could you do a quick video on all the Extentions/SDKs/Tools you have installed in your VS2019?
@RGBA
@RGBA 2 года назад
great tutorials but when i try to move my box to the right it wont move it only let me move to left and bottom, fix?
@scproinc
@scproinc 2 года назад
Doesn't work with tree view items.
@DerEddieLoL
@DerEddieLoL 2 года назад
Would you implement 64 of those boxes to make a chess game? I think this would be pretty tedious... any suggestions? I am new to WPF
@SingletonSean
@SingletonSean 2 года назад
I imagine it would be something like that! I feel like this wouldn't be that crazy to create, but would certainly be somewhat difficult. I've actually done 2 drag and drop projects in the past that are related to this. The drag and drop is the easy part, but the hard part is enforcing a "grid" structure that the draggable pieces will snap to. Since I have some experience with this and some old source code, I'd love to do a video on the "grid" behavior. It's super satisfying too, hahah. Thanks for bringing up this topic!
@y4ni608
@y4ni608 2 года назад
awesome video loved it :D
@technics6215
@technics6215 2 года назад
Thank you Sir!
@shaihulud4515
@shaihulud4515 2 года назад
Thank you - without this tutorial I would have backed out of drag&drop entirely!
@SingletonSean
@SingletonSean 2 года назад
Glad it was helpful Shai! Drag & drop just sounds so scary at first haha
@leonhardolaye-felix8811
@leonhardolaye-felix8811 2 года назад
THANKS
@mikefocal5770
@mikefocal5770 3 года назад
GREAT JOB
@SingletonSean
@SingletonSean 3 года назад
Thanks mike!
Далее
Drag Drop MVVM Integration - WPF DRAG DROP TUTORIAL #2
13:24
ПОЮ ВЖИВУЮ🎙
3:19:12
Просмотров 881 тыс.
Is LEARNING WPF still WORTH it in 2023?
10:59
Просмотров 51 тыс.
Drag & Drop Tutorial
18:29
Просмотров 16 тыс.
React Drag And Drop (dnd-kit) | Beginners Tutorial
17:27
Drag & Drop with Javascript in 4 minutes
3:58
Просмотров 33 тыс.
ListViews - WPF DRAG DROP TUTORIAL #3
16:29
Просмотров 13 тыс.
WPF Drag Tutorial
11:06
Просмотров 813
ПОЮ ВЖИВУЮ🎙
3:19:12
Просмотров 881 тыс.