Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > NumericUpDown > NullValue Not Being Displayed

Not answered NullValue Not Being Displayed

Feed from this thread
  • Jeremie avatar

    Posted on Jul 18, 2011 (permalink)

    Hello,

    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
        {
          get
          {
            if (adapter == null || adapter.CurrentOEMOriginalCost == null)
              return null;
            else
              return adapter.CurrentOEMOriginalCost.QuantityOnHand;
          }
          set
          {
            if (adapter == null || adapter.CurrentOEMOriginalCost == null)
              return;
     
            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?

    Thanks.

    Reply

  • Valeri Hristov Valeri Hristov admin's avatar

    Posted on Jul 19, 2011 (permalink)

    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!

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > NumericUpDown > NullValue Not Being Displayed
Related resources for "NullValue Not Being Displayed"

WPF NumericUpDown Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]