1 回答
TA贡献1877条经验 获得超6个赞
您可以使用cmb1 的选择DataTrigger权来设置ItemsSource,如果Cmb1SelectedItem更改其更改 Cmb2 Itemsource 无需在 VM 中维护
<ComboBox Name="Cmb1" ItemsSource="{Binding Cmb1List}" SelectedItem="{Binding Cmb1SelectedItem}">
</ComboBox>
<ComboBox Name="Cmb2" >
<ComboBox.Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemsSource" Value="{Binding ObservableCollectionC}"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Cmb1SelectedItem}" Value="A">
<Setter Property="ItemsSource" Value="{Binding ObservableCollectionA}"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Cmb1SelectedItem}" Value="B">
<Setter Property="ItemsSource" Value="{Binding ObservableCollectionB}"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报