I have a canvas within a DocumentContentHost within a SplitPane. I am dragging and dropping objects within the canvas. it all works fine... but, i want to cancel the drag whenever the object is dragged out of the bounds of the canvas. I have tried to use the previewdragleave event on the canvas, but, it doesn't seem to fire. So, I am trying to cancel the drag within the PreviewMouseMove event.
bounds = VisualTreeHelper.GetDescendantBounds(xamMainDockMgr.ActivePane) and the Left and Top properties (x,y) are always 0,0. The Right property is the actualwidth and the Bottom property is the actualheight. Bascially, I have tried using the VisualTreeHelper with all of the container objects within my xamDockManager and they all seem to return the same. I also get the same whenever i try to use the Canvas.GetLeft method. I realize the canvas is a child and would be considered at 0,0 within the parent, but, why are all the parent(s) also returning 0,0?
I will need to be able to capture the boundaries at runtime since the user can move (unpin, etc) the docked panel. Any ideas? it must be something easy i am just missing it.
The GetDescendentBounds returns the union of all descendents as well as the Content bounding box containing those descendents. I was going back and forth with that yesterday. I ended up using the GetContentBounds method.
I appreciate your input as it did help. I wasn't sure if there was something going on with the DockManager that was causing my problem. I didn't mean to use this forum for just WPF support... but, I do very much appreciate it when you guys provide assistance.
I did get everything to work the way I needed for my purposes. The xamDockManager is a great component for WPF!
Thank you.
As documented in MS' help, GetDescendantBounds is just going to union all the rects of the descendants and the rect returned will be relative to the reference element. As for Canvas.Left, that is just an attached property defined by the Canvas class that it uses to know where to position its direct children - it would only have values that you set on an element.
I'm not quite sure I follow what rect (and relative to what element) you are looking for but in WPF if you want to get a rect/point relative to another element then you would use the TransformToVisual method (or one of the TransformToAncestor|Descendant methods) and then use the Transform(Bounds) methods of that.