Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Override Floating PaneToolWindow Close event to force Redocking
posted

Hi,

The scenario I'm trying to accomplish is as follows:

I have a XamDockManger with serveral TabPanes, which contain content.   My requirements state that these panes should be able to float, and be docked, but cannot be closed.    We have set AllowClose to false in Xaml styling for Panes, however, when we dock two panes together, generating a new tab pane, the windows can be closed.

 

We want to override the close function of the windows to force them to toggle docking.  I attempted to do this first by hooking in to the Close

e.Window.Closing += new System.ComponentModel.CancelEventHandler(xamDockManager_WindowClosing);

 

and then I wanted to run the ToggleCommand and handle the close

 ExecuteCommand(ContentPaneCommands.ToggleDockedState);

but this errors stating can't run during window close.

 

What I need is a way to supplant the close method and force it to toggle the docking.  Thanks in advance for any help.

Parents
No Data
Reply
  • 54937
    Offline posted

    Well if you really needed to do that then you would likely need to cancel the event and then asynchronously perform the dock operation (presumably for all the panes in that toolwindow). That being said if the AllowClose is actually false then the pane would not be closed even if it were in a floating pane with another ContentPane that allowed closing - the close action would close the ones that allow closing or the close button would be disabled if none of the panes allowed closing. I suspect that you were trying to set the AllowClose by a Style that targets ContentPane which had a Setter for AllowClose. If so the reason that isn't working is likely because you're defined that style within the window containing the xamDockManager. When a pane is floating it is in its own top level Window and is not in the visual or logical tree of the xamDockManager so the WPF framework will not pick up your implicit style. If you really want to set this property via a Style then you would need to put that style in the app's resources. Be aware though that if you set the Theme property then you're putting an implicit style closer to the pane than the one you would have in the app's resources and so the one from the theme would be used. If preventing closing is a requirement I would recommend setting the property on each ContentPane.

Children
No Data