The CheckedChanged
event of a CheckBox
is fired when the page is loading up (on data binding), in addition to the user actually checking/unchecking.
Is there a way to detect whether CheckedChanged
event was fired by a user action or otherwise?
In WinForms/WPF, I used to define a boolean variable like Loading = true; and then used to set Loading = false; once page load is finished. Then, the CheckedChanged
event would check if Loading is false to execute the logic. Here's how I used to do it:
private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if (Loading == true) return;
//execute logic...
}
With async functions all over, I am unable to fit the Loading trick correctly. Is there a better way?
Aucun commentaire:
Enregistrer un commentaire