Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.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