【发布时间】:2021-08-05 06:03:08
【问题描述】:
有没有办法在枚举模板中获取 Binding-Context 本身?
this.CollectionView.ItemTemplate = new DataTemplate(() =>
{
var view = new SubView();
view.SetBinding(SubView.SourceProperty, new Binding()
{
Source = ??? // <- here
});
return view;
};
注意:Path = "." 在 Android 上运行良好。但在 iOS 上,源是重复的。
我已经检查了 CollectionView.ItemsSource 中没有重复项。
【问题讨论】:
-
根据你的代码,我不清楚你遇到了什么问题吗?如果想通过后面的代码使用collectionview绑定,可以看一下:xamarin.forms collectionview
-
谢谢回复,Cherry Bu。 DataTemplate 构造函数的参数中的 Action 被执行的次数与元素的数量一样多。所以我想象会有一种方法可以将元素本身作为参数传递给 Action。
-
你为什么要这样做?对于collectionview.ItemTemplate,我一般用this document,不知道要不要用relative binding。
标签: xamarin.forms binding collectionview itemssource