Cancel event on (Toggle)Button
My customer wants me to show the user a message when he has no access to specific functionality.
I tried to convince him to just disable the control when access is denied, but that was no option.
So, for instance, I have a toggleButton (preferably, it should work for any UIElement).
I check for the rights of the user, in the Click eventHandler.
private void ToggleButton_Click(object sender, RoutedEventArgs ea)
{
if (User has rights)
// do normal stuff
else
{
ea.Handled = true;
// show "No rights" message
}
}
When access is denied, I somehow want to cancel the rest of the processing. I want to avoid that the IsChecked property still changes after the click.
I've tried something with setting the Handled property on true, but that didn't do the job. Is there any way to stop the standard event handling?
It somehow feels like bad practice, but I don't have a (better) solution.
Regards, Jowen

