Back to Devexpress

DXSerializer.AllowProperty Attached Event

wpf-devexpress-dot-xpf-dot-core-dot-serialization-dot-dxserializer-d9d434fa.md

latest3.0 KB
Original Source

DXSerializer.AllowProperty Attached Event

Allows you to prevent a property from deserialization.

Namespace : DevExpress.Xpf.Core.Serialization

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

NuGet Package : DevExpress.Wpf.Core

Declaration

See AddAllowPropertyHandler(DependencyObject, AllowPropertyEventHandler) and RemoveAllowPropertyHandler(DependencyObject, AllowPropertyEventHandler).

Remarks

Do the following to prevent a property from being deserialized:

  1. Handle the AllowProperty event.
  2. Set AllowPropertyEventArgs.Allow property to false.

The following code sample disables the GridControl ID column’s WidthProperty predefined property deserialization:

csharp
using DevExpress.Xpf.Core.Serialization;
using DevExpress.Xpf.Grid;
// ...

public partial class MainWindow : Window {
    public MainWindow() {
        //...
        grid.Columns[nameof(Customer.ID)].AddHandler(DXSerializer.AllowPropertyEvent, 
              new AllowPropertyEventHandler(OnAllowProperty));
    }

    void OnAllowProperty(object sender, AllowPropertyEventArgs e) {
        if (e.DependencyProperty == GridColumn.WidthProperty)
            e.Allow = false;
    }
}
vb
Imports DevExpress.Xpf.Core.Serialization
Imports DevExpress.Xpf.Grid
'...

Public Partial Class MainWindow
    Inherits Window

    Public Sub New()
        ' ...
        grid.Columns(NameOf(Customer.ID)).[AddHandler](DXSerializer.AllowPropertyEvent, 
            New AllowPropertyEventHandler(AddressOf OnAllowProperty))
    End Sub

    Private Sub OnAllowProperty(ByVal sender As Object, ByVal e As AllowPropertyEventArgs)
        If e.DependencyProperty = GridColumn.WidthProperty Then e.Allow = False
    End Sub
End Class

View Example: Exclude GridControl's Properties from Serialization

See Also

DXSerializer Events - Advanced Scenarios

DXSerializer Class

DXSerializer Members

DevExpress.Xpf.Core.Serialization Namespace