How to restore closed windows with the Prism example?

Following your example of integrating Prism with the dock manager, I wanted to add a thing that it was currently lacking: the ability to restore closed documents.

Not without trouble to be honest, I finally got something to work:

I2qzPfX05X.png


So basically, in the behavior, I listen to the region's active views collection changes and directly work with the docking manager:

    private void RegionActiveViewsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
var manager = HostControl as DockingManager ?? throw new InvalidCastException();


switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
{
foreach (var element in e.NewItems?.Cast() ?? throw new NullReferenceException())
{
var state = DockingManager.GetState(element);


switch (state)
{
case DockState.Dock:
throw new NotImplementedException();
case DockState.Float:
throw new NotImplementedException();
case DockState.Hidden:
DockingManager.SetState(element, DockState.Document);
break;
case DockState.AutoHidden:
throw new NotImplementedException();
case DockState.Document:
manager.ActiveWindow = element;
break;
default:
throw new ArgumentOutOfRangeException();
}
}


break;
}
}

(complete example: https://github.com/aybe/SfDocking)

Question:

Is this the correct way to restore windows that have been closed by the user?


Thank you


2 Replies 1 reply marked as answer

SN Sudharsan Narayanan Syncfusion Team March 17, 2022 03:42 AM UTC

Hi Aybe,

We have checked the GitHub code that you attached in the last update,

Query:
Is this the correct way to restore windows that have been closed by the user?

Yes, your scenario is correct to restore the closed window by using menu item. You can proceed with the same way to achieve the requirement.

Please check and let us know if you require any further assistance with this. We will be happy to assist you.

Regards,
Sudharsan


Marked as answer

AY aybe March 17, 2022 11:47 AM UTC

Thank you guys, I'm slowing starting to get acquainted with the framework! 😀


Loader.
Up arrow icon