在我的ContentView (name=CvProduct)中,我有一个ListView (nam=LvProducts)和每个单元格中的几个控件,它们的特定命令可以在页面(name=Products)视图模型(name=ProductsViewModel)中访问。我无法使绑定工作。
<ContentPage x:Name="Products">
<ContentPage.Resources>
<ResourceDictionary>
<DataTemplate x:Key="ContentTemplate">
<views:CvProduct/>
</DataTemplate>
</ResourceDictionary>
</ContentPage.Resources>
</ContentPage>
<ContentView x:Name="CvProduct">
<xForms:SfListView x:Name="LvProducts">
<xForms:SfListView.ItemTemplate>
<DataTemplate>
<forms:SvgCachedImage.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.ConsultElement,
Source={x:Reference Name=LvProducts}}" CommandParameter="{Binding .}">
</forms:SvgCachedImage.GestureRecognizers>
</DataTemplate>
</xForms:SfListView.ItemTemplate>
</xForms:SfListView>
</ContentView>它总是返回此错误:
Message =“
LvProducts无法找到LvProducts引用的对象”
发布于 2019-06-25 08:42:53
在名为MyCommand的页面的绑定上下文中引用命令myPage
Command="{Binding Source={x:Reference Name=myPage},
Path=BindingContext.MyCommand}" 在名为MyCommand的布局的绑定上下文中引用包含ListView的命令ListView:
Command="{Binding Source={x:Reference Name=myLayout},
Path=BindingContext.MyCommand}" https://stackoverflow.com/questions/56745720
复制相似问题