基本控件CheckBox控件
选择框控件,为用户提供选项。
可单选或多选。
CheckBox有选中、为选中、中间态三种状态,要是中间态有效,需要设置IsThreeState="true".
- <CheckBox IsThreeState="True" Checked="checkBox1_Checked" Unchecked="checkBox1_Unchecked" Content="" Height="72" HorizontalAlignment="Left" Margin="161,172,0,0" Name="checkBox1" VerticalAlignment="Top" >
- <CheckBox.RenderTransform>
- <CompositeTransform ScaleX="1.5" ScaleY="1.5"></CompositeTransform>
- </CheckBox.RenderTransform>
- </CheckBox>
C#代码:
- private void checkBox1_Checked(object sender, RoutedEventArgs e)
- {
- if (checkBox1.IsChecked == true)
- this.textBlock1.Text = "选中";
- }
- private void checkBox1_Unchecked(object sender, RoutedEventArgs e)
- {
- if (checkBox1.IsChecked == false)
- this.textBlock1.Text = "未选中";
- }
效果图为: