如何 select UITableView 中的一行文本 Xamarin.ios c#

How to select a row's text from a UITableView Xamarin.ios c#

我想要 select 我 table 中一行的文本,我已经进行了一些搜索,但我似乎无法在 Xamarin.ios 中找到示例我认为我想要类似的东西

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *cellText = selectedCell.textLabel.text;
}

但在 Xamarin.ios 而不是 objective c 中,我们将不胜感激,谢谢

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
     new UIAlertView("Row Selected", tableItems[indexPath.Row], null, "OK", null).Show();
     tableView.DeselectRow (indexPath, true); // iOS convention is to remove the highlight
}

您只需要行索引 (indexPath.Row ),您就可以从数组中获取填充 UITableView 的文本

来自 Xamarin 网站,了解如何 Handle Row Click