Cant bind to Integer property

2 posts, 0 answers
  1. Simon
    Simon avatar
    7 posts
    Member since:
    Oct 2010

    Posted 16 Oct 2012 Link to this post

    trying to bind a RadNumericUpDown to a integer in a datatemplate:
    <DataTemplate DataType="{x:Type datatypes:IntTupleInput}">
    <telerik:RadNumericUpDown Value="{Binding Value}"  IsInteger="True" ValueFormat="Numeric" />

    My Value proerty is defined this way:

    public override object Value
                   return GetValue();
                   if (IsLinked)
                       throw new RVExecutorException(this, "Non è possibile impostare il valore di un dato che è collegato ad un altro.");

    the GetValue returns an Integer while the SetValue try to convert the value into integer.

    The problem is that I can't see anything in the NumericUpDown box. When I try to put a value inside, I can see into the debug that it is sending a double value like 1.0 or 2.0 to my property (this is not desired, but by now I can convert and store it as an integer). At the moment that the binding reads my proerty Value, I get an error in the output window saying:

    'ObjectSourceConverter' converter failed to convert value '100' (type 'Int32'); fallback value will be used, if available. BindingExpression:Path=Value; DataItem='IntTupleInput' (HashCode=64515557); target element is 'RadNumericUpDown' (Name=''); target property is 'Value' (type 'Nullable`1') NotSupportedException:'System.NotSupportedException: DoubleConverter cannot convert from System.Int32.
       in MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
       in MS.Internal.Data.ObjectSourceConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)

    this also happen if I try to bind directy to the Integer property int CurrentValue that stores the value (instead of an "object" Value property)

    Could you please clarify this behavior??

  2. Konstantina
    Konstantina avatar
    2332 posts

    Posted 19 Oct 2012 Link to this post

    Hi Simone,

    The RadNumericUpDown control doesn't support integer input. It supports double input. To make it to display integer it is formatted to the according way, but internally it manages with double type. This is also the behavior in the Silverlight toolkit's control, which we try to follow for consistency.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top