Layout Serialization for the multiple Docksites.

Docking/MDI for WPF Forum

Posted 7 years ago by keshav bansal
Version: 12.2.0573
Avatar

Hi,

How to implement Layout Serialization for the multiple Docksites ?

For Example: My layout of the shell.xaml is like

<Grid Name="shellGrid">

<Grid.RowDefinitions>

<RowDefinition Height="Auto"></RowDefinition>

<RowDefinition Height="Auto"></RowDefinition>

<RowDefinition Height="Auto"></RowDefinition>

<RowDefinition Height="*"></RowDefinition>

</Grid.RowDefinitions>

<ContentControl Grid.Row="0" x:Name="ContentControl 1"></ContentControl>

<docking:DockSite Grid.Row="1" x:Name="Docksite1" > </docking:DockSite>

<docking:DockSite Grid.Row="2" x:Name="Docksite2"> </docking:DockSite>

<docking:DockSite Grid.Row="3">

<docking:ToolWindowContainer>

<docking:ToolWindow >

<docking:DockSite Background="#6682b0"CanToolWindowsAttach="False"UseHostedAutoHidePopups="False"x:Name="BaseDocksite1">

<docking:Workspace>

<docking:DockSite UseHostedAutoHidePopups="False"Background="#6682b0"x:Name="BaseDocksite2">

<docking:Workspace>

<Grid Name="ReviewUIGrid">

<Grid.ColumnDefinitions>

<ColumnDefinition  Width="Auto" />

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<docking:DockSite VerticalAlignment="Top"Grid.Column="1"AllowDrop="True" CanDocumentWindowsRaft="False"x:Name="InnerDocksite1" >

</docking:DockSite>

 

<docking:DockSite VerticalAlignment="Top"Grid.Column="0" AllowDrop="True" CanDocumentWindowsRaft="False"x:Name="InnerDocksite2" >

</docking:DockSite>

<ContentControlBackground="#6682b0"Grid.Column="2"x:Name="ContentControl3"></ContentControl>

</Grid>

</docking:WorkSpace>

</docking:Docksite>

</docking:WorkSpace>

</docking:Docksite>

</docking:ToolWindow>

</docking:ToolWindowContainer>

</docking:Docksite>

</Grid>

Above Layout consists of Following things.

1:Combination of the Wpf Content Controls as well as the Actipro Docksites.

2. Multiple Docksites with in the Grid.Each Docksite will be registered with the single toolwindow.

3.Window inside the window Hirarchy is used as the Row 3 in the above layout.

4. As per the Row 3 of the above Layout,Workspaces used for the individual windows.Means InnerDocksite1 Toolwindow is Linked to the BaseDocksite1 so we can move the InnerDocksite1 Toolwindow  to the BaseDocksite1 Workspace.Similarly InnerDocksite2 Toolwindow is Linked to the BaseDocksite2 so we can move the InnerDocksite2 Toolwindow to the BaseDocksite2 Workspace

As per the above Layout according to the Different Docksites for the Different Toolwindows.

As all th usercontrols will be loaded as the toolwindows in the corresponding docksite with the help of PrismIntegration with Docking.

So as i run the application,Toolwindows will be displayed in their Docksite and when i drag the toolwindow inside InnerDocksite1 and move it to BaseDocksite1 and then i drag the toolwindow inside InnerDocksite2 and move it to BaseDocksite2.

And Now as i close the application ,Layout should be save in the XML and when i again run the application,it should load the saved Layout and Display the Toolwindows as in the Last Docked state when they were closed and other control should be displayed as same as it was pervieious loaded.   

Comments (5)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Keshav,

You appear to be doing four level nesting of DockSites and allowing linked DockSites between.  That is a far more complex than our product is intended for, but I suppose it works for you.

I'd probably recommend using layout serialization features (as described in the documentation) starting from the outermost DockSite and move inward from there.  So when you go to restore layouts, do it on the outermost DockSite first, then its child DockSite, etc.


Actipro Software Support

Posted 7 years ago by keshav bansal
Avatar

Hi,

I am not able to serialize the toolwindows that are moved to the another Workspace.

Code used in the Sample application is belowed.

-----------------------------------------------------------------------------------------------

<docking:DockSite Grid.Row="0" x:Name="BaseDocksite">

<docking:SplitContainer>

<docking:Workspace>

<Grid><Grid.RowDefinitions><RowDefinition Height="*" /><RowDefinition Height="Auto" /></Grid.RowDefinitions>

<docking:DockSite Grid.Row="0"UseHostedAutoHidePopups="False"VerticalAlignment="Top"Background="#6682b0"AllowDrop="True" CanDocumentWindowsRaft="False"x:Name="Docksite1" cal:RegionManager.RegionName="{x:Static sample:RegionNames.MainRegion}">

<docking:Workspace>

<docking:TabbedMdiHost />

</docking:Workspace></docking:DockSite>

<docking:DockSite x:Name="Docksite2"Grid.Row="1">

<docking:ToolWindowContainer><docking:ToolWindow Title="Toolwindow2"></docking:ToolWindow></docking:ToolWindowContainer>

</docking:DockSite></Grid>

</docking:Workspace>

</docking:SplitContainer>

</docking:DockSite>

Above code is having the BaseDocksite(With Worspace) named BaseDocksite and two other Docksites named Docksite1,Docksite2.

As Docksite2 is linked to the BaseDocksite which means Docksiet2 toolwindow can be moved to the BaseDocksite workspace.

Code used to link the Docksites is

Docksite2.LinkDockSite(BaseDocksite);

------->So when i drag the Docksite2 toolwindow and moved to the BaseDocksite workspace and then i close the application.

After that ,i am saving the Layout of the Docksite2 and the BaseDocksite using

dockSiteLayout = layoutSerializer.SaveToString(BaseDocksite);

dockSiteLayout1 = layoutSerializer1.SaveToString(Docksite2);

layoutSerializer.SaveToFile(@"D:\abc.xml");

layoutSerializer1.SaveToFile(@"D:\abcIn2.xml");

And when i again load the application , its loading the saved Layout using the belowed code--

dockSiteLayout = System.IO.File.ReadAllText(@"D:\abc.xml");

dockSiteLayout1 = System.IO.File.ReadAllText(@"D:\abcIn2.xml");

this.layoutSerializer.LoadFromString(dockSiteLayout, BaseDocksite);

this.layoutSerializer1.LoadFromString(dockSiteLayout1, Docksite2);

------> But i am not getting the toolwindow that was moved in the BaseDocksite Workspace.

So how to save the Layout for the Toolwindows that are moved to the Different Docksite workspace and How to  load e Layout for the Toolwindows that are moved to the Different Docksite workspace ?

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Keshav,

Well here you had your tool window defined in one DockSite (via the XAML) but the layout for the other DockSite is where you intend to restore it.  That other DockSite doesn't know about it at the time you do the load, so it can't load it.

There are workarounds for that though.  You need to read through the "Layout Serialization" documentation topic because that describes how to handle this sort of thing.

You also are missing a critical thing (giving the tool window an x:Name) that is described in that topic.  If it's not named, it can't be found by the deserializer.


Actipro Software Support

Posted 7 years ago by keshav bansal
Avatar

Hi,

I read the Layout Serialization topic and  also using the toolwindow names for the Serializing  and Desaerializing these toolwindows.

But its not working in case of LinkDockSites.

                                           Please read the steps Carefully

Step1---------->Suppose i have two docksites named Docksite1 and Docksite2 and these having toolwindows named toolwindow1 and toolwindow2 respectively.

Step2------------>These Docksites(Docksite1 and Docksite2 ) are Linked to each other using Docksite1.LinkDockSite(Docksite2);

Step3------------->So i drag the Toolwindow1 from the Docksite1 and dock it to the Docksite2(with respect to the toolwindow2).

Step4-------------->Now both the toolwindows are in the same Docksite named Docksite2.

Step5--------------->Now i close the application.

Step6--------------->Saving the Layout of the Both docksites(Docksite1 and Docksite2) in XML. 

Step7--------------->Now again i run the application.

Step8--------------->Loads the saved XML layout and it should display the toolwindow1 and toolwindow2 in the Docksite2 which means when they were last docked before closing of  the application.

But its Not happpening. Its NOT displaying the toolwindow2 in the Docksite2(According to the XML Layout) But toolwindow2 is saved in the Docksite2 XML layout.

 

[Modified 7 years ago]

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

In the scenario you give, I would expect toolwindow2 to definitely show up as long as you have set its x:Name, since that is a normal layout serialization use case (it's already defined in the target DockSite).

In order for toolwindow1 to show up, it would also need an x:Name AND you'd have to follow the steps in that documentation topic for handling deserialization when a DockSite doesn't know about the tool window.

If you'd like us to look into it further, please make a new simple sample project with this minimum example that you are explaining and send that to our support address.  Please reference this post and rename the .zip file extension so it doesn't get spam blocked.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.