Hey guys!
I have the following strunctire:
PaneToolWindow -> SplitPane -> ContentPane.
How can I disable ability to close window? Setting AllowClose to false doesn't help because I still can close it via close button in Start Task Bar.
I also tried to set e.Cancel to true for Closing event but in this case after docking the window I am getting extra pane tool window (as it was not closed due to setting e.Cancel flag to true).
Hello Maksim,Thank you for contacting Infragistics Developer Support.
The close button existing on the PaneToolWindows that are used for the floating panes in the XamDockManager are not affected by the close-related properties on the panes. This is because by default, the XamDockManager uses a WPF Window with its WindowStyle property set to ToolWindow to wrap the floating panes. So, this close button is essentially the same as the one that exists in your typical WPF window, in other words.
To remove this close button, I would recommend handling the ToolWindowLoaded event of the XamDockManager. This event will allow you to retrieve the PaneToolWindow as it loads via the e.Window property of the event arguments. From here, you can set the PaneToolWindow’s UseOsNonClientArea property to “false,” which will cause the window provide the chrome for the window itself, rather than using its built-in template to display the window chrome that includes the close button. This will essentially hide the close button, and prevent closure of the PaneToolWindow.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Andrew,
I am already using this property set to false because I am using custom style for header. For undocked view of the PaneToolWindow there is no the close button.
The issue is I still can close the window via Context Menu:
It looks like setting window.AllowClose to false makes this option disable... OK. But there is one more way to close the window:
And i was not able to disable this ability. "May be it's possible to do via Win32 functions?" I thought.
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
var hwnd = new WindowInteropHelper(paneToolWindow).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
But the Handle property return null. It looks like our PaneToolWindow doesn't inherit thw Window.
So I also tried to handling the Closing event and set args.Cancel to true:
private void PaneToolWindowOnClosing(object sender, CancelEventArgs cancelEventArgs) { cancelEventArgs.Cancel = true; }
And at first sight it works, but... right after I am docking the window from the indocked state, this event occurs, I am setting Cancel to true and I am getting docked content pane and empty PaneToolWindow:
Do you have any ides? I really need your help guys!
Thank you.