NumberBox delayed value propagation after keyboard input
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
- It takes two times to leave
ui:NumberBoxfocus for the input value to propagate into binded ViewModel; - Changing to
UpdateSourceTrigger=PropertyChangedmakes it behave like is should've behaved withUpdateSourceTrigger=LostFocus.
Seems like UpdateSourceTrigger=LostFocus happens between Text and Value inside the control.
To Reproduce
I made this reproduction:
https://github.com/KillyMXI/wpf-ui-numberbox-issue-repro
- View: Views/Pages/DashboardPage.xaml
- ViewModel: ViewModels/Pages/DashboardViewModel.cs
Expected behavior
- It should not have extra internal propagation step.
- Value and Text should be updated at the same time.
- It should respect
UpdateSourceTriggersetting.PropertyChanged- both Text and Value changes notified immediately;LostFocus- both Text and Value changes notified on lost focus.
Extra:
Invalid value should not override text input. Don't ruin user input.
Invalid state should be telegraphed to the user through validation.
When Text is unparseable - Value should probably be NaN.
Screenshots
What is shown:
ui:TextBoxworks as expected;- binding ViewModel string to Text of
ui:NumberBoxworks as expected, but Value is out of sync; - binding ViewModel number to Value of
ui:NumberBoxcauses extra step needed to fully propagate new value.
OS version
Edition Windows 10 Pro
Version 22H2
OS build 19045.3930
.NET version
<TargetFramework>net8.0-windows</TargetFramework>
WPF-UI NuGet version
<PackageReference Include="WPF-UI" Version="3.0.0" />
Additional context
This is most likely related to:
- #216
but observed from the opposite end.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked reproduction and reading Views/Pages/DashboardPage.xaml and ViewModels/Pages/DashboardViewModel.cs to observe the NumberBox binding sequence. Then inspect the repository's NumberBox entry points and related issue #216. Done means Text and Value propagate together according to UpdateSourceTrigger, while invalid input remains visible and is exposed through validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100