Version

Load an End User’s Docking Layout

The xamDockManager ™ control allows your end users to modify the layout of your application. Your end users will expect you to save and load these settings so that they do not have to modify the layout when they restart your application. The xamDockManager control exposes an overloaded LoadLayout method that you can use to load a previously saved docking layout.

Note
Note

The xamDockManager does not create and add content panes automatically based on the layout file information. The content panes need to exist prior the invoking of the LoadLayout method. If xamDockManager discovers a content pane in the layout file that is not found among the content panes of the current layout, the InitializePaneContent event will be fired and you can provide content for the missing content pane. To distinguish content panes and figure out what content you need to provide you can use the SerializationId property. If you do not provide content during this event, xamDockManager will not add the missing content pane to its layout.

The example code below demonstrates how to load a previously saved docking layout.

In Visual Basic:

Imports System.IO
...
' Load the layout from a stream
Using fs As New FileStream("layout.xml", FileMode.Open, FileAccess.Read)
    Me.xamDockManager1.LoadLayout(fs)
End Using
...
' Handle the InitializePaneContent event to add content to missing panes
Private Sub xamDockManager1_InitializePaneContent(ByVal sender As Object,
    ByVal e As InitializePaneContentEventArgs)
    ' TODO: Add content to the missing content pane using the e.NewPane object
End Sub
...

In C#:

using System.IO;
...
// Load the layout from a stream
using (FileStream fs = new FileStream("layout.xml", FileMode.Open, FileAccess.Read))
{
    this.xamDockManager1.LoadLayout(fs);
}
....
// Handle the InitializePaneContent event to add content to missing panes
private void xamDockManager1_InitializePaneContent(object sender,
    InitializePaneContentEventArgs e)
{
    // TODO: Add content to the missing content pane using the e.NewPane object
}
...