[Version 2.0] Deserialization problem

Jul 15, 2013 at 9:13 PM
Hello.
I have a problem with Deserialization, when Deserialization complete I have empty window...
I use code from exemples, to save:
            var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockingManager);
            using (var stream = new StreamWriter("Layout.xml"))
                serializer.Serialize(stream);
And to load(after InitializeComponent()):
            if (File.Exists("Layout.xml"))
            {
                var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockingManager);
                using (var stream = new StreamReader("Layout.xml"))
                    serializer.Deserialize(stream);
            }
and my xml:
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonDock="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
        xmlns:layout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock"
        Title="MainWindow" Height="450" Width="650">
    <Grid>
        <avalonDock:DockingManager x:Name="dockingManager">
            <layout:LayoutRoot>
                <layout:LayoutPanel Orientation="Vertical">
                    <layout:LayoutAnchorablePane >
                        <layout:LayoutAnchorable>
                            <TextBox/>
                        </layout:LayoutAnchorable>
                        <layout:LayoutAnchorable>
                            <TextBox/>
                        </layout:LayoutAnchorable>
                    </layout:LayoutAnchorablePane>
                </layout:LayoutPanel>
            </layout:LayoutRoot>
        </avalonDock:DockingManager>
    </Grid>
</Window>

Jul 24, 2013 at 6:57 PM
Edited Jul 24, 2013 at 7:07 PM
After debugging I found that ALL elements from deserialization isHidden.
I tried use code below to show hidden elements but I have no any changes.
Can somebody show me right way?
                var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockingManager);
                using (var stream = new StreamReader("Layout.xml"))
                    serializer.Deserialize(stream);


                while (dockingManager.Layout.Hidden.Count > 0)
                {
                    dockingManager.Layout.Hidden[0].Show();
                }
Aug 2, 2013 at 9:31 AM
Hello!

I do not know much English (I'm sorry for the mistakes), but i wrote my solution (this solution very simple)!

You don't use deserialize method in View Constructor after InitializeComponent, instead use in View Loaded event!

You try it!
private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockingManager);
                using (var stream = new StreamReader("Layout.xml"))
                    serializer.Deserialize(stream);
        }
Aug 2, 2013 at 9:33 AM
Yes, its really helps.
Thank!
Apr 16 at 12:16 PM
Thank you very much! Great advice! :)