【发布时间】:2019-03-04 20:28:41
【问题描述】:
我修复了一些项目中的一些自定义问题
其中一个我需要在分离的类和文件中使用自定义ViewCell
像这样:
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HBRS.Controls.ViewCellTemplates.ArticleItemViewCell">
<Image>
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding BindingContext.clickCommand, Source={x:Reference Name=mArt}}"
CommandParameter="{Binding .}" />
</Image.GestureRecognizers>
</Image>
</ViewCell>
mArt 是一个视图,它将命令用它做一些事情
之后,我在我的xamarin 页面中使用了这个视图单元格:
<ListView.ItemTemplate>
<DataTemplate>
<Cell:ArticleItemViewCell />
</DataTemplate>
</ListView.ItemTemplate>
当我在我的设备上运行应用程序时,它抛出一个异常说 找不到为“mArt”引用的对象
所以我需要一些方法以相同的结果传递Source={x:Reference Name=mArt} 或进行交互,该命令将使其实现
【问题讨论】: