Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 按钮从一个表传递到另一个表_C#_Ios_Xamarin_Xamarin.ios - Fatal编程技术网

C# 按钮从一个表传递到另一个表

C# 按钮从一个表传递到另一个表,c#,ios,xamarin,xamarin.ios,C#,Ios,Xamarin,Xamarin.ios,我一直在寻找这个问题,我几乎100%肯定有人问过我,但我找不到一个链接。请提供一个链接,如果是这样,我很抱歉,如果它是多余的,但如果我错了,这里是我试图做的 我有一张摆满东西的桌子。我有一个描述,一个价格,一个图像,每个单元格中都有一个按钮。该按钮只是一个简单的“添加到购物车”按钮,它会将对象放入一个新表中(就像在线订购任何东西一样..添加到购物车,然后将其放入购物车中)。我现在最大的问题是想办法单击按钮,获取这些对象的行索引,然后将它们放入一个新表中(事实上,我甚至还没有创建表或类似的东西……

我一直在寻找这个问题,我几乎100%肯定有人问过我,但我找不到一个链接。请提供一个链接,如果是这样,我很抱歉,如果它是多余的,但如果我错了,这里是我试图做的

我有一张摆满东西的桌子。我有一个描述,一个价格,一个图像,每个单元格中都有一个按钮。该按钮只是一个简单的“添加到购物车”按钮,它会将对象放入一个新表中(就像在线订购任何东西一样..添加到购物车,然后将其放入购物车中)。我现在最大的问题是想办法单击按钮,获取这些对象的行索引,然后将它们放入一个新表中(事实上,我甚至还没有创建表或类似的东西……我只是想得到一个项目列表来填充该表……我正试着一步一步地进行)。以下是表格代码:

Food listOfGroceries;

    public GroceryTableSource(Food listOfGroceries)
    {
        this.listOfGroceries = listOfGroceries;
    }

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        var cell = (GroceryTableCell)tableView.DequeueReusableCell("cell_id", indexPath);
        var CurrentItem = listOfGroceries[indexPath.Row];
        cell.UpdateCell(CurrentItem);
        return cell;
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return FoodList.Count;
    }

}
以下是表格单元格: 公共部分类GroceryTableCell:UITableViewCell {


我不知道如何获取行索引,我已经为此工作了几个小时。当我在UITableViewSource类中时,特别是在方法GetCell中,我可以轻松访问行索引,但我不能将我想要使用的方法放在其中,因为我需要有人先单击按钮!

创建按钮时,将索引存储在它的标记属性中的值我正在使用序列图像板..我看到标记属性,它被设置为0。应该如何设置?是否可以将其设置为currentitem的indexPath.行?在GetCells中执行?是否有一个示例可以指向我?是否应该从序列图像板中删除按钮,以便为每个单元格创建一个新按钮?您需要使用e调试器检查GetCell中内置的GroceryTableCell对象,并确定如何访问按钮及其属性
    public GroceryTableCell(IntPtr handle) : base(handle)
    {
    }

    internal void UpdateCell(FoodStruct currentItem)
    {
        double Price = 9.99;
        ItemDescription.Text = currentItem.FoodDescription;
        ItemPrice.Text = Price.ToString();
    }
    protected void AddToCartClicked ( UIButton sender)
    {
        YourGroceryCart(sender);
    }

    protected string YourGroceryCart(UIButton sender)
    {

    }
}