I have a datagrid that correctly sorts when initially loaded. But it doesn't update when I add an item. How can I have the grid update and sort when a new item is added?
<!-- This works for the initial sort, but when members get added to the collection
the sort doesn't get updated. That's because CollectionViewSource doesn't
implement INotifyPropertyChanged. -->
<UserControl.Resources>
<CollectionViewSource x:Key="SortedApplications" Source="{Binding Applications}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Name" Direction="Ascending"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</UserControl.Resources>
One option is to sort the collection within the view model. But if I'm displaying all of the Bars within a Foo, I would then have to break Bars into its own property (in the view model) just so I could sort them.
If possible, I would like to do this without using the view's code-behind because I'm trying not to put code there.