How to clear out saved dockmanager states

I have a question about how DocumentManager works when PersistState is set to true. While debugging, a persisted state survives even if I clean the solution.

How can I delete the state data that's saved automatically between debug sessions so that my windows will look as I have defined them in code rather than how they were persisted?

Thank you.



3 Replies

SS Sekar Sivalingam Syncfusion Team November 11, 2024 05:08 PM UTC

Hi Gil Yoder,

Query 1: How does DockingManager work when PersistState is set to true?

When the PersistState property is set to true, the DockingManager automatically saves its state using isolated storage when the window is closing. This feature is called AutoSave, and it helps maintain the layout and docking state between sessions. The saved state persists even if you clean the solution or restart the application.

For more details, please refer to the documentation.

Query 2: How can I delete the persisted state data?

To reset the DockingManager and remove any previously saved layout, you can use the ResetState method. This method clears the persisted state and reverts the DockingManager to its original layout as defined in your code. Here’s an example:

dockingManager1.ResetState();

This code will remove any saved state data, allowing the layout to return to its default configuration as per your application code.

Please let me know if you need further assistance or have any other questions.

Regards,

Sekar Sivalingam




GY Gil Yoder November 12, 2024 01:21 AM UTC

Thank you, Sekar, for your reply. However, I believe your description of ResetState's operation is inaccurate, as it does not restore the program's default configuration. My testing shows that it restores to the last auto-saved persist state. I followed these steps to exhibit this behavior.

1. Create a new WPF project.

2. From the toolbar, drag DockingManager to the main window.

3. Remove height and width properties from the Xaml DockingManager tag.

4. Set HorizontalAlignment="Stretch" in the DocumentManager tag.

5. Set VerticalAlignment="Stretch" in the DocumentManager tag.

6. Add PersistState="True" to the DockingManager tag.

7. Add x:Name=dockingManager" to DockingManger tag.

8. Add code to the Loaded event in MainWindow.xaml.cs to load the persisted data, i.e., this.documentManager.LoadDockState().

9. Execute the program in Debug mode.

10. Note the docking state of DockManager windows.

Image_1050_1731374016175

11. Tear the Dock Right window off into float mode.

12. Close MainWindow to close the application.

13. Restart the application in Debug mode.

14. Note the new docking state of DockManager windows.

Image_7103_1731374152697

15. Pull Auto Hidden off into float mode.

16. Close MainWindow to close the application.

17. Add a button to the Dock Bottom control.

18. Add a click event to the button.

    <Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click"/>

19. Add code to reset the DockManager state in the click event method.

29. Execute the application in Debug mode.

30. Note the document state.

Image_7447_1731374136216

31. Click the button created in the Dock Bottom pane.

32. Note the document state is unchanged.

33. Close the Auto Hidden window.

34. Click the button again.

35. The document state is restored to the state depicted in the third image, i.e., the last persisted state.

I wish to restore the docking state to the original state depicted in the first image.

If you can help me with this, please do.

Attached is a copy of the source I used for this test.


Attachment: DockmanagerTest_5e16007d.zip


SS Sekar Sivalingam Syncfusion Team November 13, 2024 03:12 PM UTC

Hi Gil Yoder,

We have updated the solution to address your requirement of restoring the initial docking layout. The docking state is now serialized to an XML file when the application first loads, and upon clicking the button, it restores the original layout by loading this saved state. We’ve implemented this by using XmlWriter to save and XmlReader to load the docking state.

Please refer to the attached modified sample and let us know if this resolves your issue.

Regards,

Sekar Sivalingam


Attachment: DockmanagerTest_af7cbb76.zip

Loader.
Up arrow icon