In monotouch.dialog can RootElement be easily styled?

Whether there are any existing extensions or it is fairly simple to add styles to RootElement in monotouch.dialog in a similar way, you can style StyledStringElement.

Basically, I would like to add an image or icon to the RootElement to indicate which details will be displayed in the child view, for example, add the image Success, Warning, Error, Info type - so that users may only be interested in clicking on the details that are not completely successful.

Ideally, I could encode something like this ...

UIImage imageSuccess = ImageLoader.DefaultRequestImage (new Uri ("file://" + Path.GetFullPath ("Images/Success.png")), null); var root = new RootElement("Root") { Image = imageSuccess, Accessory = UITableViewCellAccessory.DetailDisclosureButton, new Section (){ new BooleanElement ("Airplane Mode", false), new RootElement ("Notifications") { new Section (null, "Turn off Notifications") { new BooleanElement ("Notifications", false) } }} }; 

Thanks for any help or pointers.

+1
source share
2 answers

This question is old, but if someone else comes across it, you can subclass the RootElement class to add an icon. My code is as follows:

  public class ImageRootElement : RootElement { private UIImage _image; 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.Accessory = baseCell.Accessory; cell.ImageView.Image = _image; return cell; } public ImageRootElement (string caption, UIImage image) : base(caption) { _image = image; } } 
+5
source

Since MT.Dialog is open source, you can change the properties and constructors of RootElement as you like. I don’t think there is anything that does what you want out of the box, so you have to expand Dialog to suit your needs.

As an aside, it looks like you MAY NOT understand the intent of RootElement. RootElement is just the main container that contains all of your sections and elements. Apparently, it makes no sense to have a disclosure indicator or icon on the RootElement, simply because it is not the intent of the RootElement. Perhaps I just do not understand you. However, if you want to create your own style using icons, etc., you can create your own element classes that inherit from OwnerDrawnElement by overriding two abstract methods. However, read Miguel's answer to a similar question here before doing this.

+1
source

All Articles