![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Drag events I have Petzold's new book on WPF and was trying the Notepad clone and noticed it does not have drag-and-drop working. Not surprising, it's just a code sample. But I went to go add it and neither the window nor the textbox "saw" the DragOver event when I implemented event handlers. Is this implemented? Thanks, Jon |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Drag events Don't forget the SDK. Digging through the content tree is a good way to find general topics. If you want to really know what WPF can do, you will have to dig through the SDK. http://windowssdk.msdn.microsoft.com.../ms754130.aspx Here is the Drag-Drop link - it's under WinFX Development-> WPF ->Data. http://windowssdk.msdn.microsoft.com.../ms749074.aspx There isn't any book, including Charles, that will be as comprehensive as the SDK. For example, Drag-Drop can be easy or complex depending on what you want to do with it, and the SDK covers a number of areas a book may not cover. Of course, the SDK doesn't cover everything either...it never does...there are always holes. Also, Charles book is a 100 level type book for WPF basics. He doesn't discuss 3D, Typography, XPS, MSbuild, ....the list goes on and on... he had to stop writing as there were no trees left in his local area ![]() One thing to remember about Drag\Drop is the use of Adorners are important for Drawing other WPF content over the top for some extra fun. Here is a link: http://blogs.msdn.com/marcelolr/arch...03/543301.aspx The Micosoft folks are blogging, and that is a great resource for finding solutions to problems...for example I found the link above by searching for "WPF 'drag and drop' adorners". "Jon Davis" wrote: > I have Petzold's new book on WPF and was trying the Notepad clone and > noticed it does not have drag-and-drop working. Not surprising, it's just a > code sample. But I went to go add it and neither the window nor the textbox > "saw" the DragOver event when I implemented event handlers. > > Is this implemented? > > Thanks, > Jon > > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Drag events Thanks. Actually I was only trying to find out if netfx v3 supported drag/drop and if so why it wasn't working for me. It turns out I forgot to set AllowDrop property to True. Even after fixing that, the textbox did not raise the event. The app config: Window ("NotepadClone") -> DockPanel ("Dock") -> -> Menu ("menu") -> -> TextBox ("txtbox") When I added the following, I got a messagebox from the DockPanel and from the Window, but only when dragging to the menu (and nowhere else). public NotepadClone() { .. . . txtbox.AllowDrop = true; dock.AllowDrop = true; this.AllowDrop = true; dock.DragOver += new DragEventHandler(dock_DragOver); this.DragOver += new DragEventHandler(NotepadClone_DragOver); txtbox.DragOver += new DragEventHandler(txtbox_DragOver); .... } void dock_DragOver(object sender, DragEventArgs e) { MessageBox.Show("What a drag! From dock"); // executes } void NotepadClone_DragOver(object sender, DragEventArgs e) { MessageBox.Show("What a drag! From window"); // executes } void txtbox_DragOver(object sender, DragEventArgs e) { MessageBox.Show("What a drag! From txtbox"); // DOES NOT execute } Thanks, Jon |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Drag events You should look at the sample called DropOpenTextFile. If you follow the Drag\Drop links in the SDK, it will take you to a 72meg sample beta2 drop...look in the "Editing" folder for the sample. The answer you are looking for is in there...you are missing some code. "Jon Davis" wrote: > Thanks. Actually I was only trying to find out if netfx v3 supported > drag/drop and if so why it wasn't working for me. > > It turns out I forgot to set AllowDrop property to True. Even after fixing > that, the textbox did not raise the event. > > The app config: > > Window ("NotepadClone") > -> DockPanel ("Dock") > -> -> Menu ("menu") > -> -> TextBox ("txtbox") > > When I added the following, I got a messagebox from the DockPanel and from > the Window, but only when dragging to the menu (and nowhere else). > > > public NotepadClone() > { > .. . . > txtbox.AllowDrop = true; > dock.AllowDrop = true; > this.AllowDrop = true; > dock.DragOver += new DragEventHandler(dock_DragOver); > this.DragOver += new DragEventHandler(NotepadClone_DragOver); > txtbox.DragOver += new DragEventHandler(txtbox_DragOver); > .... > } > > void dock_DragOver(object sender, DragEventArgs e) > { > MessageBox.Show("What a drag! From dock"); // executes > } > > void NotepadClone_DragOver(object sender, DragEventArgs e) > { > MessageBox.Show("What a drag! From window"); // executes > } > > void txtbox_DragOver(object sender, DragEventArgs e) > { > MessageBox.Show("What a drag! From txtbox"); // DOES NOT execute > } > > > Thanks, > Jon > > > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Drag events That's real helpful. :-/ Look, I'm not going to download a 72 MB sample to get a very trivial question answered. This is not important enough to me, unless you have an explanation I am going to just assume then that this is either broken or inconsistently designed. I'll wait around for a few more years for v2. Cheers, Jon "TheRHogue" <TheRHogue@discussions.microsoft.com> wrote in message news:6AC8CB23-8E23-40F6-9A24-4AD74CD570BF@microsoft.com... > You should look at the sample called DropOpenTextFile. If you follow the > Drag\Drop links in the SDK, it will take you to a 72meg sample beta2 > drop...look in the "Editing" folder for the sample. The answer you are > looking for is in there...you are missing some code. > > > > "Jon Davis" wrote: > >> Thanks. Actually I was only trying to find out if netfx v3 supported >> drag/drop and if so why it wasn't working for me. >> >> It turns out I forgot to set AllowDrop property to True. Even after >> fixing >> that, the textbox did not raise the event. >> >> The app config: >> >> Window ("NotepadClone") >> -> DockPanel ("Dock") >> -> -> Menu ("menu") >> -> -> TextBox ("txtbox") >> >> When I added the following, I got a messagebox from the DockPanel and >> from >> the Window, but only when dragging to the menu (and nowhere else). >> >> >> public NotepadClone() >> { >> .. . . >> txtbox.AllowDrop = true; >> dock.AllowDrop = true; >> this.AllowDrop = true; >> dock.DragOver += new DragEventHandler(dock_DragOver); >> this.DragOver += new DragEventHandler(NotepadClone_DragOver); >> txtbox.DragOver += new DragEventHandler(txtbox_DragOver); >> .... >> } >> >> void dock_DragOver(object sender, DragEventArgs e) >> { >> MessageBox.Show("What a drag! From dock"); // executes >> } >> >> void NotepadClone_DragOver(object sender, DragEventArgs e) >> { >> MessageBox.Show("What a drag! From window"); // executes >> } >> >> void txtbox_DragOver(object sender, DragEventArgs e) >> { >> MessageBox.Show("What a drag! From txtbox"); // DOES NOT execute >> } >> >> >> Thanks, >> Jon >> >> >> |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Drag events By the way, rule of thumb, a component should never expose an event if the event is never raised. Textbox exposes DragOver but does not raise it even with AllowDrop set to true. Hence, it is broken or flawed in its design. I'd settle for broken but I have a doubt this will be fixed (we're already at RC1), making it "by design" flawed. Jon "Jon Davis" <jon@REMOVE.ME.PLEASE.jondavis.net> wrote in message news:%23JpP2Hf0GHA.4312@TK2MSFTNGP02.phx.gbl... > That's real helpful. :-/ > > Look, I'm not going to download a 72 MB sample to get a very trivial > question answered. This is not important enough to me, unless you have an > explanation I am going to just assume then that this is either broken or > inconsistently designed. I'll wait around for a few more years for v2. > > Cheers, > Jon > > > "TheRHogue" <TheRHogue@discussions.microsoft.com> wrote in message > news:6AC8CB23-8E23-40F6-9A24-4AD74CD570BF@microsoft.com... >> You should look at the sample called DropOpenTextFile. If you follow the >> Drag\Drop links in the SDK, it will take you to a 72meg sample beta2 >> drop...look in the "Editing" folder for the sample. The answer you are >> looking for is in there...you are missing some code. >> >> >> >> "Jon Davis" wrote: >> >>> Thanks. Actually I was only trying to find out if netfx v3 supported >>> drag/drop and if so why it wasn't working for me. >>> >>> It turns out I forgot to set AllowDrop property to True. Even after >>> fixing >>> that, the textbox did not raise the event. >>> >>> The app config: >>> >>> Window ("NotepadClone") >>> -> DockPanel ("Dock") >>> -> -> Menu ("menu") >>> -> -> TextBox ("txtbox") >>> >>> When I added the following, I got a messagebox from the DockPanel and >>> from >>> the Window, but only when dragging to the menu (and nowhere else). >>> >>> >>> public NotepadClone() >>> { >>> .. . . >>> txtbox.AllowDrop = true; >>> dock.AllowDrop = true; >>> this.AllowDrop = true; >>> dock.DragOver += new DragEventHandler(dock_DragOver); >>> this.DragOver += new DragEventHandler(NotepadClone_DragOver); >>> txtbox.DragOver += new DragEventHandler(txtbox_DragOver); >>> .... >>> } >>> >>> void dock_DragOver(object sender, DragEventArgs e) >>> { >>> MessageBox.Show("What a drag! From dock"); // executes >>> } >>> >>> void NotepadClone_DragOver(object sender, DragEventArgs e) >>> { >>> MessageBox.Show("What a drag! From window"); // executes >>> } >>> >>> void txtbox_DragOver(object sender, DragEventArgs e) >>> { >>> MessageBox.Show("What a drag! From txtbox"); // DOES NOT execute >>> } >>> >>> >>> Thanks, >>> Jon >>> >>> >>> > > |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Drag events Resolved on my own. It seems that although DragOver does not fire, PreviewDragOver does fire. I'm sure there will be an explanation somewhere (SDK or otherwise) on the whole idea of this "Preview-" prefix and what PreviewDragOver suggests differently from DragOver. TheRHogue, I apologize for my nasty reply. However, I did find the sample you described and it did not help because event binding was implemented in XAML whereas Petzold's NotepadClone does not use XAML at all. Jon "Jon Davis" <jon@REMOVE.ME.PLEASE.jondavis.net> wrote in message news:uEEqhkV0GHA.4252@TK2MSFTNGP03.phx.gbl... > Thanks. Actually I was only trying to find out if netfx v3 supported > drag/drop and if so why it wasn't working for me. > > It turns out I forgot to set AllowDrop property to True. Even after fixing > that, the textbox did not raise the event. > > The app config: > > Window ("NotepadClone") > -> DockPanel ("Dock") > -> -> Menu ("menu") > -> -> TextBox ("txtbox") > > When I added the following, I got a messagebox from the DockPanel and from > the Window, but only when dragging to the menu (and nowhere else). > > > public NotepadClone() > { > . . . > txtbox.AllowDrop = true; > dock.AllowDrop = true; > this.AllowDrop = true; > dock.DragOver += new DragEventHandler(dock_DragOver); > this.DragOver += new DragEventHandler(NotepadClone_DragOver); > txtbox.DragOver += new DragEventHandler(txtbox_DragOver); > ... > } > > void dock_DragOver(object sender, DragEventArgs e) > { > MessageBox.Show("What a drag! From dock"); // executes > } > > void NotepadClone_DragOver(object sender, DragEventArgs e) > { > MessageBox.Show("What a drag! From window"); // executes > } > > void txtbox_DragOver(object sender, DragEventArgs e) > { > MessageBox.Show("What a drag! From txtbox"); // DOES NOT execute > } > > > Thanks, > Jon > |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: Drag events > TheRHogue, I apologize for my nasty reply. However, I did find the sample > you described and it did not help because event binding was implemented in > XAML whereas Petzold's NotepadClone does not use XAML at all. ... but it did point out the "Preview-" nomenclature, which led to my own findings. To that extent, it was indeed helpful. Thanks. Jon |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wmi events | A. Petitjean | PowerShell | 1 | 12-16-2006 12:11 PM |
| Access denied trying to "md"? Drag & Drop is now drag, drop, OK, OK ???? | Noozer | Vista installation & setup | 0 | 10-17-2006 04:45 AM |
| Fire events from Xaml files.. events in Pre compiled Dll's | SureshGubba | Avalon | 1 | 09-15-2006 01:56 PM |
| Events, events | Greg Borota | PowerShell | 2 | 07-01-2006 05:38 PM |
| Handling Drag Events in Custom Control | viRtual | Avalon | 2 | 06-04-2006 10:00 PM |