Articles in this section
Category / Section

How can the initial design state be loaded by the DockingManager LoadDockState?

1 min read

When the DockingManager loads the initial designer state by using the LoadDockState() method at the loaded event of the DockingManager, it reloads the last saved state of the DockingManager instead of the initial designer state.

To reload the initial designer state of the DockingManager, load the state of the DockingManager by invoking the LoadDockState() method by using the Dispatcher with the DispatcherPriority as the Background.

The following code example explains the same:

C#

using System.Windows.Threading;
namespace DockingManager_ResetState
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml.
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Window1.Closing += Window1_Closing;
            DockingManager.Loaded += DockingManager_Loaded;
        }
        void DockingManager_Loaded(object sender, RoutedEventArgs e)
        {
            //Loads the DockingManager state by using the Dispatcher class.
            Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart)delegate
            {
                // This code loads the state of the DockingManager.
                DockingManager.LoadDockState();
            });
         }
     void Window1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // This code saves the state of the DockingManager.
            DockingManager.SaveDockState();
        }
        private void Reset(object sender, EventArgs e)
        {
           // This code resets the initial designer state of the DockingManager.
           DockingManager.ResetState();
        }
    }
}

 

XAML

<Window x:Name="Window1" x:Class="DockingManager_ResetState.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Button Width="150" Height="23" Content="ResetState" Grid.Row="0" Click="Reset"></Button>
        <syncfusion:DockingManager x:Name="DockingManager" UseDocumentContainer="True" Grid.Row="1">
            <ContentControl syncfusion:DockingManager.Header="Dock1"
                            syncfusion:DockingManager.State="Document"></ContentControl>
            <ContentControl syncfusion:DockingManager.Header="Dock2"
                            syncfusion:DockingManager.State="Document"></ContentControl>
            <ContentControl syncfusion:DockingManager.Header="Dock3"
                            syncfusion:DockingManager.State="Dock"></ContentControl>
            <ContentControl syncfusion:DockingManager.Header="Dock4"
                            syncfusion:DockingManager.State="Dock"></ContentControl>
            <ContentControl syncfusion:DockingManager.Header="Dock5"
                            syncfusion:DockingManager.State="Dock"></ContentControl>
        </syncfusion:DockingManager>
    </Grid>
</Window>  

 

The following screenshot shows the initial designer state of the DockingManager.

Figure 1: Initial designer state

The following screenshot shows the loaded state of the DockingManager with some changes in the state of the DockingManager:

Figure 2: Loaded state of the DockingManager

 

The following screenshot shows that the initial designer state of the DockingManager reset on pressing the ResetState Button.

Figure 3: Initial designer state of the DockingManager reset

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment