Xamarin.forms 如何在Prism for Xamarin窗体中使用EventToCommandBehavior获取ItemTappedEventArgs
Xamarin.表格和棱镜6.3.0 似乎我无法通过使用EventToCommandBehavior获取ItemTappedEventArgs(或作为ListView的sender对象) 在我的XAML中,我定义了2个名称空间Xamarin.forms 如何在Prism for Xamarin窗体中使用EventToCommandBehavior获取ItemTappedEventArgs,xamarin.forms,prism,Xamarin.forms,Prism,Xamarin.表格和棱镜6.3.0 似乎我无法通过使用EventToCommandBehavior获取ItemTappedEventArgs(或作为ListView的sender对象) 在我的XAML中,我定义了2个名称空间 xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms" xmlns:c="clr-namespace:Prism.Converters;assembly=Prism.Forms" 同样在我的XAML中,在
xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
xmlns:c="clr-namespace:Prism.Converters;assembly=Prism.Forms"
同样在我的XAML中,在我的ListView中,我有以下内容
<ListView.Behaviors>
<b:EventToCommandBehavior EventName="ItemTapped" Command="{Binding ItemTappedCommand}"
EventArgsConverter="{StaticResource ItemTappedEventArgsConverter}"/>
</ListView.Behaviors>
我还在代码“MyApp/Converters”的其他地方定义了文档中建议的项目TappedEventArgsConverter
应用程序(Android)在启动之前会显示通常的“应用程序停止工作”消息
我能够在XAML中使用CommandParameter=“MyParameter”
而不是EventArgsConverter
,并且我能够通过使用EventArgsParameterPath=“item”
但是,当我使用事件argsConverter
时,我得到了错误,应用程序无法启动
我做错了什么?如何获取事件行为中的参数(或发送方)?有我可以使用的例子吗?我找到了问题所在。实际上有两个问题 第一个是包含转换器的程序集的引用。 而不是
xmlns:c=“clr命名空间:Prism.Converters;assembly=Prism.Forms”
应该是
xmlns:local=“clr名称空间:MyApplication.Converters”
(或包含转换器的程序集的名称)
第二个错误是我的内容页中没有以下XAML
<ContentPage.Resources>
<ResourceDictionary>
<local:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter" />
</ResourceDictionary>
</ContentPage.Resources>
我找到了问题所在。实际上有两个问题 第一个是包含转换器的程序集的引用。 而不是
xmlns:c=“clr命名空间:Prism.Converters;assembly=Prism.Forms”
应该是
xmlns:local=“clr名称空间:MyApplication.Converters”
(或包含转换器的程序集的名称)
第二个错误是我的内容页中没有以下XAML
<ContentPage.Resources>
<ResourceDictionary>
<local:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter" />
</ResourceDictionary>
</ContentPage.Resources>
void ItemTapped(object args)
{
...
}
<ContentPage.Resources>
<ResourceDictionary>
<local:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter" />
</ResourceDictionary>
</ContentPage.Resources>