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.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.2.dll

NuGet Package: DevExpress.Wpf.Core

#Declaration

#Remarks

Do the following to save controls that do not exist in the visual tree:

  1. Handle the CustomGetSerializableChildren event.
  2. 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