Hello,
I'd like to handle the floating ToolWindow's closing event the same way as the tabbed ContentPane (the tabbed ContentPanes have a close button which is bound to a ICommand reference)
To achieve this, I hook to the
XamDockManager.ToolWindowLoaded
event where I hook to the
ToolWindow.Closing
event.
So my question is: Is there a solution to detect if the ToolWindow gets closed due to closing via button or due to docking back into the XamDockManager.
Or is there maybe another solution to achieve the handling of closing the tabs?
Thanks in advance
Christian
Hello Christian,
Thank you for your post. I have been looking into it and I can suggest you add the following check in the ToolWindow’s Closing event handler in order to determine whether it is closed or docked:
if (((sender as PaneToolWindow).Content as SplitPane).IsVisible) { Debug.WriteLine("Closed"); } else Debug.WriteLine("Docked");
Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Stefan,
how can I get access to my user control that was inside a window? Basically, I want to display additional section when it is undocked and hide it when it is docked again. It seems like it's already not a child of PaneToolWindow when Closing event is fired.
Hello Anton,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I used the events mentioned in the first post and get the content of the PaneToolWindow and ContentPane trough the VisualTree.
Hope this helps you.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Yeah, I've found this way recently by myself.
I have modified the sample, so now it has the functionality you want. Instead of using the events of the PaneToolWindow I bound the background of the UserControl to the ContentPane's PsneLocation Property and by using a Converter I return different colors. You can use the same approach for the Visibility Property of the element you need. Please let me know if this helps you or you have further questions on this matter.
Well, in this simple example it's OK. But what if I want to bind a collection of tab's view models and their UI is defined in Data Template. I've modified your solution to show this. Run it, then try to undock tab - its background became green. Then try to dock it and it still will be green because I'm unable to find my user control in the visual tree (my suspect is ContentPanePlaceholder).