NumberBox not updating displayed value after changing value
@pomianowski is already working on this.
Since Jun 10, 2022.
- 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:
- Create NumberBox
<wpfui:NumberBox x:Name="TEST" MinWidth="100" Step="1" Min="1" Max="100" />
- 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;
}
- Run application and set NumberBox to 13 (or any other number)
- 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
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.
Assessment
This issue has not been assessed yet.