BRogers
BRogers

Reputation: 3604

Monotouch OwnerDrawnElement Click Event

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!

Upvotes: 0

Views: 255

Answers (1)

olexa.le
olexa.le

Reputation: 1807

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

Upvotes: 2

Related Questions