Home Forums WPF controls Other WPF controls AvalonDock: cannot control pane visibility after loading layout via serializer

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • cmkessell
    Participant
    Post count: 3
    #44872 |

    Hi,

    I’m using the latest AvalonDock (3.4.17280.14430) and have a layout in which I want to be able to hide and show panes. My code works fine with the default dock layout, but once the layout has been saved and re-loaded using XmlLayoutSerializer the hiding and showing of panes no longer works.

    I’ve created a bare minimum WPF project that displays the problem, which I think must be a bug within AvalonDock. I can cut-and-paste the XAML and code here or email it in – please advise.

    Many thanks,
    Chris

    cmkessell
    Participant
    Post count: 3

    If it helps, here is the XAML of my simple test program:

    
    <Window x:Class="AvalonDockTest.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
            xmlns:local="clr-namespace:AvalonDockTest"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">
    
        <DockPanel>
            <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
                <Button Content="Save Layout" Click="SaveLayout_Click" Margin="5"/>
                <Button Content="Load Layout" Click="LoadLayout_Click" Margin="5"/>
                <Button Content="Hide Pane 1" Click="HidePane1_Click" Margin="5"/>
                <Button Content="Show Pane 1" Click="ShowPane1_Click" Margin="5"/>
                <Button Content="Hide Pane 2" Click="HidePane2_Click" Margin="5"/>
                <Button Content="Show Pane 2" Click="ShowPane2_Click" Margin="5"/>
            </StackPanel>
    
            <xcad:DockingManager x:Name="dockingManager">
                <xcad:LayoutRoot>
                    <xcad:LayoutPanel Orientation="Horizontal">
                        <xcad:LayoutAnchorablePane>
                            <xcad:LayoutAnchorable x:Name="Pane1" ContentId="Pane1" Title="Pane 1"/>
                        </xcad:LayoutAnchorablePane>
                        <xcad:LayoutAnchorablePane>
                            <xcad:LayoutAnchorable x:Name="Pane2" ContentId="Pane2" Title="Pane 2"/>
                        </xcad:LayoutAnchorablePane>
                    </xcad:LayoutPanel>
                </xcad:LayoutRoot>
            </xcad:DockingManager>
        </DockPanel>
    </Window>
    

    and here is the code behind:

    
    using System.Windows;
    using System.IO;
    using Xceed.Wpf.AvalonDock.Layout.Serialization;
    
    namespace AvalonDockTest
    {
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void SaveLayout_Click(object sender, RoutedEventArgs e)
            {
                var serializer = new XmlLayoutSerializer(dockingManager);
                using (var writer = new StreamWriter("avalonlayout.xml"))
                    serializer.Serialize(writer);
            }
    
            private void LoadLayout_Click(object sender, RoutedEventArgs e)
            {
                var serializer = new XmlLayoutSerializer(dockingManager);
                using (var reader = new StreamReader("avalonlayout.xml"))
                    serializer.Deserialize(reader);
            }
    
            private void HidePane1_Click(object sender, RoutedEventArgs e)
            {
                Pane1.Hide();
            }
    
            private void ShowPane1_Click(object sender, RoutedEventArgs e)
            {
                Pane1.Show();
            }
    
            private void HidePane2_Click(object sender, RoutedEventArgs e)
            {
                Pane2.Hide();
            }
    
            private void ShowPane2_Click(object sender, RoutedEventArgs e)
            {
                Pane2.Show();
            }
    
        }
    }
    

    When run it produces a window with some buttons and two docking panes. The buttons allow the panes to be displayed or hidden. The Save Layout and Load Layout buttons allow the layout to be saved and reloaded; when the layout it has been reloaded, however, the ability to hide and show panes no longer works.

    gremlin
    Participant
    Post count: 1

    I’m having a similar issue, except I can no longer create new documents once I’ve deserialised, works fine before I do it but not after. Have a small sample bit of code if you want me to send it.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.