NumericUpDown: Shouldn't there be a single event for when the user made a change that should be acted upon?
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- C#
- 星标
- 4.2k
- 派生
- 912
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
xceedsoftware/wpftoolkit 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
xceedsoftware/wpftoolkit#1808 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 48/100
xceedsoftware/wpftoolkit#1807 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
xceedsoftware/wpftoolkit#1806 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 45/100
xceedsoftware/wpftoolkit#1804 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
xceedsoftware/wpftoolkit#1802 · 3 条评论 ·
查看 xceedsoftware/wpftoolkit 的全部 Issue
相似的 Issue
-
untriaged
难度 1/5 1 小时以内 新手友好度 88/100
dotnet/dotnet-api-docs#13095 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
newrelic/newrelic-dotnet-agent#3850 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
LuckyPennySoftware/AutoMapper#4660 ·