I have a DataGrid control that has a TextColumn
<DataGrid ItemsSource="{Binding Path=Dvm.Data}"
Name="GrdName"
AutoGenerateColumns="False"
Margin="5"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Header="Column 1"
Binding="{Binding Path=Col1, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
I have a custom control that requires me to test what the UpdateSourceTrigger setting is, but I am having trouble accessing that from code. I would like to do something like this:
BindingOperations.GetBindingExpression(GrdName.Columns[0], DataGridTextColumn.BindingProperty);
But, BindingProperty is not actually a dependency property, so I can’t do that. Does anyone know how I would go about getting the binding expression for the Binding property for that column so I can get the UpdateSourceTrigger setting?
Thanks,
Matt
The
Bindingproperty is not aDependancyPropertyso you will have to access using normal public properties.So you will have to do a bit of casting as the
Bindingproperty inDataGridTextColumnis typeBindingBaseyou will have to cast asBindingto accessUpdateSourceTrigger.And since
DataGridTextColumnis derived fromDataGridBoundColumnyou can cast from that to make it a bit more genericSomething like this should work: