I have MainWindow.xaml (View) and MainWindowViewModel.cs (ViewModel).
In my program i have custom class for async loading data at startup in Worklist.Result (observablecollection). At this moment i need use custom filtering data. If i create CollectionViewSource in xaml all display perfectly but i can't bind Filter event to CollectionViewSource. Ok, then i need code-behind CollectionView... But finally DataGrid doesn't display data (no bindings error, CollectionViewSource have all records). Why?
Example 1: (XAML-created CollectionViewSource w/o filtering) All is OK!
MainWindow.xaml
...
<xdg:DataGridCollectionViewSource x:Key="DataItems"
Source="{Binding WorkList.Result}"
<xdg:DataGridCollectionViewSource.GroupDescriptions>
<xdg:DataGridGroupDescription PropertyName="Date"/>
</xdg:DataGridCollectionViewSource.GroupDescriptions>
</xdg:DataGridCollectionViewSource>-->
...
<xdg:DataGridControl VerticalAlignment="Stretch" Background="White" ItemsSource="{Binding Source={StaticResource DataItems}}" ... </xdg:DataGridControl>
Example 2: (CodeBehind-created CollectionViewSource w/o filtering) NO RECORDS in DataGrid!):
MainWindow.xaml
<xdg:DataGridControl VerticalAlignment="Stretch" Background="White" ItemsSource="{Binding DataItems}" ... </xdg:DataGridControl>
MainWindowViewModel.cs
...
public ICollectionView DataItems { get; private set; }
...
private void WorkList_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
DataItems = CollectionViewSource.GetDefaultView(WorkList.Result);
}
Then WorkList_PropertyChanged event was raised all data in CollectionViewSource but not in DataGrid. Can someone help with this problem?