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.
| XAML | Copy Code |
|---|---|
<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> | |
The DependencyPropertyDescriptor for the ItemsSource property is defined in the OnInitialized override and will call the OnDataGridItemsSourceChanged method when the ItemsSource property has been changed. The ChangeDataSource method will be called by the button to change the ItemsSource property.
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
