I need to add ValidationRule to the TextBox programmatically in WPF.
I’m trying something like:
Binding binding = BindingOperations.GetBinding(myTextBox, TextBox.TextProperty);
binding.ValidationRules.Clear();
binding.ValidationRules.Add(myValidationRule);
But BindingOperations.GetBinding return null. Why?
Many thanks.
From the API:
So apparantly there is no Bindig object set.
Source