我正在编写我的第一个 Xamarin.Forms MVVM 应用程序,并且我正在完全使用 XAML 编写视图。我需要能够检测用户何时点击 Xamarin.Forms.Label,为此我遵循了以下 Xamarin 指南中的示例:
我的 Label 的 XAML 看起来像这样:
<Label Text="Test Check">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding OnClickCheckOption}"
CommandParameter="TestCheck" />
</Label.GestureRecognizers>
</Label>
当应用程序启动时,这会导致运行时错误:
“Xamarin.Forms.Xaml.Xaml.DLL 中出现 Xamarin.Forms.Xaml.XamlParseException 类型的异常,但未在用户代码中处理。附加信息:在 TapGestureRecognizer 上找不到 BindableProperty CommandProperty”
根据 Xamarin API,Xamarin.Forms.TapGestureRecognizer 类上没有 CommandProperty 或 CommandParameterProperty 的错误显然不正确:
http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.TapGestureRecognizer%2f*
有谁知道我做错了什么?非常感谢任何帮助,在此先感谢!