use*_*604 5 c# xaml mvvm xamarin.forms
我正在编写我的第一个 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>
Run Code Online (Sandbox Code Playgroud)
当应用程序启动时,这会导致运行时错误,指出:
“Xamarin.Forms.Xaml.XamlParseException 类型的异常发生在 Xamarin.Forms.Xaml.DLL 中,但未在用户代码中处理。附加信息:在 TapGestureRecognizer 上找不到 BindableProperty CommandProperty”
根据 Xamarin API,Xamarin.Forms.TapGestureRecognizer 类上没有 CommandProperty 或 CommandParameterProperty 的错误显然不是真的:
http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.TapGestureRecognizer%2f*
有谁知道我做错了什么?非常感谢任何帮助,提前致谢!
您的代码是有效的,并且应该可以工作,前提是您在 的最新版本之一上运行它Xamarin.Forms,因为它CommandProperty是全新的。
在撰写本文时,您应该定位的版本是1.2.2-pre2(nuget pre-release)
| 归档时间: |
|
| 查看次数: |
8450 次 |
| 最近记录: |