Back to Devexpress

DXSerializer.CustomGetSerializableProperties Attached Event

wpf-devexpress-dot-xpf-dot-core-dot-serialization-dot-dxserializer-05e443b3.md

latest4.1 KB
Original Source

DXSerializer.CustomGetSerializableProperties Attached Event

Allows you to serialize standard/custom controls or custom properties.

Namespace : DevExpress.Xpf.Core.Serialization

Assembly : DevExpress.Xpf.Core.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

See AddCustomGetSerializablePropertiesHandler(DependencyObject, CustomGetSerializablePropertiesEventHandler) and RemoveCustomGetSerializablePropertiesHandler(DependencyObject, CustomGetSerializablePropertiesEventHandler).

Remarks

Serialize Standard and Custom Controls

Do the following to save/restore properties of custom and standard controls:

  1. Specify the SerializationID property for a control that contains the layout you want to save/restore.
  2. Assign the XtraSerializableProperty attribute to the control’s properties whose values you want to save/restore.
  3. Choose one of the following:

Save Properties that are not Marked with the XtraSerializablePropertyAttribute

  1. Handle the CustomGetSerializableProperties event.
  2. Pass the property whose value you want to save/restore to the CustomGetSerializablePropertiesEventArgs.SetPropertySerializable method.

The following code sample saves (serializes) the GridColumn.Tag property:

csharp
Imports DevExpress.Utils.Serializing
Imports DevExpress.Xpf.Core.Serialization
Imports DevExpress.Xpf.Grid
Imports DevExpress.Xpf.Core
//...
public partial class MainWindow : Window {
    public MainWindow() {
        //...
        grid.AddHandler(DXSerializer.CustomGetSerializablePropertiesEvent, new CustomGetSerializablePropertiesEventHandler(CustomGetSerializablePropertiesHandler));
    }

    void CustomGetSerializablePropertiesHandler(object sender, CustomGetSerializablePropertiesEventArgs e) {
        e.SetPropertySerializable(GridColumn.TagProperty, new DXSerializable() { });
    }
}
vb
Imports DevExpress.Utils.Serializing
Imports DevExpress.Xpf.Core.Serialization
Imports DevExpress.Xpf.Grid
Imports DevExpress.Xpf.Core
'...

Public Partial Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()
        Me.DataContext = Me
        grid.Columns("Name").[AddHandler](DXSerializer.CustomGetSerializablePropertiesEvent, New CustomGetSerializablePropertiesEventHandler(CustomGetSerializablePropertiesHandler))
    End Sub

    Sub CustomGetSerializablePropertiesHandler(ByVal sender As Object, ByVal e As CustomGetSerializablePropertiesEventArgs)
        e.SetPropertySerializable
        TODO
    End Sub
End Class

See Also

DXSerializer Events - Advanced Scenarios

DXSerializer Class

DXSerializer Members

DevExpress.Xpf.Core.Serialization Namespace