我对 C 编码和最重要的 C# 很陌生,所以我的问题是了解它是如何工作的。所以我真正想要的是,当您按下网格时,您将获得一个唯一的 id,具体取决于网格中显示的项目,而按下网格时,您将进入我想要显示 item.id 的新页面
文件 1
foreach (var item in list)
{
TapGestureRecognizer gridTap = new TapGestureRecognizer();
gridTap.Tapped += (sender, e) =>
{
Navigation.PushModalAsync(new MarketItemPage());
item.Id = GridIdentifier.Grid_id; // item.id is the id of the choosen item = static int in class
};
}
档案 2
public void Update()
{
string gridid = GridIdentifier.Grid_id.ToString();
grid.Children.Add(new Label
{
Text = gridid,
FontSize = 16,
FontFamily = "Arial",
TextColor = Color.Red,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Center,
HorizontalOptions = LayoutOptions.Center,
});
}
班级
public static class GridIdentifier
{
public static int Grid_id { get; set; }
}
泛舟湖上清波郎朗
相关分类