To write a WPF custom control, add a checkbox in it, and then register a dependency to expose it to the outside world so as to obtain the ischecked status. Now an error is reported:
Error xdg0062 default value type does not match the type of 'ischecked' property
public Nullable<Boolean> CheckBoxIsChecked
{
get { return (Nullable<Boolean>)GetValue(CheckBoxIsCheckedProperty); }
set { SetValue(CheckBoxIsCheckedProperty, value); }
}
// Using a DependencyProperty as the backing store for ChcckBoxIsChecked. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CheckBoxIsCheckedProperty =
DependencyProperty.Register("IsChecked", typeof(Nullable<Boolean>), typeof(FileControl), new PropertyMetadata("CheckBox",new PropertyChangedCallback(onCheckBoxChanged)));
static void onCheckBoxChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
((FileControl)sender).OnCheckBoxValueChanged(args);
}
private void OnCheckBoxValueChanged(DependencyPropertyChangedEventArgs e)
{
bool temp = bool.Parse(e.NewValue.ToString());
this.checkBox.IsChecked = (Nullable < Boolean >) temp;
}