Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How not to serialize certain properties in GridControl

$
0
0

This example demonstrates how to exclude specific properties from serialization. To accomplish this task, handle the DXSerializer.AllowProperty event for an object whose property shouldn't be serialized. In this event handler, set AllowPropertyEventArgs.Allow to 'False' to prohibit property serialization. 
In this particular example, the GridColumn.ActualWidth property has been excluded. Please note that since GridColumn is not a UIElement descendant, it's necessary to use the GridColumn.AddHandler method instead of DXSerializer.AddAllowPropertyHandler to subscribe to the event.
If it's necessary to handle this event for all columns in GridControl, you can create a GridControl descendant and override the OnDeserializeAllowProperty method:


[C#]
publicclassGridControlEx:GridControl{protectedoverrideboolOnDeserializeAllowProperty(AllowPropertyEventArgse){if(e.DependencyProperty==GridColumn.ActualWidthProperty)returnfalse;returnbase.OnDeserializeAllowProperty(e);}}

Viewing all articles
Browse latest Browse all 7205

Trending Articles