Hi,
on my computer,if I drag a ContentPane out of the XamDockManager,the resulting floating pane does not have an icon in the upper left corner, regardless of the Image property being set or not.
I think that this is the desired behavior because the Image property is only for the tab headers. This is also what I want.
However, on a coworker's computer (same code),if I drag a ContentPane out of the XamDockManager,the resulting floating pane always shows the default Windows icon in the upper left corner.
How can I prevent that (I don't know what setting on his computer causes this behavior)?
I am using this code to hide the standard Windows icon for non-DockManager child windows in my application, and this works on both computers:
protected override void OnSourceInitialized(EventArgs e){ base.OnSourceInitialized(e); IntPtr hwnd = new WindowInteropHelper(window).Handle; // Change the extended window style to not show a window icon var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME); // Update the window's non-client area to reflect the changes SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); SendMessage(hwnd, WM_SETICON, new IntPtr(1), IntPtr.Zero); SendMessage(hwnd, WM_SETICON, IntPtr.Zero, IntPtr.Zero);}
Unfortunately I have no access to ToolWindowHostWindow, so I cannot do the same for floating panes in the XamDockManager. Calling this code in the ToolWindowLoaded event handler doesn't do anything.
Thanks,
Tjark
Hi Rob,
thanks a lot, that works great!
I didn't know that SourceInitialized was also available as an event!
Hi Tjark,
ToolWindowHostWindow derives from the Window class so you can cast it to a Window. As for the OnSourceInitialized event, you should be able to handle the SourceInitialized event on the Window class and then execute your code in there. Inside the ToolWindowLoaded event:
Window toolWindow = e.Window.Parent as Window;toolWindow.SourceInitialized += toolWindow_SourceInitialized;
Give that a try.
Some additional details:
A minimal working example to demonstrate the problem would be
a WPF windowcontaining a XamDockManagerwith AllowMaximizeFloatingWindows="True"containing a SplitPanecontaining an empty ContentPane.
Run this app, the drag the ContentPane out of the XamDockManager.
On my machine, no icon appears in the upper left corner of the ToolWindowHostWindow.
On my colleague's machine, a standard Windows icon appears in the upper left corner of the ToolWindowHostWindow.
I want to prevent the latter (I think the code that I posted above could help, but I cannot override OnSourceInitialized of ToolWIndowHostWindow because it's protected).