バージョン

SerializationId プロパティ

レイアウトが保存される時にペインと一緒に保存される文字列を返す/設定します。
シンタックス
'宣言
 
Public Property SerializationId As String
public string SerializationId {get; set;}
解説

SeralizationId プロパティは ContentPane に使用されません。その代わり、SaveLayout(Stream) メソッドを使用すると、このプロパティの値がレイアウトとともに保存されます。このプロパティは、ペインがまだ読み込みされていない場合にレイアウトが読み込みされる時に ContentPane を作成するために使用できる情報を保存するために使用できます。ContentPane が読み込みされたレイアウト内で参照され、保存された名前が付けられたペインがレイアウト内に存在しない場合、InitializePaneContent イベントが発生してペインのコンテンツを作成することができます。SerializationId は、作成したいコンテンツのタイプを識別するために使用できます。たとえば、レイアウトが読み込みされる時にファイルを読み込めるように、これをファイル名に設定できます。

使用例
Imports Infragistics.Windows.DockManager
Imports Infragistics.Windows.DockManager.Events

Private Sub InitializeDmWithSaveInLayout(ByVal dockManager As XamDockManager)
    ' hook the InitializePaneContent to dynamically provide the 
    ' content for panes that are loaded at runtime. for example, 
    ' if your application creates documents for files that the 
    ' user opens you could let those panes be saved, store information 
    ' in the SerializationId of the pane to know what to load and then 
    ' load that information into the pane in the InitializePaneContent 
    ' when you load a layout 
    AddHandler dockManager.InitializePaneContent, AddressOf dockManager_InitializePaneContent
End Sub

Private Sub mnuOpen_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim file As String = Me.OpenFile()
    Dim rtb As RichTextBox = CreateRichTextBox(file, DataFormats.Rtf)

    If rtb IsNot Nothing Then
        Dim fileName As String = System.IO.Path.GetFileName(file)
        Dim cp As ContentPane = Me.dmSaveInLayout.AddDocument(fileName, rtb)

        ' in order for the pane to be saved we must give it a unique name 
        ' since we won't be using the name we can just use a guid. we have 
        ' to use the format string that does not include "-" since that 
        ' is not valid for an element name. prefix with a letter since 
        ' the name cannot start with a number 
        cp.Name = "A" + Guid.NewGuid().ToString("N")

        ' store the path to the file. the SerializationId will be saved 
        ' in the layout with the pane so we can use this information from 
        ' within the InitializePaneContent to know what file to load 
        ' when a layout containing this pane is loaded 
        cp.SerializationId = file
    End If
End Sub

Private Sub dockManager_InitializePaneContent(ByVal sender As Object, ByVal e As InitializePaneContentEventArgs)
    Dim id As String = e.NewPane.SerializationId

    Dim rtb As RichTextBox = CreateRichTextBox(id, DataFormats.Rtf)

    ' if you set the Content of the NewPane to a non-null value then that 
    ' pane will be kept in the newly loaded layout. if you do not set the 
    ' content to a non-null value then the pane will be discarded 
    e.NewPane.Content = rtb
End Sub
Private Function OpenFile() As String

    ' simple helper method for prompting for an rtf file 
    ' you could show a file open dialog, etc. 
    Dim dlg As New Microsoft.Win32.OpenFileDialog()
    dlg.DefaultExt = ".rtf"
    dlg.Filter = "RichText Files (*.rtf)|*.rtf"

    If dlg.ShowDialog(Me) = True Then
        Return dlg.FileName
    End If

    Return Nothing
End Function

' simple helper method for creating a richtextbox with 
' contents loaded from a specified file 
Private Shared Function CreateRichTextBox(ByVal fileName As String, ByVal format As String) As RichTextBox
    If System.IO.File.Exists(fileName) Then
        Dim rtb As New RichTextBox()
        Dim range As New TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd)

        Using stream As New System.IO.FileStream(fileName, System.IO.FileMode.Open)
            ' we're assuming that the serialization id you stored was the name of 
            ' an rtf file 
            range.Load(stream, DataFormats.Rtf)
        End Using

        Return rtb
    End If

    Return Nothing
End Function
using Infragistics.Windows.DockManager;
using Infragistics.Windows.DockManager.Events;

private void InitializeDmWithSaveInLayout(XamDockManager dockManager)
{
	// hook the InitializePaneContent to dynamically provide the 
	// content for panes that are loaded at runtime. for example, 
	// if your application creates documents for files that the
	// user opens you could let those panes be saved, store information
	// in the SerializationId of the pane to know what to load and then
	// load that information into the pane in the InitializePaneContent 
	// when you load a layout
	dockManager.InitializePaneContent += new EventHandler<InitializePaneContentEventArgs>(dockManager_InitializePaneContent);
}

private void mnuOpen_Click(object sender, RoutedEventArgs e)
{
	string file = this.OpenFile();
	RichTextBox rtb = CreateRichTextBox(file, DataFormats.Rtf);

	if (null != rtb)
	{
		string fileName = System.IO.Path.GetFileName(file);
		ContentPane cp = this.dmSaveInLayout.AddDocument(fileName, rtb);

		// in order for the pane to be saved we must give it a unique name
		// since we won't be using the name we can just use a guid. we have
		// to use the format string that does not include "-" since that
		// is not valid for an element name. prefix with a letter since
		// the name cannot start with a number
		cp.Name = "A" + Guid.NewGuid().ToString("N");

		// store the path to the file. the SerializationId will be saved
		// in the layout with the pane so we can use this information from
		// within the InitializePaneContent to know what file to load
		// when a layout containing this pane is loaded
		cp.SerializationId = file;
	}
}

private void dockManager_InitializePaneContent(object sender, InitializePaneContentEventArgs e)
{
	string id = e.NewPane.SerializationId;

	RichTextBox rtb = CreateRichTextBox(id, DataFormats.Rtf);

	// if you set the Content of the NewPane to a non-null value then that
	// pane will be kept in the newly loaded layout. if you do not set the
	// content to a non-null value then the pane will be discarded
	e.NewPane.Content = rtb;
}

// simple helper method for prompting for an rtf file
private string OpenFile()
{
	// you could show a file open dialog, etc.
	Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
	dlg.DefaultExt = ".rtf";
	dlg.Filter = "RichText Files (*.rtf)|*.rtf";

	if (dlg.ShowDialog(this) == true)
		return dlg.FileName;

	return null;
}

// simple helper method for creating a richtextbox with
// contents loaded from a specified file
private static RichTextBox CreateRichTextBox(string fileName, string format)
{
	if (System.IO.File.Exists(fileName))
	{
		RichTextBox rtb = new RichTextBox();
		TextRange range = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);

		using (System.IO.FileStream stream = new System.IO.FileStream(fileName, System.IO.FileMode.Open))
		{
			// we're assuming that the serialization id you stored was the name of
			// an rtf file
			range.Load(stream, DataFormats.Rtf);
		}

		return rtb;
	}

	return null;
}
参照