Skip to content

Instantly share code, notes, and snippets.

@philcockfield
Created October 8, 2012 07:33
Show Gist options
  • Save philcockfield/3851206 to your computer and use it in GitHub Desktop.
Save philcockfield/3851206 to your computer and use it in GitHub Desktop.
MT.Dialog Element - No Tapped Event
using System;
using MonoTouch.Dialog;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using TheraPlay.Data;
namespace Namespace
{
public class MyElement : Element
{
#region Head
static readonly string CELL_KEY = "my_key";
public event EventHandler<EventArgs> Tapped;
// Constructor.
public MyElement() : base("")
{
}
#endregion
#region Methods - Overrides
public override UITableViewCell GetCell(UITableView tableView)
{
var cell = tableView.DequeueReusableCell(CELL_KEY) ?? new UITableViewCell(UITableViewCellStyle.Default, CELL_KEY);
cell.SelectionStyle = (Tapped != null) ? UITableViewCellSelectionStyle.Blue : UITableViewCellSelectionStyle.None;
// Setup the label.
var label = cell.TextLabel;
label.Text = "FOO";
// Finish up.
return cell;
}
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath indexPath)
{
// GRRRRR - this never gets invoked!
if (Tapped != null)
Tapped (this, EventArgs.Empty);
tableView.DeselectRow (indexPath, true);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment