lepoco / lepoco/wpfui

NumberBox delayed value propagation after keyboard input

Open
#945 0 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:star: top bug :star: top issue bug
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:NumberBox focus for the input value to propagate into binded ViewModel;
  • Changing to UpdateSourceTrigger=PropertyChanged makes it behave like is should've behaved with UpdateSourceTrigger=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

Expected behavior
  • It should not have extra internal propagation step.
  • Value and Text should be updated at the same time.
  • It should respect UpdateSourceTrigger setting.
    • 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

NumberBoxIssue

What is shown:

  • ui:TextBox works as expected;
  • binding ViewModel string to Text of ui:NumberBox works as expected, but Value is out of sync;
  • binding ViewModel number to Value of ui:NumberBox causes 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.