Skip to main content
All docs
V24.2

DXSerializer.Serialize(DependencyObject, Stream, String, DXOptionsLayout) Method

Saves (serializes) layouts of the specified container (or control) and all its child elements to a Stream. The method saves layouts of visual controls that exist in the application’s visual tree.

Namespace: DevExpress.Xpf.Core.Serialization

Assembly: DevExpress.Xpf.Core.v24.2.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public static void Serialize(
    DependencyObject root,
    Stream stream,
    string appName = "",
    DXOptionsLayout options = null
)

Parameters

Name Type Description
root DependencyObject

A container (or a control) whose layouts should be saved.

stream Stream

The stream for output data.

Optional Parameters

Name Type Default Description
appName String String.Empty

The application name.

options DXOptionsLayout null

Settings that specify whether the container’s child object layouts should be serialized.

Remarks

Call this method to save (serialize) layouts of a container (Window, View, UserControl) and its child controls to a Stream.

If your target object (specified with the root method parameter) contains multiple serializable child objects with the same type, specify unique SerializationID attached property values (within the container) for each of these objects.

Note

The RibbonControl and each instance of its category/page/group should also have unique SerializationID attached property values.

The following code saves the layout of the window and its child GridControls to an XML file:

<Window . . .
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    x:Name="mainWindow">
    <Grid>
        <dxg:GridControl dx:DXSerializer.SerializationID="gridControl1">
            <!--...-->
        </dxg:GridControl>
        <dxg:GridControl dx:DXSerializer.SerializationID="gridControl2">
            <!--...-->
        </dxg:GridControl>
    </Grid>
</Window>
using DevExpress.Xpf.Core.Serialization;

Stream mainWindowLayout = new MemoryStream();

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
    DXSerializer.Serialize(mainWindow, mainWindowLayout);
}

To deserialize these layouts, use the Deserialize(DependencyObject, Stream, String, DXOptionsLayout) method.

See Also