-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UpdateSourceTrigger on PropertyChanged for NumberBox does not work #7188
Comments
I'm having this problem also but I'm using Binding instead of x:Bind. |
Are there any updates on this issue |
Weird that this issue is still unresolved. The TextBox has the same behavior. |
The problem seems to be that NumberBox doesn't update its Text and Value properties when the underlying TextBox gets input, instead only updating them when focus is lost. So UpdateSourceTrigger is doing what it's supposed to do, but the NumberBox itself isn't behaving how we'd expect since it doesn't update the Text/Value properties until focus loss. Unfortunately this makes it difficult to use NumberBox in conjunction with keyboard events (for instance, submitting data when Enter is pressed). At minimum it would be nice to be able to programmatically tell NumberBox to update it's value from the entered text so we could work around this. |
@garrettpauls Actually I managed to fixed it with a workaround. the xaml:
The code behind:
|
@IsmailHassani Unfortunately that won't work for NumberBox, as NumberBox currently doesn't support UpdateSourceTrigger=PropertyChanged for either Value or Text (TextBox does behave as expected as of this comment). Short of forcing it to lose focus there doesn't seem to be a way to force NumberBox to update the parsed value. For now we've moved away from NumberBox and will implement custom key input handling for TextBox instead... |
I've found this issue today as well and had to use a text box in which I validate the value manually as well. Would love to see this on numberbox. And as already mentioned it would be okay to force validation programmatically if necessary. |
So is |
Describe the bug
Using x:Bind to create a two-way binding of data to the NumberBox.Value property and specifying UpdateSourceTrigger as PropertyChanged does not affect the behavior of the NumberBox. It appears that the behavior is remains to act as if UpdateSourceTrigger was set to LostFocus.
Steps to reproduce the bug
Expected behavior
When the binding UpdateSourceTrigger is set to PropertyChanged, the behavior should be that any keystroke updates the ViewModel's backing property, but that does not happen until the NumberBox loses focus.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.0
Windows app type
Device form factor
Desktop
Windows version
Windows 11 (21H2): Build 22000
Additional context
No response
The text was updated successfully, but these errors were encountered: