NullValue Not Being Displayed

2 posts, 0 answers
  1. Jeremie
    Jeremie avatar
    13 posts
    Member since:
    Apr 2011

    Posted 18 Jul 2011 Link to this post


    I am using the NumericUpDown with a binding to a nullable short property on my ViewModel. The NumericUpDown is declared as follows

    <telerik:RadNumericUpDown Value="{Binding Path=CurrentOEMOriginalQuantity, ValidatesOnDataErrors=True}" Grid.Row="1" Grid.Column="2" Margin="0,0,2,0"
                                                                  NumberDecimalDigits="0" UpdateValueEvent="PropertyChanged" ShowButtons="False" NullValue=""/>

    And the ViewModel property is defined as

    public short? CurrentOEMOriginalQuantity
            if (adapter == null || adapter.CurrentOEMOriginalCost == null)
              return null;
              return adapter.CurrentOEMOriginalCost.QuantityOnHand;
            if (adapter == null || adapter.CurrentOEMOriginalCost == null)
            adapter.CurrentOEMOriginalCost.QuantityOnHand = value;
            RaisePropertyChanged(() => this.CurrentOEMOriginalQuantity);

    However, the value that is displayed on load is a 0.  I put a breakpoint in the getter of the property and it is indeed returning null.

    What am I missing here?

  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 19 Jul 2011 Link to this post

    Hello Jeremie,

    The Type of the Value property of RadNumericUpDown is Nullable<double> and since Nullable<short> is not automatically converted to Nullable<double>, the control always displays its default value - 0. You should use a IValueConverter that converts the two types in the binding to make the application to work.

    All the best,
    Valeri Hristov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft R3 2016 release webinar banner
Back to Top