There's a lot of discussion about Filtering, Grouping and Sorting on CollectionViewSource in WPF, and what is an isn't "MVVM"-practical (especially when adding Filters in code-behind).
I want to have ViewModel control over these properties (like adding sort and filter descriptors), but in order to use SynchronizationContext with an Asynchronous ObservableCollection, I need the CollectionViewSource instantiated in the View (on the dispatcher thread), NOT instantiated in the model - but the model needs access to the CollectionViewSource in order to add filter, group and sort descriptors from code, rather than defining them in XAML.
For this purpose, I'd like to find a way to Bind the XAML-declared CollectionViewSource object BACK to the ViewModel. Something like this:
<UserControl.Resources>
<CollectionViewSource
IsLiveFilteringRequested="True"
x:Name="collectionViewSource"
x:Key="collectionViewSource"
Source="{Binding DataContext.myCollection, IsAsync=True}"
Binding="{Binding DataContext.myCollectionViewSourceProperty, Mode=OneTime}" />
</UserControl.Resources>
Of course, the CollectionViewSource doesn't have a "Binding" property, and the source must point to an ObservableCollection.
Is there a way to accomplish this?