The TextBox is working exactly as it should
The Binding class is at fault for 2 reasons
(1) It wasn't designed correctly
(2) It's design is too sealed / black-boxy to allow us to fix it
My working solution is horrendous - I derive from Binding and then use two semi-clones of Binding
one with a dummy Source and one with a dummy Target
This allows me to get the current SourceValue and TargetValue
Whilst also triggering the default IConvert and Validation behavior
(But avoiding the unwanted UpdateSource())
Then I can perform a typed equality check
This means my WPF forms pass quality control, but the hack doesn't!
I can replace the default Binding like so:
ConventionManager.SetBinding = delegate (Type viewModelType, string path, PropertyInfo property, FrameworkElement element, ElementConvention convention, DependencyProperty bindableProperty) {
Binding binding = new TestBinding(path);
ConventionManager.ApplyBindingMode(binding, property);
ConventionManager.ApplyValueConverter(binding, bindableProperty, property);
ConventionManager.ApplyStringFormat(binding, convention, property);
ConventionManager.ApplyValidation(binding, viewModelType, property);
ConventionManager.ApplyUpdateSourceTrigger(bindableProperty, element, binding, property);
BindingOperations.SetBinding(element, bindableProperty, binding);
};
|