wpf 单选按钮 mode
WPF单选按钮有两种模式:
- 单一选择模式:只有一个单选按钮可以选中,当选中一个单选按钮时,其他的单选按钮会自动取消选中状态。
可以通过设置单选按钮的GroupName属性来实现单一选择模式,GroupName属性的值为字符串类型,相同GroupName的单选按钮会被视为一组。
例如:
<StackPanel>
<RadioButton GroupName="Group1">选项一</RadioButton>
<RadioButton GroupName="Group1">选项二</RadioButton>
<RadioButton GroupName="Group1">选项三</RadioButton>
</StackPanel>
- 多选模式:多个单选按钮可以同时选中。
可以通过设置单选按钮的IsChecked属性来实现多选模式,IsChecked属性的值为bool类型。
例如:
<StackPanel>
<RadioButton IsChecked="True">选项一</RadioButton>
<RadioButton IsChecked="False">选项二</RadioButton>
<RadioButton IsChecked="True">选项三</RadioButton>
</StackPanel>
原文地址: https://www.cveoy.top/t/topic/bpgd 著作权归作者所有。请勿转载和采集!