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:
User then changes the layout to this:
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.
|
DockingManager1.Loaded += DockingManager1_Loaded;
private void DockingManager1_Loaded(object sender, RoutedEventArgs e) {
DockingManager1.LoadDockState(LayoutXml);
} |
Works perfectly, thank you! 😀