简体   繁体   English

WPF 中 Telerik RadNumericUpDown 的默认值

[英]Default value of telerik RadNumericUpDown in WPF

I am working on a web app, and it includes a RadNumericUpDown from telerik.我正在开发一个网络应用程序,它包含来自 Telerik 的 RadNumericUpDown。 The minimum value that the user is allowed to input is 0.1.允许用户输入的最小值为 0.1。 It seems that when the page is first loaded, it defaults to the minimum value (0.1).好像页面第一次加载的时候默认是最小值(0.1)。 This is an issue because it is displaying 0.1, but this value is not passed into the code until the user makes changes.这是一个问题,因为它显示的是 0.1,但在用户进行更改之前,不会将此值传递到代码中。

Another Issue that I am having is that because the default is 0.1, pressing the up arrow moves it up to 1.1, 2.1, ect.我遇到的另一个问题是,因为默认值为 0.1,按向上箭头会将其向上移动到 1.1、2.1 等。 I would like it to move from 1 to 2 instead.我希望它从 1 移动到 2。

What I want the up down button to do is to not display any value when no value has been set.我希望向上向下按钮做的是在没有设置任何值时不显示任何值。 When the up arrow is pressed, I would like it to go to 1. If the user needs a decimal value, they can manually set it.当按下向上箭头时,我希望它转到1。如果用户需要一个十进制值,他们可以手动设置。

Does anyone know how I can either:有谁知道我可以如何:

  • Set the default value to be something other than the minimum value将默认值设置为最小值以外的值
  • or get the box to update when the page loads.或在页面加载时获取更新框。

I can't find anything in the telerik documentation .我在Telerik 文档中找不到任何内容

Here's my current RadNumericUpDown:这是我当前的 RadNumericUpDown:

<telerik:RadNumericUpDown Grid.Row="4"
         Grid.Column="1"
         Minimum="0.1"
         Style="{StaticResource RadNumericUpDown}"
         NumberDecimalDigits="1"
         Value="{Binding SampleRateText, Mode=TwoWay}"
         UpdateValueToMatchTextOnLostFocus ="True"
         Visibility="{Binding IsTimeRateVisible}" />

Any help would be greatly appreciated!任何帮助将不胜感激!

The SampleRateText source property that you bind to should return default(double?) or whatever default double value you want to display.您绑定到的SampleRateText源属性应返回default(double?)或您想要显示的任何默认double值。 It's the current value of the Value property that is displayed in the control.它是控件中显示的Value属性的当前值。

And if you want to increase from 0.1 to 0.2 you should either set the SmallChange to 0.1 or handle the ValueChanged event and write your custom logic.如果您想从0.1增加到0.2您应该将SmallChange设置为0.1或处理ValueChanged事件并编写您的自定义逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM