I'm writing my first Xamarin.Forms MVVM application and I'm writing the view entirely with XAML. I need to be able to detect when the user taps a Xamarin.Forms.Label and to do so I've followed the example in the following Xamarin guide:
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/gestures/#Using_ICommand
And my Label's XAML looks like this:
<Label Text="Test Check">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding OnClickCheckOption}"
CommandParameter="TestCheck" />
</Label.GestureRecognizers>
</Label>
This causes a run-time error when the app starts that states:
"An exception of type Xamarin.Forms.Xaml.XamlParseException' occured in Xamarin.Forms.Xaml.DLL but was not handled in user code. Additional information: BindableProperty CommandProperty not found on TapGestureRecognizer"
The error that there is no CommandProperty or CommandParameterProperty on the Xamarin.Forms.TapGestureRecognizer class is clearly not true according to the Xamarin API:
http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.TapGestureRecognizer%2f*
Does anyone know what I'm doing wrong? Any help is greatly appreciated, thanks in advance!
Your code is valid, and should work, provided you run it on one of the latest build of Xamarin.Forms
, as the CommandProperty
is brand new.
At the time of this writing, the version you should target is 1.2.2-pre2
(nuget pre-release)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With