This is a migrated thread and some comments may be shown as answers.

Initialize NumericUpDown with null

3 Answers 1121 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Paweł Polaczyk
Top achievements
Rank 1
Paweł Polaczyk asked on 12 Apr 2013, 09:39 AM
Is it possible to initialize NumericUpDown with null, so that the NullValue is shown when the NumericUpDown is shown first time?
NullValue is shown correctly when a user deletes the content of the NumericUpDown, but when I initialize the view model's property with null NumericUpDown shows 1 (my minimal value).

My XAML code is the following:
<t:RadNumericUpDown ValueFormat="Numeric" Minimum="1" Maximum="6"
NumberDecimalDigits="0" IsInteger="True" IsEditable="True"
Value="{Binding Priority, UpdateSourceTrigger=PropertyChanged}" Margin="4"
NullValue="None"></t:RadNumericUpDown>

3 Answers, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 17 Apr 2013, 02:11 PM
Hi,

By default if the Value property of the control is bound to a null value the NullValue will be shown. I recorded and attached a short video for you showing how the control behaves on our side.

Could you try to reproduce the issue with the latest released dlls of RadNumericUpDown and let is know if you are experiencing different behavior then the one observed in the video.

Kind regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paweł Polaczyk
Top achievements
Rank 1
answered on 18 Apr 2013, 01:10 PM
Hi Vladi,

Thank you for your answer and the video.
I am using assemblies in version 2013.1.403.45

When reproducing the issue I found that if my Priority property which is bound to the RadNumericUpDown.Value is of the double? type, then it works exactly like in your example - when window is opened control shows "None" string. So this is as expected.

However, when the Priority property is of the int? type the control shows "1" (the minimal value) when the window is opened.

I wrapped the int? property in a double? property and it seems to solve my problem.
However, I guess the behavior for int? is not what is expected.

EDIT:
I see another post where it is explained that "The RadNumericUpDown control doesn't support integer input" 

However now, I have a 2nd problem: when the control initialized with null, when I press Up or Down arrow "1" is shown (which is expected), but the bound property setter gets 0.0 as a value. Am I doing something wrong again?

EDIT2:
Actually, I made a workaround for this 2nd problem (with 0 instead of 1) by implementing an event handler for ValueChanged event:
if (!e.OldValue.HasValue && e.NewValue.HasValue && e.NewValue.Value == (sender as RadNumericUpDown).Minimum)
{
    (sender as RadNumericUpDown).Value = (sender as RadNumericUpDown).Minimum;
}

But it seems like the 2nd problem exists in RadNumericUpDown. Am I correct?

Best regards,
Paweł Polaczyk
0
Accepted
Vladi
Telerik team
answered on 22 Apr 2013, 02:09 PM
Hello,

We investigate the issue and it seems there is a bug in the control. We logged it in our Public Issue Tracker System where you can track its status.

I updated your Telerik point for bringing this to our attention.

Kind regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
NumericUpDown
Asked by
Paweł Polaczyk
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Paweł Polaczyk
Top achievements
Rank 1
Share this question
or