Xamarin 如何处理UITableViewCell ID

Xamarin 如何处理UITableViewCell ID,xamarin,xamarin.ios,Xamarin,Xamarin.ios,我有一个模型,我正在从我的UITableView类传递给我的UITableViewCell,如下所示 this.Source = new MyTableSource(ListOfItems); public void BindCell(ITEM link) { TitleText.Text = Link.Title; } public override void RowSelected(UITableView tableView, NSIndexPath indexPath) {

我有一个模型,我正在从我的
UITableView
类传递给我的
UITableViewCell
,如下所示

this.Source = new MyTableSource(ListOfItems);
public void BindCell(ITEM link)
{
 TitleText.Text = Link.Title;
}
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{                              
 tableView.DeselectRow(indexPath, true);
}
我的项目模型只有两个值

public string Id { get; set; }
public string Title { get; set; }
其中my
UITableViewSource
如下所示

public class AllSource : UITableViewSource
{
    List<ITEM> ITEMS = new List<ITEM>();        
    public AllSource(List<ITEM> _items)
    {
        ITEMS = _items;           
    }

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        var cell =  tableView.DequeueReusableCell("AllCell") as AllCell;

        if (cell == null)
        {
            cell = new AllCell();
            var views = NSBundle.MainBundle.LoadNib(AllCell.Key, cell, null);
            cell = Runtime.GetNSObject(views.ValueAt(0)) as AllCell;
        }
        var LINK = ITEMS[indexPath.Row];           
        cell.BindCell(LINK);            
        return cell;
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return HomeDisplay.Count;
    }
}
我还使用了“RowSelected”,如下所示

this.Source = new MyTableSource(ListOfItems);
public void BindCell(ITEM link)
{
 TitleText.Text = Link.Title;
}
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{                              
 tableView.DeselectRow(indexPath, true);
}
这个可以,但是

我想将
字符串格式的唯一ID附加到
单元格
因此,当触发我的
行选择
时,我会将该
字符串
ID发送到 是否唯一标识所选项目的ID(而不是索引)

一开始,我以为只是把一个隐藏的标签,但这似乎不是一个正确的选择


这可能吗

> p>如果从模型中考虑<代码>公共字符串id {get;set;} >是唯一的<代码> id < /代码>,那么您可以得到如下:

public override void RowSelected(UITableView tableView, NSIndexPath indexPath) 
{ 
    tableView.DeselectRow(indexPath, true);

    //Here you can get your Id of selected row
    string selectedId = ITEMS[indexPath.Row].Id;
}

我不知道为什么我没有想到:)非常感谢你