【发布时间】:2011-06-08 14:33:16
【问题描述】:
如何在ComboBox上设置触发器,当SelectedIndex大于0时(基本上,选择时选项)另一个ComboBox获取修改。我有两个ComboBoxes,但用户只能从其中一个中选择。因此,如果我从 ComboBox A 中选择第一个选项,那么 ComboBox B 应该得到 SelectedIndex 的 0 ,反之亦然。
我尝试过以下操作,但不确定如何捕获所需的逻辑。
<ComboBox ItemsSource="{Binding AvailableStatuses}"
SelectedItem="{Binding SelectedStatus}"
Grid.Row="1" Grid.Column="1" DisplayMemberPath="Name"
x:Name="Statuses">
<ComboBox.Style>
<Style TargetType="{x:Type ComboBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Decisions}" Value="0">
<Setter Property="SelectedIndex" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
我应该查看什么样的触发器?
【问题讨论】:
标签: wpf xaml triggers selection mutual-exclusion