Initialize NumericUpDown with null

4 posts, 2 answers
  1. Paweł Polaczyk
    Paweł Polaczyk avatar
    8 posts
    Member since:
    Jul 2011

    Posted 12 Apr 2013 Link to this post

    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>
  2. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 17 Apr 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Paweł Polaczyk
    Paweł Polaczyk avatar
    8 posts
    Member since:
    Jul 2011

    Posted 18 Apr 2013 Link to this post

    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
  5. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 22 Apr 2013 Link to this post

    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.

Back to Top