wpf-checkbox

响应点击事件

private void chk_isEnable_Click(object sender, RoutedEventArgs e)
{
// 获取当前选中行,更新
var result = (sender as CheckBox).IsChecked;
}

binding

DataContext = App.db.m_config[0];

<CheckBox x:Name="chk_autoStart" IsChecked="{Binding Path=AutoStart, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" Margin="4,0">程序自启动</CheckBox>

只读

// IsHitTestVisible="False" Focusable="False" 就可以了
<CheckBox IsChecked="{Binding Path=IsValid}" IsHitTestVisible="False" Focusable="False" />

代码判断属性

if ((bool)check_clear_coder.IsChecked)
{

}