0

I'm using the OwnerDrawnElement example from the Monotouch.Dialog example project (modifying colors but that's about it).

I would like to know how to register click events for each row working. I've heard that the OwnerDrawnElement isn't quite sophisticated enough to do that. I would like to extend if, but not sure that this is possible.

Option 2:

The MessageElement would work great for what I'm trying to do, but... I need to set the background color and not sure how I could do that either.

Help is greatly appreciated!

BRogers
  • 3,534
  • 4
  • 23
  • 32

1 Answers1

2

You can extend OwnerDrawnElement with this:

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);
}

After that tap event can be set in following way:

var ownTap = new MyOwnerDrawnElement ();
ownTap.Tapped += (DialogViewController arg1, UITableView arg2, NSIndexPath arg3) => {
    Console.WriteLine ("Test");
};
olexa.le
  • 1,697
  • 10
  • 14