How to save a layout with a horizontal document group?

I'm trying to achieve a simple thing but without much success so far, I would like the DockingManager to save the document layout group.


XAML:


<Window x:Class="WpfApp1.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:syncfusion="http://schemas.syncfusion.com/wpf"
        mc:Ignorable="d"
        Title="MainWindow" Width="640" Height="480"
        WindowStartupLocation="CenterScreen"
        syncfusion:SfSkinManager.Theme="{syncfusion:SkinManager ThemeName=VisualStudio2015}">
    <Grid>
        <syncfusion:DockingManager x:Name="DockingManager1">

            <ContentControl syncfusion:DockingManager.Header="Video Screen"

                            syncfusion:DockingManager.State="Document" />
            <ContentControl syncfusion:DockingManager.Header="Video Memory"

                            syncfusion:DockingManager.State="Document" />
        </syncfusion:DockingManager>

    </Grid>

</Window>


Code:


using System;
using System.IO;
using System.Windows;


namespace WpfApp1;


public partial class MainWindow
{
    private const string LayoutXml = "Layout.xml";


    public MainWindow()
    {
        InitializeComponent();
        Loaded += MainWindow_Loaded;
        Closed += MainWindow_Closed;
    }


    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        if (File.Exists(LayoutXml))
        {
            DockingManager1.LoadDockState(LayoutXml);
        }
    }


    private void MainWindow_Closed(object? sender, EventArgs e)
    {
        DockingManager1.SaveDockState(LayoutXml);
    }
}


Application starts like this as expected:

0OMKinH9z2.png

User then changes the layout to this:

TEcOW1KvXi.png

But when I open the application again, that new layout is not persisted, the layout is like in picture #1.

Note that if both panes are not documents, the layout is persisted and at next application start it is indeed restored.

Is it possible to persist the layout when the panes are documents?

Thank you.


3 Replies 1 reply marked as answer

SN Sudharsan Narayanan Syncfusion Team March 14, 2022 09:20 AM UTC

Hi Aybe,

You can be able to achieve the “Save Horizontal layout for tab groups” requirement by using the DockingManager Loaded event to load the state for the Tab groups. We have prepared the sample and it’s work as expected. So, please find the sample from below,

Sample: https://www.syncfusion.com/downloads/support/forum/173608/ze/DockingStatePersist-243043005


Code Snippet:

 
DockingManager1.Loaded += DockingManager1_Loaded;
private void DockingManager1_Loaded(object sender, RoutedEventArgs e) 
        { 
            DockingManager1.LoadDockState(LayoutXml); 
        } 

Please check the sample and let us know your concerns. We are happy to assist you.

Regards,
Sudharsan
 


Marked as answer

AY aybe March 14, 2022 11:25 PM UTC

Works perfectly, thank you! 😀



SN Sudharsan Narayanan Syncfusion Team March 15, 2022 06:27 AM UTC

Hi Aybe,

We are glad to know that your issue has been fixed. Please let us know if you need any other assistance. We are happy to assist you.

Regards,
Sudharsan


Loader.
Up arrow icon