lepoco / lepoco/wpfui

NumberBox not updating displayed value after changing value

Open
#216 9 comments 0 reactions 1 assignee View on GitHub

@pomianowski is already working on this.

Since Jun 10, 2022.

bug
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

NumberBox does not update the displayed value (Text property) after changing Value property if the control is not empty.

To Reproduce
Steps to reproduce the behavior:

  1. Create NumberBox
<wpfui:NumberBox x:Name="TEST" MinWidth="100" Step="1" Min="1" Max="100" />
  1. Create button with click event
<Button x:Name="Button" Content="Change Value" Click="Button_Click" />
private void Button_Click(object sender, RoutedEventArgs e) {
    TEST.Value = 20;
}
  1. Run application and set NumberBox to 13 (or any other number)
  2. Click button, notice that NumberBox still displays original number

Expected behavior
I expect when changing Value for the new number to be reflected in the NumberBox

Desktop (please complete the following information):

  • OS: Windows 10
  • .NET: net6.0
  • Version: WPFUI 1.2.7

Additional context
This appears to be an issue in Value_PropertyChanged: https://github.com/lepoco/wpfui/blob/8883c3a2a1125b75801066626e6f4d9f137dfd88/src/WPFUI/Controls/NumberBox.cs#L189

If the string is not null or empty the code returns. I’d be happy to submit a pull request but not sure what the intent of this line is.

In the mean time the simple workaround is to set Text and Value properties.

Thanks for the great library!

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.