NumericUpDown: Shouldn't there be a single event for when the user made a change that should be acted upon?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by tracing NumericUpDown's ValueChanged handling, UpdateValueOnEnterKey behavior, and the spinner-related events described in the issue. Clarify the desired event semantics for Enter/Return, focus loss, and completed spinner changes; done means an agreed API that avoids per-keystroke actions while reporting the applied value.
Written by the indexing model from the issue text.
Description
When the user is editing a NumericUpDown, every keystroke raises a ValueChanged event. This is not ideal when it's linked to something that you don't want changed more frequently than necessary. In the past I have dealt with this by handling the KeyUp, LostFocus, and Spinned events like this:
private void TheIntegerUpDown_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter || e.Key == Key.Return)
if (TheIntegerUpDown.Value.HasValue)
Update(TheIntegerUpDown.Value);
}
private void TheIntegerUpDown_LostFocus(object sender, RoutedEventArgs e)
{
if (TheIntegerUpDown.Value.HasValue)
Update(TheIntegerUpDown.Value);
}
private void TheIntegerUpDown_Spinned(object sender, Xceed.Wpf.Toolkit.SpinEventArgs e)
{
if (TheIntegerUpDown.Value.HasValue && TheIntegerUpDown.Increment.HasValue)
{
if (e.Direction == Xceed.Wpf.Toolkit.SpinDirection.Increase)
Update(TheIntegerUpDown.Value + TheIntegerUpDown.Increment);
else if (e.Direction == Xceed.Wpf.Toolkit.SpinDirection.Decrease)
Update(TheIntegerUpDown.Value - TheIntegerUpDown.Increment);
}
}
This seem like a lot of code to handle something conceptually very simple. I see there is an UpdateValueOnEnterKey property which could simplify this a bit, but when that's set to true, using the up/down spinner buttons no longer raises the ValueChanged event. Furthermore, let's say you needed to look at multiple NumericUpDowns whenever a spinner button on one is used. You would need some mechanism to indicate one particular NumericUpDown's new value, while the others are unchanged.
I can envision a few ways of solving this, if an elegant solution does not exist already:
- An ActionableValueChanged event (couldn't come up with a better name) that's only raised when the user is typing and hits enter/return, the NumericUpDown loses focus, or a spinner button is pressed.
- A SpinCompleted event so one can easily get the NumericUpDown's Value after the change has been applied.
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 912
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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.
More from xceedsoftware/wpftoolkit
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
xceedsoftware/wpftoolkit#1808 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
xceedsoftware/wpftoolkit#1807 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
xceedsoftware/wpftoolkit#1806 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
xceedsoftware/wpftoolkit#1804 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
xceedsoftware/wpftoolkit#1802 · 3 comments ·
All issues in xceedsoftware/wpftoolkit
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·