I am trying to create a ControlTemplate which will merge 2 IQueryables (and some other things) into a CompositeCollection.
I am having issues getting the CollectionViewSource.Source to bind correctly to the template. It looks like TemplateBinding in the Resources section is not supported. What is the best way to get around this limitation?
Code sample is below:
-- C#
IQueryable Items1; // (DependencyProperty)
IQueryable Items2; // (DependencyProperty)
-- XAML
<ControlTemplate TargetType="{x:Type Components:Selector}">
<ControlTemplate.Resources>
<!-- The two bound properties below fail to bind -->
<CollectionViewSource Source="{Binding Items1,RelativeSource={RelativeSource TemplatedParent}}" x:Key="Items1Key" />
<CollectionViewSource Source="{Binding Items2, RelativeSource={RelativeSource TemplatedParent}}" x:Key="Items2Key" />
<CompositeCollection x:Key="collection">
<CollectionContainer Collection="{Binding Source={StaticResource Items1Key}}" />
<CollectionContainer Collection="{Binding Source={StaticResource Items2Key}}" />
</CompositeCollection>
</ControlTemplate.Resources>
<ComboBox ItemsSource="{Binding Source={StaticResource collection}}" />
</ControlTemplate>