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
You're very welcome! Glad to help.
Hi Rob,
sorry for the late reply, I couldn't post earlier because my subscription had expired.
It works great now, thanks a lot for the amazing support!
Cheers
Hi Tjark,
There's another way to handle this that will cover your requirement better. Rather than trying to get the SourceInitialized/SourceUpdated events when the ToolWindow is loaded, the code should first check to see if it can get the window handle like normal. If not then it should use the PresentationSource.AddSourceChangedHandler method to attach an event handler to the window. When the source changes for the window, it will fire this event and you can then execute the icon removal code. This will cover situations where the handle is not immediately available when the ToolWindowLoaded event is fired.
I have attached a sample containing the code for this.
I have to get back to you on this issue because I noticed one problem that I previously overlooked:
It works great when dealing with floating panes that the user drags out of the XamDockManager.
However, at some points in my application, I create floating panes by myself by
-creating a new SplitPane,-calling XamDockManager.SetInitialLocation() with InitialPaneLocation.DockableFloating,-and then adding this SplitPane to the Panes collection of the XamDockManager
As soon as I call
dockManager.Panes.Insert(0, splitPane);
the ToolWindowLoaded event is fired. However, in this case the Parent property of the PaneToolWindow is always null. So I cannot subscribe to the SourceInitialized event.
Do you know a solution for that?
Awesome! Glad that worked!