0

我正在使用 Monotouch.Dialog 示例项目中的 OwnerDrawnElement 示例(修改颜色,仅此而已)。

我想知道如何为每一行注册点击事件。我听说OwnerDrawnElement它还不够复杂,无法做到这一点。我想扩展如果,但不确定这是可能的。

选项 2:

MessageElement对于我正在尝试做的事情非常有用,但是......我需要设置背景颜色,但我也不确定我该怎么做。

非常感谢您的帮助!

4

1 回答 1

2

你可以OwnerDrawnElement用这个扩展:

public event Action<DialogViewController, UITableView, NSIndexPath> Tapped;
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
    if (Tapped != null) {
        Tapped (dvc, tableView, path);
    }
    tableView.DeselectRow (indexPath, true);
}

之后可以通过以下方式设置点击事件:

var ownTap = new MyOwnerDrawnElement ();
ownTap.Tapped += (DialogViewController arg1, UITableView arg2, NSIndexPath arg3) => {
    Console.WriteLine ("Test");
};
于 2013-02-20T09:10:00.597 回答