Null values for integers are not displayed properly by the Telerik NumericUpDown control

StackOverflow https://stackoverflow.com/questions/18232457

  •  24-06-2022
  •  | 
  •  

سؤال

We are using the Telerik RadNumericUpDown control (2013 version) in our application to display & edit both double values and integers; The control works fine for nullable double types: it displays nothing for a null value, and 0.00 for the 0 value. We want the same behaviour for integers, but the control always displays 0 for null values. I've tried setting the NullValue to an empty string & null, based on the discussion here: http://www.telerik.com/community/forums/silverlight/numericupdown/null.aspx, but this doesn't solve our issue.

The XAML:

      <telerik:RadNumericUpDown Value="{Binding Path=Contents, Mode=TwoWay}"
                        NumberDecimalDigits="0"
                        IsEnabled="True"
                        IsEditable="True"
                        IsInteger="True"
                        NullValue=""                                
                        MinWidth="70"
                        HorizontalAlignment="Left"
                        HorizontalContentAlignment="Left" />

The Contents property is a nullable int.

Any help is appreciated.

هل كانت مفيدة؟

المحلول

Try adding to the binding TargetNullValue='', worked for me

    <telerik:RadNumericUpDown Value="{Binding Path=Contents, Mode=TwoWay, TargetNullValue=''}" 
                    IsEnabled="True"
                    IsEditable="True"
                    IsInteger="True"
                    NullValue=""                                
                    MinWidth="70"
                    HorizontalAlignment="Left"
                    HorizontalContentAlignment="Left" />
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top