wpf-devexpress-dot-xpf-dot-core-dot-serialization-dot-dxserializer-ff459072.md
Allows you to save a layout of a control that does not exist in the application’s visual tree.
Namespace : DevExpress.Xpf.Core.Serialization
Assembly : DevExpress.Xpf.Core.v25.2.dll
NuGet Package : DevExpress.Wpf.Core
See AddCustomGetSerializableChildrenHandler(DependencyObject, CustomGetSerializableChildrenEventHandler) and RemoveCustomGetSerializableChildrenHandler(DependencyObject, CustomGetSerializableChildrenEventHandler).
Do the following to save controls that do not exist in the visual tree:
CustomGetSerializableChildren event.If a LayoutPanel contains a UserControl with a GridControl and this panel was not activated, the GridControl does not exist in the visual tree and its properties are not saved (serialized). To save the GridControl properties, add this control to the CustomGetSerializableChildrenEventArgs.Children collection.
using DevExpress.Utils.Serializing;
using DevExpress.Xpf.Core.Serialization;
using DevExpress.Xpf.Grid;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Docking;
// ...
public partial class MainWindow : Window {
public MainWindow() {
//...
layoutPanel.AddHandler(DXSerializer.CustomGetSerializableChildrenEvent, new CustomGetSerializableChildrenEventHandler(CustomGetSerializableChildrenEventHandler));
}
///...
void OnCreateContentPropertyValue(object sender, XtraCreateContentPropertyValueEventArgs e) {
e.Children.Add(grid);
}
}
Imports DevExpress.Utils.Serializing
Imports DevExpress.Xpf.Core.Serialization
Imports DevExpress.Xpf.Grid
Imports DevExpress.Xpf.Core
Imports DevExpress.Xpf.Docking
'...
Public Partial Class MainWindow
Inherits Window
Public Sub New()
'...
layoutPanel.[AddHandler](DXSerializer.CustomGetSerializableChildrenEvent, New CustomGetSerializableChildrenEventHandler(CustomGetSerializableChildrenEventHandler))
End Sub
'...
Sub OnCreateContentPropertyValue(ByVal sender As Object, ByVal e As XtraCreateContentPropertyValueEventArgs)
e.Children.Add(grid)
End Sub
End Class
See Also