Cannot restore hidden window

Docking/MDI for WPF Forum

Posted 11 years ago by Pasha
Version: 13.2.0590
Platform: .NET 4.5
Environment: Windows 8 (64-bit)
Avatar

I try to load the saved layout

 

    public partial class MainWindow : Window
    {
        private string m_layout = @"<DockSiteLayout xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" SerializationFormat=""All"">
	<AutoHideHost />
	<Content xsi:type=""Workspace"" AutoHideSize=""274,232"" DockedSize=""274,232"" DocumentSize=""274,232"" FloatingSize=""274,232"" Size=""274,232"">
		<Content xsi:type=""TabbedMdiHost"">
			<Content xsi:type=""SplitContainer"" AutoHideSize=""274,232"" DockedSize=""274,232"" DocumentSize=""274,232"" FloatingSize=""274,232"" Size=""274,232"" Orientation=""Horizontal"">
				<UIElement xsi:type=""TabbedMdiContainer"" AutoHideSize=""134.5,232"" DockedSize=""134.5,232"" DocumentSize=""134.5,232"" FloatingSize=""134.5,232"" Size=""134.5,232"" SelectedWindowUniqueId=""45b992b9-0190-4585-b2dc-600c01ad2a70"">
					<UIElement xsi:type=""DocumentWindowRef"" UniqueId=""45b992b9-0190-4585-b2dc-600c01ad2a70"" />
				</UIElement>
			</Content>
		</Content>
	</Content>
	<DocumentWindows>
		<DocumentWindow UniqueId=""45b992b9-0190-4585-b2dc-600c01ad2a70"" AutoHideSize=""134.5,232"" DockedSize=""134.5,232"" DocumentSize=""134.5,232"" FloatingSize=""134.5,232"" Size=""134.5,232"" IsOpen=""false"" LastState=""Document"" Name=""Editor"" StandardMdiBounds=""0,0,300,200"" State=""Document"" />
	</DocumentWindows>
</DockSiteLayout>";

        public MainWindow()
        {
            InitializeComponent();
            Load();
        }

        void Load()
        {
            var serializer = new DockSiteLayoutSerializer
            {
                SerializationBehavior = DockSiteSerializationBehavior.All,
                DocumentWindowDeserializationBehavior = DockingWindowDeserializationBehavior.AutoCreate,
            };
            serializer.DockingWindowDeserializing += SerializerOnDockingWindowDeserializing;
            try
            {
                serializer.LoadFromString(m_layout, root);
            }
            catch (Exception ex)
            {

                throw;
            }
        }

        private void SerializerOnDockingWindowDeserializing(object sender, DockingWindowDeserializingEventArgs e)
        {
            e.Window.Header = "window1";
        }
    }

 and

<Window x:Class="TestLoad.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <docking:DockSite x:Name="root">
            <docking:Workspace >
                <docking:TabbedMdiHost>
                    <docking:TabbedMdiContainer>
                    </docking:TabbedMdiContainer>
                </docking:TabbedMdiHost>
            </docking:Workspace>
        </docking:DockSite>
    </Grid>
</Window>

 I want to save the hidden status of restored window (IsOpen=false) but the serializer always oopens windows. How can I restore the saved IsOpen status?

Furthermore I want to use MVVM template in the application. Can I manage the IsOpen property from my viewmodel?

Now if I add

<Setter Property="IsOpen" Value="{Binding IsVisible, Mode=TwoWay}" />

 to the DocumentWindow style then the exception throws

"This operation is invalid since the DockingWindow has not yet been registered with a DockSite."

[Modified 11 years ago]

Comments (1)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Pasha,

I looked at the code and it looks like you can't really change how things get deserialized.  You'd have to wait until after the layout has loaded, and then make adjustments as needed.  You could perhaps programmatically inject your IsOpen binding following layout load.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.