Skip to main content
All docs
V23.2

DXSerializer.DeserializeSingleObject(DependencyObject, Object, String) Method

Restores (deserializes) the specified container (or control) layout from the XML file/Stream.

Namespace: DevExpress.Xpf.Core.Serialization

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

NuGet Package: DevExpress.Wpf.Core

Declaration

public static void DeserializeSingleObject(
    DependencyObject d,
    object path,
    string appName = ""
)

Parameters

Name Type Description
d DependencyObject

A container (or a control) whose layout should be restored.

path Object

The target XML File’s path/Stream.

Optional Parameters

Name Type Default Description
appName String String.Empty

The application name.

Remarks

Call this method to restore (deserialize) layouts of a container (Window, View, UserControl) from a Stream.

The following code restores only the layout of the mainwindow (but not the layout of its child elements) from the 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.SerializeSingleObject(mainWindow, "Layout.xml");
}
private void Window_Loaded(object sender, System.ComponentModel.CancelEventArgs e) {
    DXSerializer.DeserializeSingleObject(mainWindow, "Layout.xml");
}
See Also