In my scenario i am closing ToolWindow programmatically calling
Close() function in several situation related application UI requirement,
but also user can close by standard "x" button.
How can i distinguish these close events?
thanks in advance
Sorry, to dig up an old post but figured it makes more sense than adding to the post rather than a duplicate but I imagine this is still the case?
My scenario is that when we close ToolWindows via the 'x' we hide it ie IsOpen = false, and in our DockSite (which inherits from DockSite) we override the OnWindowsClosed and notify our controller that the user has closed it.
I've been able to track this in my ViewModel, as every scenario will be UserClosed = true, but when I dispose of the ToolWindow ourselves we flip UserClosed to false so then the code within OnWindowsClosed isn't executed.
This works happy days, until someone uses ToolWindows.Clear(), but anyway.
With this scenario in mind, is there a way I can use ToolWindow as a base, and then use that type within the DockSite as my ToolWindow type?
Hi Matthew,
I believe your company uses MVVM patterns. The DockSite.GetContainerForItemOverride method is what generates the ToolWindow "container" for a view-model. It's default implementation is this:
protected virtual DockingWindow GetContainerForItemOverride(DockingWindowItemKind kind) {
if (kind == DockingWindowItemKind.Document)
return new DocumentWindow(true);
else
return new ToolWindow(true);
}
You can override that method to provide your own inherited class instead if you like. It works in the same way ItemsControl does and is described in the "MVVM Features" documentation topic.
Please log in to a validated account to post comments.