Save/Load the Content of the Panes

This tutorial will walk you through the common tasks of saving the content of the panes.

RadDocking cannot save the Content of the panes itself. It only remembers the properties of the panes, the groups and the split containers and the way they are changed.

Tha Save/Load layout mechanism matches the SerializationTag of the saved pane with the SerializationTag of the pane that is already created. It works for the static panes, because when your application loads, the XAML parser creates correctly all the static panes and their contents. The dynamic panes are created by the RadDocking control and it doesn't know what content to put in them.

When a ToolWindow, PaneGroup or SplitContainer instance is auto-generated by the RadDocking in order to set the SerializationTag for these elements the ToolWindowCreated, PaneGroupCreated and SplitContainerCreated could be handled. Inside them the newly created instance could be found and SerializationTag could be set to them as demonstrated in Example 1:

Example 1: Setting SerializationTag

private void radDocking_PaneGroupCreated(object sender, Telerik.Windows.Controls.Docking.ElementCreatedEventArgs e) 
{ 
    var newGroup = e.CreatedElement as RadPaneGroup; 
 
    if (newGroup != null && RadDocking.GetSerializationTag(newGroup) == null) 
    { 
        RadDocking.SetSerializationTag(newGroup, "CustomSerializationTag"); 
    } 
} 
For the purpose of this tutorial the following RadDocking declaration will be used:

Example 2: RadDocking declaration

<telerik:RadDocking x:Name="radDocking"> 
    <telerik:RadSplitContainer> 
        <telerik:RadPaneGroup x:Name="Group1" 
    telerik:RadDocking.SerializationTag="Group1"> 
            <telerik:RadPane Header="static pane 1" 
        telerik:RadDocking.SerializationTag="staticpane1"> 
                <TextBox Text="Some content" /> 
            </telerik:RadPane> 
        </telerik:RadPaneGroup> 
    </telerik:RadSplitContainer> 
</telerik:RadDocking> 
Silverlight RadDocking Pane Declaration

You can save the panes' content by handling the ElementLoaded event of the RadDocking control and setting the content of the newly created pane yourself.

Attach to the ElementLoaded event of the RadDocking element.

Example 3: Attaching to the ElementLoaded event

<telerik:RadDocking x:Name="radDocking1" ElementLoaded="radDocking_ElementLoaded"> 

Example 4: Get Content of Pane

private void radDocking_ElementLoaded(object sender, Telerik.Windows.Controls.LayoutSerializationEventArgs e) 
{ 
    var pane = e.AffectedElement as RadPane; 
    if (pane != null) 
    { 
        pane.Content = this.GetPaneContent(e.AffectedElementSerializationTag); 
    } 
} 
Private Sub radDocking_ElementLoaded(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.LayoutSerializationLoadingEventArgs) 
    Dim pane = TryCast(e.AffectedElement, RadPane) 
    If pane IsNot Nothing Then 
        pane.Content = Me.GetPaneContent(e.AffectedElementSerializationTag) 
    End If 
End Sub 

The GetPaneContent() method needs to be implemented with the specific user custom logic.

See Also

In this article