Reputation: 6801
The MonoTouch.Dialog RootElement
does not appear to have a way of adding a subtitle. I would like to display a subtitle below the caption.
Do I have to subclass the element and add a custom view to in the GetCell method?
Is there a simpler option?
Upvotes: 0
Views: 483
Reputation: 6801
The simplest way to achieve this is to subclass RootElement and override GetCell method, create a new cell and set the LabelText and DetailLabelText. This will give you a nice subtitle
public override MonoTouch.UIKit.UITableViewCell GetCell(MonoTouch.UIKit.UITableView tv) {
var baseCell = base.GetCell(tv);
var cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "cellId");
cell.TextLabel.Text = Caption;
cell.DetailTextLabel.Text = _subtitle;
cell.Accessory = baseCell.Accessory;
return cell;
}
Note the cell Style. Unfortunately, it looks like the cell style is available only during cell construction and not afterward. So you cant just call base.GetCell(tv) and set it's style. That would have been a better option.
_subTitle is a class level variable set via the custom constructor
private string _subtitle = string.Empty;
public ChartSectionRootElement(string caption, string subTitle) : base(caption) {
this._subtitle = subTitle;
}
Upvotes: 2