How can initial design state be loaded by WPF DockingManager?
When the DockingManager loads the initial designer state by using the LoadDockState() method at the loaded event of the WPF 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
Conclusion
I hope you enjoyed learning about how can initial design state be loaded by WPF DockingManager.
You can refer to our WPF DockingManager feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF DockingManage documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!