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
590
PaneToolWindow with auto size
posted

Hi.

Is there any way to make PaneToolWindow to be dependent on its content resize? I have a user control inside with a expandable section so If it's expanded tool window should increase it's height to show it. I was able to set initial tool window size depending on my user control size using this code but still can't figure out how to handle control size changes:

private void XamDockManager_ToolWindowLoaded(object sender, PaneToolWindowEventArgs e)

{
     var control = FindVisualChildren<MyUserControl>(e.Window.Content as DependencyObject).FirstOrDefault();

     if (control != null)
     {

         e.Window.Height = control.ActualHeight;
         e.Window.Width = control.ActualWidth;

     }

}

I tried to subscribe SizeChanged event in the XamDockManager_ToolWindowLoaded but in it looks like tool window somehow forces its children to resize during startup so I got bunch of SizeChanged with size going to zero. Which leads tool window to be opened with zero size after all.