Floating Window SizeToContent not working as expected

Nov 7, 2010 at 6:23 PM

This doesn't seem to work in the way I expect.

I can only get it to work if I do the following...

 Form.ShowAsFloatingWindow(this.DockingManager, false);
 Form.FloatingWindowSizeToContent = SizeToContent.WidthAndHeight;
 Form.ShowAsFloatingWindow(this.DockingManager, true)

The content of the Form is declared as Height/Width=Auto (or in some cases I don't even set Auto). What happens is that the window is displayed very briefly using the default [floating window] size, it then disappears and is redisplayed correctly (in a more central position!)

I have created a general wrapper window for all my floating windows and just set the content depending on what I want to display.

Is there any way to get this to work without the 2 calls to ShowAsFloatingWindow()? The other issue is that this causes is that the 'Loaded' event is fired on each call which is a problem.

Nov 8, 2010 at 10:36 AM

I think I may have an answer to this.

In DockingManager.cs the method

        internal void Show(DockableContent content, DockableContentState desideredState, AnchorStyle desideredAnchor)

                if (desideredState == DockableContentState.DockableWindow ||  desideredState == DockableContentState.FloatingWindow)
                   var floatingWindow = new DockableFloatingWindow(this);

                   floatingWindow.Content = content;
                   var mainWindow = Window.GetWindow(this);

                   if (mainWindow.IsVisible)
                        floatingWindow.Owner = mainWindow;

                   floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; 
                   floatingWindow.SizeToContent = content.FloatingWindowSizeToContent;

I added the highlighted line. I also uncommented the one above it. I did this because the floating window was starting up in an 
odd location so maybe this should be added as a property to 'content' so that it can be set in the Xaml or in code.