Search code examples
c#wpfxamltelerik

Default value of telerik RadNumericUpDown in WPF


I am working on a web app, and it includes a RadNumericUpDown from telerik. The minimum value that the user is allowed to input is 0.1. It seems that when the page is first loaded, it defaults to the minimum value (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.

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. I would like it to move from 1 to 2 instead.

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.

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.

Here's my current 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!


Solution

  • The SampleRateText source property that you bind to should return default(double?) or whatever default double value you want to display. It's the current value of the Value property that is displayed in the control.

    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.