Monotouch OwnerDrawnElement单击“事件”

时间:2013-02-19 22:00:47

标签: ios xamarin.ios monotouch.dialog

我正在使用Monotouch.Dialog示例项目中的OwnerDrawnElement示例(修改颜色但是就此而言)。

我想知道如何为每行工作注册点击事件。我听说OwnerDrawnElement不够复杂,不足以做到这一点。我想延长if,但不确定这是可能的。

选项2:

MessageElement对我正在尝试做的事情很有用,但是......我需要设置背景颜色,不知道我怎么做。

非常感谢帮助!

1 个答案:

答案 0 :(得分: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");
};
相关问题