Created
October 8, 2012 07:33
-
-
Save philcockfield/3851206 to your computer and use it in GitHub Desktop.
MT.Dialog Element - No Tapped Event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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