【发布时间】:2014-03-15 10:53:06
【问题描述】:
我有这样的东西... 第一个用户控件如下
<UserControl x:Class="FirstControl">
<UserControl.Resources>
<ResourceDictionary x:Key="PrintTemplates>
<ControlTemplate x:Key="PrintTemplateA">
.....
</ControlTemplate>
<ControlTemplate x:Key="PrintTemplateB">
.....
</ControlTemplate>
<ResourceDictionary/>
</UserControl.Resources>
<Grid>
<ComboBox x:Name="PrintTemplateComboBox"
ItemsSource="{StaticResource PrintTemplates}" />
</Grid>
</UserControl>
第二个用户控件如下...请查看代码中大写 cmets 的位置。我想将 PrintBox 的控件模板设置为用户在 FirstControl 的组合框中选择的任何内容
<UserControl x:Class="SecondControl">
<Grid>
<local:PrintBox x:Name="PrintBox"
Template={Binding SelectedValue, Source= I WANT THIS TO BE PrintTemplateComboBox IN THE FirstControl />
</Grid>
</UserControl>
感谢您的帮助!!!
【问题讨论】:
-
你试过 ElemenetName="PrintTemplateComboBox" Path=SelectedValue 吗?
-
谢谢,但在我的情况下这不起作用,因为这些控件不在同一个窗口/控件上