private void OnValidationRaised(object sender, RoutedEventArgs e) { var args = (System.Windows.Controls.ValidationErrorEventArgs)e; if (_myViewModel != null) { // Check if the error was caused by an exception if (args.Error.RuleInError is ExceptionValidationRule) { // Add or remove the error from the ViewModel if (args.Action == ValidationErrorEventAction.Added) { _myViewModel.AddUIValidationError(); } else if (args.Action == ValidationErrorEventAction.Removed) { _myViewModel.RemoveUIValidationError(); } } } }