Hello,
I have hooked an event handler to the DockStateChanged event in order to intercept the tool windows that were being detached from the dock. Once I find a tool window whose DockState has turned to Floating I adjust its size and change the border style so that the user cannot resize it anymore while it is floating. However I encountered a small problem with this approach: if I detach the tool window by clicking its tab and dragging it out of the tab strip the FloatingParent field of the DockWindow provided in the event arguments is properly set and I can alter it. However if I double-click on the tab or use the context menu to make the window floating the FloatingParent field is set to null. Curiously this only happens the first time I undock the window this way, if I dock the window again and then undock it FloatingPanel is not null anymore (the same is true if I undock the window by dragging it out of the tab strip). Is this an intended behavior or a bug? Here's my event handler code (which throws a NullReferenceException when FloatingParent is null):
I have hooked an event handler to the DockStateChanged event in order to intercept the tool windows that were being detached from the dock. Once I find a tool window whose DockState has turned to Floating I adjust its size and change the border style so that the user cannot resize it anymore while it is floating. However I encountered a small problem with this approach: if I detach the tool window by clicking its tab and dragging it out of the tab strip the FloatingParent field of the DockWindow provided in the event arguments is properly set and I can alter it. However if I double-click on the tab or use the context menu to make the window floating the FloatingParent field is set to null. Curiously this only happens the first time I undock the window this way, if I dock the window again and then undock it FloatingPanel is not null anymore (the same is true if I undock the window by dragging it out of the tab strip). Is this an intended behavior or a bug? Here's my event handler code (which throws a NullReferenceException when FloatingParent is null):
void event_DockStateChanged(object sender, DockWindowEventArgs e) |
{ |
if (e.DockWindow.DockState == DockState.Floating) |
{ |
// Resize a tool window to fit its contents and make it fixed-size. |
e.DockWindow.FloatingParent.ClientSize = e.DockWindow.GetPreferredSize(Size.Empty); |
e.DockWindow.FloatingParent.FormBorderStyle = FormBorderStyle.FixedToolWindow; |
} |
} |