I got following CollectionViewSource definition in XAML:
<UserControl.Resources>
<CollectionViewSource x:Key="PersonsViewSource" Source="{Binding AvailablePersons}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Surname" Direction="Ascending" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</UserControl.Resources>
I got a combobox bound to this CVS and would like to access the View from code like this:
(Resources["PersonsViewSource"] as CollectionViewSource).View
However even if I try to access it in constructor after InitializeComponent()
or in Loaded event
handler View & Source are still null
.
When application is shown to me in browser though binding has already taken place and if I now put a breakpoint somewhere view & source are not null now.
So when exactly is Source set? Where can I access the view on the stage of loading my application?
Maybe this is a general binding question not really regarding viewsource, when is static resource binding set?