Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1090
Binding an int to the value of a XamNumericEditor
posted

Hey,

I have a few questions related to the XamNumericEditor:

When I first tried binding an int to the XamNumericEditor I got the following error in the output:

System.Windows.Data Error: 22 : Cannot convert '1' from type 'Double' to type 'System.Int32' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: Int32Converter cannot convert from System.Double.
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'

This goes away if I set the ValueType property to Int32.  My question is: do I have to set ValueType or is it possible to have it automatically determined?


Also, when I completely clear the text in the XamNumericEditor (with ValueType=Int32), it does not set 0 in the underlying property.  So, it looks like the value is empty, but it is still there.  What is the best way to get around this?


Thanks

 

Parents
No Data
Reply
  • 69686
    posted

    Hello,

    I tried to reproduce this, but I was not able.

     

    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    ...
    <sys:Int32 x:Key="int1">1</sys:Int32>
    ...
    <igEditors:XamNumericEditor Value="{StaticResource int1}" ../>

    Can you please provide more information about how you bind the XamNumericEditor?

    Please note, that if the XamNumericEditor is in the XamDataGrid, the default value type would be double.

    Regarding the Null values, the ValueEditors have a NullText property, which you can use to get this.

    Regards,

    Alex.

     

     

     

     

Children