Skip to main content

Creating a Value-changed Handler

The following example demonstrates how to create a DependencyPropertyDescriptor for the ItemsSource property that will provide a value-changed handler so that we can be notified when the value of the ItemsSource property is changed.

The value of the ItemsSource property is changed to the Employees table when the button located above the grid is clicked.

  <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
<Grid.Resources>
<xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
Source="{Binding Source={x:Static Application.Current},
Path=Orders}"/>
</Grid.Resources>
<DockPanel>
<Button Content="Change data source"
DockPanel.Dock="Top"
Click="ChangeDataSource"/>
<xcdg:DataGridControl x:Name="OrdersGrid"
ItemsSource="{Binding Source={StaticResource cvs_orders}}"
DockPanel.Dock="Bottom"/>
</DockPanel>
</Grid>