在 monotouch.dialog 中可以轻松设置 RootElement 样式吗? [英] In monotouch.dialog can RootElement be easily styled?

查看:19
本文介绍了在 monotouch.dialog 中可以轻松设置 RootElement 样式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何现有的扩展,或者是否可以通过类似的方式在 monotouch.dialog 中为 RootElement 添加样式,您可以为 StyledStringElement 添加样式.

Are there any existing extensions or is it fairly straight forward to add styles to RootElement in monotouch.dialog in a similar way you can style StyledStringElement.

基本上,我想向 RootElement 添加图像或徽章以指示子视图中的详细信息类型,例如添加成功、警告、错误、信息类型的图像 - 因此用户可能只对点击感兴趣到不完全成功的细节.

Basically I would like to add an image, or badge to RootElement to indicate what sort of details would be in the child view, eg add Success, Warning, Error, Info type image - so the users may only be interested in clicking through to details that are not fully successful.

所以理想情况下,我将能够编写这样的代码......

So ideally I would be able to code 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)
                        }
                    }}
            };

感谢您的帮助或指点.

推荐答案

这个问题很老了,但是如果其他人遇到它,您可以将 RootElement 类子类化以添加图标.我的代码如下:

This question is old, but if anyone 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;
        }   
    }

这篇关于在 monotouch.dialog 中可以轻松设置 RootElement 样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆