Say I've got a button on a form that I want to disable if some condition is met. Is there a way to check for this condition inside the button's "IsEnabled" event handler and modify the enabled state such that setting the enabled state a second time does not trigger another call to the IsEnabled event handler?
Let me demonstrate:
private void ExportResults_IsEnabledChanged (object sender, DependencyPropertyChangedEventArgs e)
{
if (some condition)
{
uxExportResults.IsEnabled = false; // this will cause another call to the event handler, eventually resulting in a stack overflow
}
}
Assume I'm triggering the event elsewhere (which I am).