jeudi 13 septembre 2018

How to block a checkbox to be checked in on a Checked event when some condition is not met?

I'm using System.Windows.Controls.CheckBox. I am implement the OnChecked event handler, I want the checkbox to be unchecked if some condition is not met after the handler runs, how should I implement the handler?

xaml code:

<CheckBox  Checked="OnChecked" >Checkbox text</CheckBox>

C# code:

private void OnChecked(object sender, RoutedEventArgs e)
{
   // Block checkbox being checked if some condition not met
}




Aucun commentaire:

Enregistrer un commentaire