Setting Up Drag Drop - WPF DRAG DROP TUTORIAL #1

  Рет қаралды 39,873

SingletonSean

SingletonSean

Күн бұрын

Пікірлер: 46
@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
@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 2 жыл бұрын
@@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.
@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!
@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.
@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.
@EcuTester
@EcuTester Жыл бұрын
Good job! Thank you for YOUR WORK👍
@shaihulud4515
@shaihulud4515 3 жыл бұрын
Thank you - without this tutorial I would have backed out of drag&drop entirely!
@SingletonSean
@SingletonSean 3 жыл бұрын
Glad it was helpful Shai! Drag & drop just sounds so scary at first haha
@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.
@TuberTugger
@TuberTugger 2 жыл бұрын
I can't get errverr how easy this was
@bonehead-lo2pi
@bonehead-lo2pi 4 ай бұрын
😂😂😂😂
@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.
@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?
@SangTruongITE
@SangTruongITE Жыл бұрын
thank you very much! By the way, can you tell me why my rectangle can drag outside of the canvas?
@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
@matthiasmerz86
@matthiasmerz86 3 жыл бұрын
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.
@JarosawPietras
@JarosawPietras 3 жыл бұрын
UserControl is not serializable, how drag drop UserControl?
@technics6215
@technics6215 2 жыл бұрын
Thank you Sir!
@mikefocal5770
@mikefocal5770 3 жыл бұрын
GREAT JOB
@SingletonSean
@SingletonSean 3 жыл бұрын
Thanks mike!
@RGBA
@RGBA 3 жыл бұрын
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?
@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.?
@y4ni608
@y4ni608 2 жыл бұрын
awesome video loved it :D
@John-vv7ok
@John-vv7ok 2 жыл бұрын
is there any possiblitiy of doing this without XAML?
@gary6212
@gary6212 9 ай бұрын
Note: Set playback speed to .75 for human speed.
@SingletonSean
@SingletonSean 9 ай бұрын
👽👽👽
@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!
@leonhardolaye-felix8811
@leonhardolaye-felix8811 2 жыл бұрын
THANKS
@scproinc
@scproinc 2 жыл бұрын
Doesn't work with tree view items.
@evgeniilewicki5874
@evgeniilewicki5874 4 ай бұрын
This seems to be useful information, but you chatter as if two people with whips are urging you on behind your back.
Drag Drop MVVM Integration - WPF DRAG DROP TUTORIAL #2
13:24
SingletonSean
Рет қаралды 13 М.
Drag & Drop Tutorial
18:29
FlutterFlow
Рет қаралды 18 М.
Walking on LEGO Be Like... #shorts #mingweirocks
00:41
mingweirocks
Рет қаралды 6 МЛН
Which team will win? Team Joy or Team Gumball?! 🤔
00:29
BigSchool
Рет қаралды 15 МЛН
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 149 МЛН
Don't Use Websockets (Until You Try This…)
6:46
Code With Ryan
Рет қаралды 319 М.
How we fell out of love with Java
9:44
Train To Code
Рет қаралды 6 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 814 М.
Drag & Drop with Javascript in 4 minutes
3:58
Appwrite
Рет қаралды 40 М.
Creating Reusable Controls - WPF TUTORIALS
17:10
SingletonSean
Рет қаралды 31 М.
ListViews - WPF DRAG DROP TUTORIAL #3
16:29
SingletonSean
Рет қаралды 13 М.
WPF INotifyPropertyChanged and Databinding
14:30
Payload
Рет қаралды 41 М.
Modern Python logging
21:32
mCoding
Рет қаралды 200 М.
СКОЛЬКО СТОИТ КАЖДЫЙ КОМП APPLE? (Ч.1)
0:37
ТЕСЛЕР
Рет қаралды 122 М.
Дешёвые мониторы - имба?😳
0:59
Корнеич
Рет қаралды 1,8 МЛН
Diode
0:16
ZS Electrical Work
Рет қаралды 4,7 МЛН