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

NullValue Not Being Displayed

1 Answer 118 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Jeremie
Top achievements
Rank 1
Jeremie asked on 18 Jul 2011, 08:59 PM
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.

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 19 Jul 2011, 08:13 AM
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!

Tags
NumericUpDown
Asked by
Jeremie
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or