BUG: AppBarButton click doesn't trigger focus loss on previously focused inputs
See original GitHub issue// EDIT: initially this was a proposal and it unfolded into a bug. To get the full context please read all comments
Proposal: NumberBox NumberChanged event
Summary
There is currently no way to get value updates from a NumberBox
just-in-time as the user types (like you can with a TextBox.TexChanged
event).
Rationale
Given the summary above, this forces developers to make workarounds to certain scenarios. Example scenario: We want to input a value and save the value to a file
- Given a form with a
NumberBox
having aValue={x:Bind MyProp, Mode=2way}
andValueChanged="OnValChanged"
- Given a
Button
withClick="OnClick"
which passesMyProp
to a method - When I input a number in the
NumberBox
, and directly after that I click theButton
- The
OnClick
triggers before theNumberBox
change is picked up, thus passing an outdated value around.
In the case of a TextBox
this annoying behavior can be worked around by having a TextChanged
event handler which always updates MyProp
just-in-time to be ready for being passed to the method invoked by OnClick
In the case of a NumberBox
, there’s no way to work around this, other than redesigning the UI to have a modal which collects the NumberBox
value, and then passes it to the called to be used.
Scope
Capability | Priority |
---|---|
Just-in-time NumberBox value changes | Must |
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (9 by maintainers)
Top GitHub Comments
I wonder if @ranjeshj saw you tagging him above @chingucoding 😄
I think it is, but I am not really sure when bindings get evaluated. It may be a bug, but I think it’s more based on the way bindings work in XAML. But again I am not sure on that.
Hmm, it seems that setting the focus inside the event handler only raises ValueChanged after it finished the handler it is in. There are two possible workarounds for your situation now I think:
ClickedSendAppBar
) inside AppBarButton click function, and change focus. Inside ValueChanged check for that flag and if it is set, do what you would like to do, in the example app send money.