WPF 使用Converter实现控件的动态显隐

效果如图:

根据下拉框fieldTypeComboBox,控制其他控件的显隐

关键代码

<ComboBox Grid.Column="1" Grid.Row="2" DataContext="{Binding FieldTypeEnumInfos}" ItemsSource="{Binding }" Name="fieldTypeComboBox" DisplayMemberPath="Description" SelectedValuePath="Value"></ComboBox>
<CheckBox Grid.Column="1" Grid.Row="3" IsChecked="{Binding IsUniqueKey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding SelectedItem,ElementName=fieldTypeComboBox,Converter={StaticResource EditFieldVisibilityConverter},ConverterParameter=IsUniqueKey}"></CheckBox>

示例代码

Converters

posted @ 2020-06-27 14:26  Lulus  阅读(927)  评论(0编辑  收藏  举报