I have the same question as in the link below, but the answers where not satisfying for me.
ValidationRule ValidatesOnTargetUpdated NullReferenceException at Design Time
XAML
<TextBox x:Name="MyTextBox">
<TextBox.Text>
<Binding Path="MyText">
</Binding>
</TextBox.Text>
</TextBox>
Code-Behind
Binding binding = BindingOperations.GetBinding(MyTextBox, TextBox.TextProperty);
binding?.ValidationRules.Add(new MyValidationRule()
{
ValidatesOnTargetUpdated = true
});
It works with this section in code behind. But I am looking for a only XAML solution, because it is more intuitive and for me better maintainable. Does anybody have an idea?