ItemsControl Drag Drop Behavior for WPF
Average Rating:
(8)
(8)
Description
Discussions
(6)
|
|
-
Whether using DataTemplate will lost visualTree hierarchy?2 Posts | Last Post March 20, 2011
-
Written March 20, 2011Hello Edwin, Thanks a lot for this great example. It is super useful for me. I am doing something similar but I have some extra requirement as well. Based on your listview, I have two listviews A and B on a canvas. And I have connection link(actually a wpf Path) between one item in A and another item in B.I need to dynamically update this link when I drag or drop the two items. I use this function to find the absolute location of item on my canvas: public void SetPosition() { Center = this.TransformToAncestor(FindA ncestor<Canvas> (this)).Transfo rm(new Point(this.Actu alWidth / 2, this.ActualHeig ht / 2)); } // "this" above is my item - it's a control class written by me and it's subclass of border // walk up the visual tree for parent of type T private static T FindAncestor<T> (DependencyObje ct current) where T : DependencyObjec t { do { if (current is T) { return (T)current; } current = VisualTreeHelpe r.GetParent(cur rent); } while (current != null); return null; } Now I am confused - why VisualTreeHelpe r.GetParent() return null as my item's ancestor? Why this item's parent is not my listview? Do you know whether I use DataTemplate will cause the visual tree hierarchy doesn't recognize listview as listviewItem's parent due to this listviewItem is actually in DataTemplate? -
Written March 20, 2011Actually I need to find the absolute location of the item on my canvas. Do you know whether there is a way I can avoid use the dataTemplate or I can get the absolute location without this FindAncestor Function? Thank you so much!
-
-
-
Written November 06, 2009As a noob to Silverlight (and Windows development in general): How do I install this thingy into Expression Blend/ SketchFlow? I need it for a tutorial I am doing. Cheers, Bjørn
-
Written December 10, 2009The download link is to a file with no .zip extension - add the extension and then you can expand it. This control was built for WPF so it cannot be used in Silverlight app. You use it by adding it as a reference in your project (Add reference, browse to DLL). Bjørn - I too am looking for the DragDropItem behavior referenced in module 9 of the snowboard online videos for SketchFlow. Apparently, this is a custom behavior they used in the MIX presentations and I can't find it anywhere!!! If you stop the video (09_BLN03SP1EN7
20_Working_with _Behaviors_in_S ketchFlow) when he selects the behavior you can see that it is custom cause the flyout is different, says "Snowboard_Mix_ Screens" and the DLL is Expression.Prot otype.Screens.d ll in his local c:\users\admin\ sketchflow_star ter_kit folder. This is not included in the Assets of the Prototyping_wit h_Sketchflow_St arterKit download so until someone finds it and posts it somewhere, we're out of luck on that part of the tutorial.
-
-
-
Written October 31, 2009Forgive me for asking a probably silly question, but what would this be used for? Is this something that other programmers would use when creating a program of their own or is it something a regular person could use to organise thier computer files? I ask as I am looking for a solution or work around to the fact that Auto Arrange can no longer be turned off in Windows 7.
-
-
-
Written September 15, 2009Thanks for this control it works great. One question though, I am using this in my MVVM application and was wondering how I can add additional events / commands? For example I want to know when an item is being added or removed and what item it is. It looks like I need the remove and add item notification in the helper class but can not figure out how to add them? Thanks
-
Written October 08, 2009Hi there, sorry for late reply. I don't check this very often. Best way to know if an item is added or removed is to fire an event from the behavior itself. you can expose that event (with the object as an argument) in the behavior and you can subscribe to that in your parent xaml control and handle that. Hope that helps.
-
-
-
Written August 01, 2009Excellent work Edwin. Your inclusion of the DataTemplate property really makes this very complete. I must admit that I have only been pouring over the code and the example for about an hour, so may come up with questions, but so far this appears to be a pretty complete solution.
-

-

-
-
-
Written August 01, 2009Edwin, your example helped me a lot. It really makes the Drag&Drop is very simple. Thanks.
-




