admin管理员组文章数量:1181399
I have a numeric up down
like this:
<NumericUpDown Value="{Binding Samples}" ShowButtonSpinner="False" ParsingNumberStyle="Integer"/>
Then I use this on the MainWindow.axaml.cs:
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Key == Key.Enter) // includes Key.Return
Focus();
}
This makes the Input lose focus when the Return
key is pressed.
if I type '100' into the field and press return, it accepts the value, like I would expect.
if I type '100.0' or any invalid string the field does not loose focus when pressing return
. In this case I'd like the input to be reset to whatever it was before the user started typing.
Do I need to write my own validator and call it while the user is typing?
本文标签: number formattingAvalonia Get Numeric UpDown to parse the text on lost focusStack Overflow
版权声明:本文标题:number formatting - Avalonia: Get Numeric UpDown to parse the text on lost focus - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738234514a2070624.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论