I'm getting an annoying binding error that's basically my last roadblock with this control:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=SearchResults; DataItem=null; target element is 'CollectionViewSource' (HashCode=6017800); target property is 'Source' (type 'Object')
Here's the TabControl's markup:
<TabControl ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}">
<TabControl.ItemTemplate>
<!-- tab header template works as intended -->
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate DataType="controls:SearchResultsViewModel">
<DataTemplate.Resources>
<CollectionViewSource x:Key="GroupedSearchResults"
Source="{Binding SearchResults}">
<CollectionViewSource.SortDescriptions>
<!-- sort descriptions -->
</CollectionViewSource.SortDescriptions>
<CollectionViewSource.GroupDescriptions>
<!-- group descriptions -->
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</DataTemplate.Resources>
<controls:GroupingGrid ShowGroupingItemCount="True"
ItemsSource="{Binding Source={StaticResource GroupedSearchResults}}"
SelectedItem="{Binding SelectedItem}">
<DataGrid.Columns>
<!-- column definitions -->
</DataGrid.Columns>
</controls:GroupingGrid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
The designer gives me no squiggly lines anywhere, which seems to indicate everything is ok; I only get the binding error at run-time, however the ViewModels (serach results) populate exactly as expected... they just don't bind into the CollectionViewSource for some reason.
What am I doing wrong?
