DXSerializer.CustomGetSerializableChildren Attached Event
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.v24.1.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
See AddCustomGetSerializableChildrenHandler(DependencyObject, CustomGetSerializableChildrenEventHandler) and RemoveCustomGetSerializableChildrenHandler(DependencyObject, CustomGetSerializableChildrenEventHandler).
Remarks
Do the following to save controls that do not exist in the visual tree:
- Handle the
CustomGetSerializableChildren
event. - Add a control that contains the layout you want to save to the CustomGetSerializableChildrenEventArgs.Children collection.
Use Case
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);
}
}
See Also