Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Are there any built in Value Converters for basic binding?

$
0
0

I'm getting an invalid cast exception when trying to bind to an Int. I know I need to use a Value Converter, but I'm wondering if there are any baked in, or if I need to implement each one by hand?

The Property

public int Age { get; set; }

The XAML

<Entry Placeholder="Age"
             Keyboard="Numeric"
             Text="{Binding Age}" />

The Error

UNHANDLED EXCEPTION: System.ArgumentException: Object type System.String cannot be converted to target type: System.Int32 06-12 10:46:30.731 I/MonoDroid(21851): at System.Reflection.Binder.ConvertValue (object,System.Type,System.Globalization.CultureInfo,bool) 06-12 10:46:30.731 I/MonoDroid(21851): at System.Reflection.Binder.ConvertValues (object[],System.Reflection.ParameterInfo[],System.Globalization.CultureInfo,bool) 06-12 10:46:30.731 I/MonoDroid(21851): at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.Platform.Android.EntryRenderer.Android.Text.ITextWatcher.OnTextChanged (06-12 10:46:30.731 I/MonoDroid(21851): at System.Reflection.MethodBase.Invoke (object,object[]) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.BindingExpression.ApplyCore (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty,bool) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.BindingExpression.Apply (bool) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.Binding.Apply (bool) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.BindableObject/<>c__DisplayClass1.b__0 () 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,bool,bool,bool) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty,object,bool) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty,object) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.Entry.set_Text (string) 06-12 10:46:30.731 I/MonoDroid(21851): at Xamarin.Forms.Platform.Android.EntryRenderer.Android.Text.ITextWatcher.OnTextChanged (Java.Lang.ICharSequence,int,int,int) 06-12 10:46:30.731 I/MonoDroid(21851): at Android.Text.ITextWatcherInvoker.n_OnTextChanged_Ljava_lang_CharSequence_III (intptr,intptr,intptr,int,int,int) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/b5dc5ce9/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Text.ITextWatcher.cs:149 06-12 10:46:30.731 I/MonoDroid(21851): at (wrapper dynamic-method) object.9137de96-3561-461d-b245-a7d51d6329fb (intptr,intptr,intptr,int,int,int) 06-12 10:46:30.751 E/mono-rt (21851): Stacktrace:


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>