I would like to report a bug in the QuantityUpDown control.
When the QUD Value property is the source for binding, the target property does update but the behavior is not as expected.
myTargetTextBlock.SetBinding(TextBlock.TextProperty, new Binding { Source = [B]MyQud[/B], Path = new PropertyPath("Value"), Converter = new IntToStrConverter() as IValueConverter, } );
- The target updates on mouse scrolling in the QUD.
- The target updates on clicking of the up & down buttons of the QUD.
- The target updates when the QUD value is changed programatically.
- The target DOES NOT update if the user sets focus inside the QUD and types in a quantity value in the QUD. (onkeypressed handler?)
- The target DOES NOT update if the user pastes a quantity value in the QUD. (ontextchanged handler?)
I have not spent time to figure out how the QUD value property is exposed from the inner textbox, but the implementation is not consistent as there are obviously UI ways to change the value and the QUD control is not aware of the new value.
Of course there are workarounds — digging inside the control to find its nested textbox and binding to it works as expected:
myTargetTextBlock.SetBinding(TextBlock.TextProperty, new Binding { Source = [B]myQudInnerTextBox[/B], Path = new PropertyPath("Text"), [COLOR="Green"] //no converter needed as both are type string.[/COLOR] } );
MyQud.ValueChanged+=OnMyQudValueChanged;
Thanks for looking into this. It is a true bug. I hope it gets fixed. The fix would not break legacy code of addons but will just make the legacy workarounds obsolete/deprecated.
Comment