【发布时间】:2020-06-01 01:50:48
【问题描述】:
我有下面的代码,我基本上是循环一个列表并使用该列表的属性作为值:
SLTData.g_RecentLoans.ForEach(x => {
colorCode = loanHistoryViewModel.GetStatusColor(x.ActivityListID);
principal = utilities.FormatCurrency(x.PAMT);
formattedDate = loanHistoryViewModel.ConvertDate(x.DateRequested);
stackRecentList.Children.Add(
new Frame {
BackgroundColor = Color.White,
Margin = new Thickness(30, 20, 30, 0),
Padding = new Thickness(10),
CornerRadius = 5,
HasShadow = true,
Content = new StackLayout {
Orientation = StackOrientation.Horizontal,
Spacing = 0,
Children = {
// Content here
// The 'x' variables are used inside this StackLayout
}
}
}
);
});
问题是,我想在循环中 StackLayout 的每次迭代中添加一个 TapGestureRecognizer。我尝试在 StackLayout 的右括号中添加.GestureRecognizers.Add(tapGestureRecognizer),但它显示Cannot implicitly convert type 'void' to 'Xamarin.Forms.View'
我基本上想要做的是向处理点击的函数添加一个参数,该参数是传递给 API 的关键字。
【问题讨论】:
-
那是因为你必须将它应用到 Add 方法,检查括号并将它应用到你的 View !!!
标签: c# xamarin.forms uitapgesturerecognizer