DXSerializer.Serialize(DependencyObject[], Object, String, DXOptionsLayout) Method
Saves (serializes) layouts of the specified container (or control) collection and all its child elements 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.v24.2.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
public static void Serialize(
DependencyObject[] dObjects,
object path,
string appName = "",
DXOptionsLayout options = null
)
Parameters
Name | Type | Description |
---|---|---|
dObjects | DependencyObject[] | A collection of containers (or controls) whose layouts should be saved. |
path | Object | The XML File path/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) the layout of a container (Window, View, UserControl) collection and its child controls to an XML file/Stream.
If your target objects (specified with the dObjects
method parameter) contain 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 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(new DependencyObject[] { gridControl1, gridControl2 }, "Layout.xml");
}
To deserialize these layouts, use the Deserialize(DependencyObject[], Object, String, DXOptionsLayout) method.