This is a migrated thread and some comments may be shown as answers.

Prism and RadDocking save/restore

11 Answers 211 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 15 Mar 2011, 12:49 AM
I'm using the Telerik Docking controls for my Prism regions and everything works just great on the initial display. I can use the splitter bars and change sizes of panes. I can dock and float panes... everything a good UI would want to do.

But now I come to the hard part... saving a layout and restoring it.

I figured I'd have some challenges and I've been fighting this off and on for a bit, and finally today came to the realization that when I do the restore, it's not interleaving the xaml with the layout parameters, it's doing a wholesale replace.

If I read my layout.xml file in, my layout appears to change to where I wanted it, but then the Prism RegionManager tells me I have no regions.

If I run the exact same block of code and skip the layout restore, all my regions are available.

I tried to insert the prism region code into the xml stream, but had a run-time error.

I've fully understood that I needed to restore my content, but I didn't expect all the xaml tags on the RadDocking and RadSplitContainer to be completely replaced with what was saved with the save layout command.

This looks like a deal-breaker to me.

-Dave

For reference, here is the first region:

<telerikDocking:RadDocking Margin="0,24,0,0"                                         
                           Grid.Row="0"                                              
                           Grid.RowSpan="3"                                          
                           x:Name="dock"                                             
                           ElementLoading="dock_ElementLoading"                      
                           Close="dock_Close">                                       
    <telerikDocking:RadSplitContainer x:Name="LeftContainer"                         
                                      Orientation="Vertical"                         
                                      InitialPosition="DockedLeft"                   
                                      prism:RegionManager.RegionName="LeftToolRegion">
                                          
    </telerikDocking:RadSplitContainer>                                              


I am wrapping my view, which is a UserControl, in a RadPane/RadPaneGroup and adding it to the Region
In the course of the wrapping, I add the SerializationTag.

The saved layout for this section looks like this (with some other things also left off for clarity:

<RadDocking>
...
   <SplitContainers>
      <RadSplitContainer Dock="DockedLeft" Width="240" Orientation="Vertical">
         <Items>
            <RadPaneGroup SerializationTag="TestAppModule.TestAppModuleView" SelectedIndex="0">
               <Items>
                  <RadPane IsPinned="True" IsDockable="True" Title="Test AppModule" Header="Test AppModule" CanUserClose="False" CanDockInDocumentHost="False" CanFloat="False" />
               </Items>
            </RadPaneGroup>
         </Items>
      </RadSplitContainer>
...






11 Answers, 1 is accepted

Sort by
0
Nick
Top achievements
Rank 1
answered on 17 Mar 2011, 01:58 AM
I'm having a similar problem - I've applied a custom style to a RadSplitContainer which works fine the first time, but when the layout is restored, the style is not applied to the RadSplitContainer. Is it possible to apply the style programatically during deserialisation?
0
George
Telerik team
answered on 17 Mar 2011, 05:00 PM
Hello,

 
Dave:

As long as I see, in the saved xml the RadPane has no SerializationTag. I would suggest you to set it and try again. If this doesn't help, could you please give us more detailed information about your scenario? Do you define the RadPanes as Views? If you send us a sample project that reproduces the problem it would be of great help.

Nick:

No, unfortunately it is not possible. I would suggest you to handle the PaneStateChange event and to set SerializationTag to the RadSplitContainers. When you load the layout, in the PaneStateChange event handler you could set the style for each split container. I hope this helps.

Please do not hesitate to contact us if you require any further information.


Regards,
George
the Telerik team
0
Dave
Top achievements
Rank 1
answered on 17 Mar 2011, 05:33 PM
Hi George....

I apparently had sent you code and xml that was during change attempts trying to figure this out.

The XAML for the area in quesiton hasn't changed:

<telerikDocking:RadDocking Margin="0,24,0,0"                                         
                           Grid.Row="0"                                              
                           Grid.RowSpan="3"                                          
                           x:Name="dock"                                             
                           ElementLoading="dock_ElementLoading"                      
                           Close="dock_Close">                                       
    <telerikDocking:RadSplitContainer x:Name="LeftContainer"                         
                                      Orientation="Vertical"                         
                                      InitialPosition="DockedLeft"                   
                                      prism:RegionManager.RegionName="LeftToolRegion">
                                          
    </telerikDocking:RadSplitContainer>                                              


because I'm wrapping a UserControl in a RadPane and RadPaneGroup to allow my modules to be blendable.

I made certain that I had my SerializationTag back on the RadPane in the wrapper, and saving the laout produces this, again with only the portion associated with the XAML above shown:

<?xml version="1.0" encoding="utf-8"?>
<RadDocking>
   <DocumentHost>
      <RadSplitContainer>
         <Items>
            <RadPaneGroup SelectedIndex="0">
               <Items>
               ...
               </Items>
            </RadPaneGroup>
         </Items>
      </RadSplitContainer>
   </DocumentHost>
   <SplitContainers>
      <RadSplitContainer Dock="DockedLeft" Width="240" Orientation="Vertical">
         <Items>
            <RadPaneGroup SelectedIndex="0">
               <Items>
                  <RadPane SerializationTag="QuickLinksModule.QuickLInksView" IsPinned="True" IsDockable="True" Title="Quick Links" Header="Quick Links" CanUserClose="False" CanDockInDocumentHost="False" CanFloat="True" />
               </Items>
            </RadPaneGroup>
            <RadPaneGroup SelectedIndex="0">
               <Items>
                  <RadPane SerializationTag="TestAppModule.TestAppModuleView" IsPinned="True" IsDockable="True" Title="Test AppModule" Header="Test AppModule" CanUserClose="False" CanDockInDocumentHost="False" CanFloat="True" />
               </Items>
            </RadPaneGroup>
         </Items>
      </RadSplitContainer>
      <RadSplitContainer Dock="DockedTop" Height="280" Orientation="Horizontal">
         <Items>
            <RadPaneGroup SelectedIndex="4">
               <Items>
               ...
               </Items>
            </RadPaneGroup>
         </Items>
      </RadSplitContainer>
   </SplitContainers>
</RadDocking>

So, now I indeed have SerializationTags on my RadPanes, not my RadPaneGroups as I showed the last time.

After saving the layout, I ran this code on a 'restore' button press

            IRegionManager regionManager = container.Resolve<IRegionManager>();
            IRegion region = regionManager.Regions["LeftToolRegion"];

this functioned fine, and returned the region for me

The code then  ran the load layout code in your samples:

            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var isoStream = storage.OpenFile("RadDocking_Layout.xml"FileMode.Open))
                {
                    dock.LoadLayout(isoStream);
                }
            }

, then ran this code:

            IRegion region2 = regionManager.Regions["LeftToolRegion"];

And threw an exception because "The region manager does not contain the LeftToolRegion region."

My Prism regions are in the XAML prior to doc,.LoadLayout, and they're not there after.

Maybe wholesale replacement of the XAML for the RadDocking part of the XAML is what this is supposed to be doing, but if that's what it really is doing, it's also wiping out other tags that I need, such as this one on the RadSplitContainer (also shown in the XAML above):

prism:RegionManager.RegionName="LeftToolRegion"





-Dave

0
George
Telerik team
answered on 22 Mar 2011, 05:32 PM
Hello Dave,

 
The RadSplitContainer which is set for a Region is without a SerializationTag. When the RadDocking control is loaded, it won't generate the same RadSplitContainer. Could you set a SerializationTag for this RadSplitContainer? This should resolve the issue.

If it doesn't help, we will greatly appreciate a sample project of yours. It will definitely help us in further pinpointing and resolving the problem.

All the best,
George
the Telerik team
0
Dave
Top achievements
Rank 1
answered on 22 Mar 2011, 06:17 PM
So it works different than this page implies?

http://www.telerik.com/help/silverlight/raddocking-features-save-load-layout.html

on that page, it says to "Set the RadDocking.SerializationTag attached property for each one of the panes in your xaml declaration"

and you're not setting it on the RadSplitContainer...

I'll give it a try later

-Dave
0
Dave
Top achievements
Rank 1
answered on 22 Mar 2011, 09:18 PM
Hi George...

Now you've really got me confused...

You said "Could you set a SerializationTag for this RadSplitContainer?"

So rather than do the XAML first, I setup all the rest of my instrumentation to test this. When I got to the XAML, I tried adding a SerializationTag to the first RadSplitContainer and it wouldn't take it, because "The property 'SerializationTag' was not found in type 'RadSplitContainer'."

I'm running the latest bits... has something changed?

-Dave
0
George
Telerik team
answered on 23 Mar 2011, 09:21 AM
Hello Dave,

 
Yes, you are right that in our documentation it is said that the SerializationTag could be set to the RadPanes and to the RadPaneGroups. In this case, using the RadSplitContainer as a Region, I would suggest you to set it to the RadSplitContainer as well.

I look at the screenshot. Please, pay attention to that the RadDocking.SerializationTag is an attached property. You could set it like this: telerikDocking:RadDocking.SerializaionTag="".

Greetings,
George
the Telerik team
0
Zack
Top achievements
Rank 1
answered on 06 Dec 2013, 03:44 PM
Hi there,

My application is Silverlight 5 / PRISM / C#.
My telerik version is: 2013.3.1016.1050

I want to use the Load/Save feature of the RadDocking.

The "Regions:RegionManager" attached properties are not saved as well as all the "infadpt:" ones. I have set the SerializationTag as suggested in this post. No joy.

Could you help me?

My xaml code is below:

<telerik:RadDocking x:Name="RadDockingMainDockingControl" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CloseButtonPosition="InPaneAndGroup">
 
    <telerik:RadSplitContainer InitialPosition="DockedLeft">
        <telerik:RadPaneGroup Name="RadPaneGroupDockedLeft" Regions:RegionManager.RegionName="DockedLeftRegion" infadpt:RadPaneGroupRegionAdapter.RadDockingParent="{Binding Path=DockManager}" infadpt:RadPaneGroupRegionAdapter.ItemContainerStyle="{StaticResource SimpleHeaderTemplate}" telerik:RadDocking.SerializationTag="DockedLeftRegion"/>
    </telerik:RadSplitContainer>
 
    <telerik:RadSplitContainer InitialPosition="DockedRight" telerik:DockingPanel.InitialSize="450,360">
        <telerik:RadPaneGroup Name="RadPaneGroupDockedRight" Regions:RegionManager.RegionName="DockedRightRegion" Regions:RegionManager.RegionManager="{Binding Path=RegionManager}" infadpt:RadPaneGroupRegionAdapter.ItemContainerStyle="{StaticResource SimpleHeaderTemplate}" telerik:RadDocking.SerializationTag="DockedRightRegion" />
    </telerik:RadSplitContainer>
 
    <telerik:RadSplitContainer InitialPosition="DockedBottom">
        <telerik:RadPaneGroup Name="RadPaneGroupDockedBottom" Regions:RegionManager.RegionName="DockedBottomRegion" infadpt:RadPaneGroupRegionAdapter.RadDockingParent="{Binding Path=DockManager}" infadpt:RadPaneGroupRegionAdapter.ItemContainerStyle="{StaticResource SimpleHeaderTemplate}" telerik:RadDocking.SerializationTag="DockedBottomRegion"/>
    </telerik:RadSplitContainer>
 
    <telerik:RadDocking.DocumentHost>
        <telerik:RadSplitContainer>
            <telerik:RadPaneGroup Name="RadPaneGroupTabbedDocuments" Regions:RegionManager.RegionName="DockingAreaRegion" Regions:RegionManager.RegionManager="{Binding Path=RegionManager}" infadpt:RadPaneGroupRegionAdapter.ItemContainerStyle="{StaticResource HeaderTemplate}" telerik:RadDocking.SerializationTag="DockingAreaRegion" >
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
    </telerik:RadDocking.DocumentHost>
</telerik:RadDocking>
0
George
Telerik team
answered on 10 Dec 2013, 09:11 AM
Hello Stephen,

Setting SerializationTag marks that the group will be cached in docking control and the next time the layout is loaded, the same pane group instance will be used. This ensures that all attached properties will be kept. Can you give us more information about the faced issue? What do you mean that the attached properties are not saved?

I am glad to assist you further.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Zack
Top achievements
Rank 1
answered on 10 Dec 2013, 04:44 PM
Hi George

I understand perfectly what should happen when setting the SerializationTag.
All attached properties should be kept as you said.
But in my case, it is not.

I save my layout using the following code:
var container = _unityContainer.Resolve<Telerik.Windows.Controls.RadDocking>();
 
MemoryStream stream = new MemoryStream();
container.SaveLayout(stream);
 
stream.Seek(0, SeekOrigin.Begin);
 
StreamReader reader = new StreamReader(stream);
var layoutxml = reader.ReadToEnd();
 
this.Save("LayoutList", FileName, layoutxml);

the xml from the stream above, does not have any attached property. But the serializationTag is there.

Please help me, I have been spending hours on this. Am I doing something wrong?

Just wondering if could be the xml being saved in the database... then the user will logon on and load his/her desired layout, which is part of the userprofile database (where I am saving the layout xml) - line: this.Save("LayoutList", FileName, layoutxml); Am I losing the cache doing that?

Thanks,
0
George
Telerik team
answered on 11 Dec 2013, 04:00 PM
Hello Stephan,

The described behavior is by design - the attached properties are not saved in the xml, but setting SerializationTag ensures that the same group will be reused in loading. Even though the application is closed and reopened again, the group with its attached properties is defined in the xaml and it will be created.

You are not doing anything wrong, this is how Save/Load layout feature works. I am still unsure about what is the issue with docking control. If you want to save the xml in a database and reuse it for other docking control which has complete different initial layout and these attached properties are not set in the xaml, I could suggest a different approach:
    -  When saving: you could save an additional dictionary for the attached properties in each pane group, split container, pane
    - When loading: handle the RadDocking.ElementLoaded event. You can get the affected element using the arguments and set the attached properties.

Please, note that we introduced our brand new example how to use RadDocking with PRISM which covers save/load layout. You can find it here - http://blogs.telerik.com/blogs/13-12-11/using-raddocking-with-prism-in-wpf-silverlight. Hope this helps.


Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Docking
Asked by
Dave
Top achievements
Rank 1
Answers by
Nick
Top achievements
Rank 1
George
Telerik team
Dave
Top achievements
Rank 1
Zack
Top achievements
Rank 1
Share this question
or