DXSerializer.SerializeSingleObject(DependencyObject, Object, String) Method
Saves (serializes) the specified container (or control) layout to an XML file/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.v25.1.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
public static void SerializeSingleObject(
DependencyObject d,
object path,
string appName = ""
)
Parameters
| Name | Type | Description |
|---|---|---|
| d | DependencyObject | A container (or a control) whose layouts should be saved. |
| path | Object | The target XML file path/Stream. |
Optional Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| appName | String | String.Empty | The application name. |
Remarks
Call this method to save (serialize) the layout of a container (Window, View, UserControl) 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 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.