DockingManager persistence, a few questions

Hello

I have modified Docking manager example from github (https://github.com/SyncfusionExamples/working-with-wpf-docking-manager-and-mvvm). It is in the attachment.
I added SaveDockState and LoadDockState methods in the adapter, and added 2 new menu items to save and load layout.

1. Question
I run a program, load a txt file and Save layout. The saved XML file looks fine, it has 6 DockingParams elements (2 panes i 4 txt documents, original layout has 5). However, when I close the program, the saved layout XML file is overwritten with the original layout. Why this happens and how to prevent it?

2. Question
When I close the program and try to load file with the modified layout, there is no a tab for the previously loaded file. Method PART_DockingManager.LoadDockState returns false. Is it possible to load state for the newly, dynamically added documents, and load this state, just like Visual Studio does ?

3. Question
How do I correlate a DockingManager tab with its content? I don't see a way to, for example, say that a file should be displayed in a tab, or some object with some internal GUID id, or something like that. Avalon dock has a property ContentId which can be used for this, is there something similar in DockingManager?

Is there a working demo for restoring a full DockingMnager layout?

Thanks,
Tom

Attachment: workingwithwpfdocking_persistence_43128d0a.zip

12 Replies

UN Unknown Syncfusion Team March 6, 2020 12:59 PM UTC

Hi Tom, 

Thanks for contacting Syncfusion support. 

Please refer the below table. 

S.No 
Query  
Answer 
I run a program, load a txt file and Save layout. The saved XML file looks fine, it has 6 DockingParams elements (2 panes i 4 txt documents, original layout has 5). However, when I close the program, the saved layout XML file is overwritten with the original layout. Why this happens and how to prevent it? 
Currently we don’t have support to serialize the state of DockingManager children which has been added during runtime. Please refer the below documentation for same. 


And we are analyzing why the serialized data of DockingManager children added in runtime is removed from saved layout when application is closed and we will update you on  11th March 2020. 
When I close the program and try to load file with the modified layout, there is no a tab for the previously loaded file. Method PART_DockingManager.LoadDockState returns false. Is it possible to load state for the newly, dynamically added documents, and load this state, just like Visual Studio does ? 
How do I correlate a DockingManager tab with its content? I don't see a way to, for example, say that a file should be displayed in a tab, or some object with some internal GUID id, or something like that. Avalon dock has a property ContentId which can be used for this, is there something similar in DockingManager? 
We can correlate the DockingManager tab with its content by using Name property which is unique as ContentId property  in AvalonDock . 
Is there a working demo for restoring a full DockingMnager layout? 
The layout of the DockingManager can be restored to initial layout by using ResetState method as shown in below code snippet. 
C#: 
PART_DockingManager.ResetState(); 
      

Regards, 
Niranjan Kumar 



TT Tomislav Tustonic March 6, 2020 02:19 PM UTC

Hello
Thanks for your answer.
The ContentId property in AvalonDock can be any string, while the Name property must be a valid name for a control, which means it can't be a file path, url, guid etc.
But, it's not much of a problem, since it's impossible to save children added during runtime.
Unfortunately, this is a deal breaker for my project, so I'll have to keep using AvalonDock.

Thanks,
Tom



UN Unknown Syncfusion Team March 9, 2020 10:02 AM UTC

Hi Tom, 

Thanks for your update. 

We have checked your requirement and logged it as feature request. This feature will be included in any of our upcoming releases, so please refer the below feedback link for same. 


Regards, 
Niranjan Kumar 



TT Tomislav Tustonic March 9, 2020 02:06 PM UTC

Ok, thanks a lot.

Tom


UN Unknown Syncfusion Team March 10, 2020 05:30 AM UTC

Hi Tom, 

Thanks for your update. 

We will be happy to assist you anytime if you require further assistance. 

Regards, 
Niranjan Kumar 





TT Tomislav Tustonic April 11, 2021 11:52 PM UTC

Hello
I didn't look at this for a while, and I see that the feature request is marked completed:
https://www.syncfusion.com/feedback/12590/need-to-save-the-layout-of-children-in-dockingmanager-which-is-added-in-run-time
Thanks a lot.
However, I don't understand how does it work.
I'd like to have a feature similar to what Visual Studio does... open a few text documents, each in its own tab, save the layout, and the application is automatically restored to the saved state on the next start.
Is this possible, and is there a demo for this feature?

Thanks, Tom

PS: Documentation
https://help.syncfusion.com/wpf/docking/state-persistence#serialize-the-dynamically-added-children
still claims that this isn't possible.



SG Sangeetha Ganesan Syncfusion Team April 14, 2021 03:25 AM UTC

Hi Tom, 
  
Thanks for your update. 
  
We have same feature as Visual Studio that is, we have a child in DockingManager control and added children at run time and change the state of any one child and save it state using SaveDockState(). When we restart the application and call the LoadDockState() it loads the children state what we saved in SaveDockState().Please check the video and sample for your reference. 
  
 
Note : If the children are not in the collection it will not serialize. 
 
Please ensure the video and let us know if you need any further assistance on this. We will be glad to assist you. 
  
Regards, 
Sangeetha G 



TT Tomislav Tustonic April 14, 2021 12:13 PM UTC

Hello
Thanks for the reply, however that's not it.
Even in your video, the tabs 'Output' and 'StartPage' are not restored after you restart the application and load state.
So, I don't think that the feature is implemented, and perhaps it should be reopened.

Tom    


SG Sangeetha Ganesan Syncfusion Team April 14, 2021 12:56 PM UTC

Hi Tom, 


When there is a mismatch in children in saved file and DiagramManager.Children, DockingManager will smartly ignore those mismatches by
 
  
  1. closing the extra children (that is not present in the saved file)
  2. realign layout in such a way that missed children (child listed in saved file, bot available in DockingManager.Children ) are considered as closed.
When there is a mismatch, after restoring the layout as in saved file using Load method, it will return false. Based on this you can find missing children and add them back in application side and load the layout again. This behavior is explained in blog with full details 


Code snippet: 

    if (!dockingManager.LoadDockState(loadLayoutPath)) 
    { 
        var savedWindows = GetSavedWindowList(loadLayoutPath); 
        var missingChildren = FindMissingChidren(dockingManager, savedWindows); 
        AddMissedChildrensIntoDockingManager(missingChildren); 
    } 
    this.dockingManager.LoadDockState(formatter, StorageFormat.Xml, loadLayoutPath); 
 
 
 
Please refer following method from the sample that gives solution for your requirement. 

    GetSavedWindowList() 
    FindMissingChidren() 
    AddMissedChildrensIntoDockingManager() 
 

Regards, 

Sangeetha G 
  



TT Tomislav Tustonic April 14, 2021 02:10 PM UTC

Ok, thanks.
I'll have a look at the blog post and Github sample and see what and how.

Cheers, Tom


TT Tomislav Tustonic April 15, 2021 01:09 AM UTC

This seems to work, thanks.
There's a bug in the example. I have submitted the bug report, so you may want to fix it.

Tom


SG Sangeetha Ganesan Syncfusion Team April 15, 2021 04:11 PM UTC

Hi Tom, 
 
Thanks for your update. 
We have reported your problem with concern team. We will get back with you once it gets resolved. 
Regards, 
Sangeetha G 


Loader.
Up arrow icon