I have a page where a few textboxes cannot be empty before clicking a Save button.
On the codebehind for the view you could wireup the Validation.ErrorEvent like so;
this.AddHandler(Validation.ErrorEvent,new RoutedEventHandler(OnErrorEvent));
And then
private int errorCount;
private void OnErrorEvent(object sender, RoutedEventArgs e)
{
var validationEventArgs = e as ValidationErrorEventArgs;
if (validationEventArgs == null)
throw new Exception("Unexpected event args");
switch(validationEventArgs.Action)
{
case ValidationErrorEventAction.Added:
{
errorCount++; break;
}
case ValidationErrorEventAction.Removed:
{
errorCount--; break;
}
default:
{
throw new Exception("Unknown action");
}
}
Save.IsEnabled = errorCount == 0;
}
This makes the assumption that you will get notified of the removal (which won't happen if you remove the offending element while it is invalid).