Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 在ControlTemplate中绑定CollectionViewSource_Wpf_Xaml - Fatal编程技术网

Wpf 在ControlTemplate中绑定CollectionViewSource

Wpf 在ControlTemplate中绑定CollectionViewSource,wpf,xaml,Wpf,Xaml,我正在尝试创建一个ControlTemplate,它将2个iQueryTables(和其他一些东西)合并到一个CompositeCollection中 获取CollectionViewSource.Source以正确绑定到模板时遇到问题。似乎不支持参考资料部分中的TemplateBinding。绕过这一限制的最佳方式是什么 代码示例如下: --C# --XAML 对于任何感兴趣的人来说,WPF的未来版本将尝试用一种称为“继承上下文”的东西来解决这个问题。 IQueryable Items1; /

我正在尝试创建一个ControlTemplate,它将2个iQueryTables(和其他一些东西)合并到一个CompositeCollection中

获取CollectionViewSource.Source以正确绑定到模板时遇到问题。似乎不支持参考资料部分中的TemplateBinding。绕过这一限制的最佳方式是什么

代码示例如下:

--C#

--XAML


对于任何感兴趣的人来说,WPF的未来版本将尝试用一种称为“继承上下文”的东西来解决这个问题。
IQueryable Items1; // (DependencyProperty)
IQueryable Items2; // (DependencyProperty)
  <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>