选择框控件,为用户提供选项。

可单选或多选。

CheckBox有选中、为选中、中间态三种状态,要是中间态有效,需要设置IsThreeState="true".

<CheckBoxIsThreeState="True"Checked="checkBox1_Checked"Unchecked="checkBox1_Unchecked"Content=""Height="72"HorizontalAlignment="Left"Margin="161,172,0,0"Name="checkBox1"VerticalAlignment="Top"><CheckBox.RenderTransform><CompositeTransformScaleX="1.5"ScaleY="1.5"></CompositeTransform></CheckBox.RenderTransform></CheckBox>

C#代码:

privatevoidcheckBox1_Checked(objectsender,RoutedEventArgse){if(checkBox1.IsChecked==true)this.textBlock1.Text="选中";}privatevoidcheckBox1_Unchecked(objectsender,RoutedEventArgse){if(checkBox1.IsChecked==false)this.textBlock1.Text="未选中";}

效果图为: