Does anyone know how I can sort a Datagrid when the Itemsource of the grid changes? i.e. if I have a DataGrid of products, and another grid of product versions, when I select a product, the ItemSource of the product version DataGrid will change so I would like to do a sort before the data appears inside the Product Versions DataGrid.
The way I do the sorting at the moment is.
<CollectionViewSource x:Key="cvsProductVersions"
Source="{Product.ProductVersions, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Filter="CollectionViewSource_Filter">
<!--<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Build1" Direction="Descending"/>
</CollectionViewSource.SortDescriptions>-->
</CollectionViewSource>
I think I need to use
CollectionViewSource.GetDefaultView(dgProductVersion.ItemsSource).Refresh();
However, I need an event which basically means "Run this code once a new itemsource is applied to the table.
Cheers
ItemSource
of version DataGrid? Can you show XAML of this DataGrid? – shfire