Validation.HasError es una propiedad adjunta para que pueda comprobar que textboxMin como esto
void buttonOK_Click(object sender, RoutedEventArgs e)
{
if (Validation.GetHasError(textboxMin) == true)
return;
}
Para ejecutar todas las ValidationRules para el TextProperty en código detrás se puede obtener el BindingExpression y llame UpdateSource
BindingExpression be = textboxMin.GetBindingExpression(TextBox.TextProperty);
be.UpdateSource();
Actualización
Tomará algunos pasos para lograr el enlace para desactivar le el botón si ocurre alguna validación.
Primero, asegúrese de que todos los enlaces agreguen NotifyOnValidationError = "True". Ejemplo
<TextBox Name="textboxMin">
<TextBox.Text>
<Binding Path="Max" NotifyOnValidationError="True">
<Binding.ValidationRules>
<local:IntValidator/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Luego conectamos un manejador de eventos al evento Validation.Error en la ventana.
<Window ...
Validation.Error="Window_Error">
Y en código detrás que añadir y eliminar los errores de validación en un ObservableCollection como vienen y vamos
public ObservableCollection<ValidationError> ValidationErrors { get; private set; }
private void Window_Error(object sender, ValidationErrorEventArgs e)
{
if (e.Action == ValidationErrorEventAction.Added)
{
ValidationErrors.Add(e.Error);
}
else
{
ValidationErrors.Remove(e.Error);
}
}
Y entonces podemos obligar IsEnabled del botón para ValidationErrors.Count como esto
<Button ...>
<Button.Style>
<Style TargetType="Button">
<Setter Property="IsEnabled" Value="False"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ValidationErrors.Count}" Value="0">
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
¿Necesita saber si un ReglaDeValidación específica tiene un error o simplemente si el cuadro de texto tiene errores? –