Skip to main content
All docs
V23.2

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

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

Namespace: DevExpress.Xpf.Core.Serialization

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

NuGet Package: DevExpress.Wpf.Core

Declaration

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

Parameters

Name Type Description
root DependencyObject

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

path Object

The target file path.

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 an XML file.

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;

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

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Serialize(DependencyObject, Object, String, DXOptionsLayout) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also