Xamarin.ios 在monotouch.dialog中,RootElement可以轻松设置样式吗?

Xamarin.ios 在monotouch.dialog中,RootElement可以轻松设置样式吗?,xamarin.ios,monotouch.dialog,Xamarin.ios,Monotouch.dialog,是否有任何现有的扩展,或者在monotouch.dialog中直接向RootElement添加样式,方法与设置StyledStringElement样式类似 基本上,我想向RootElement添加一个图像或徽章,以指示子视图中的详细信息,例如添加成功、警告、错误、信息类型图像-因此用户可能只对点击未完全成功的详细信息感兴趣 所以理想情况下,我可以编写这样的代码 UIImage imageSuccess = ImageLoader.DefaultRequestImage (new Uri ("f

是否有任何现有的扩展,或者在monotouch.dialog中直接向RootElement添加样式,方法与设置StyledStringElement样式类似

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

所以理想情况下,我可以编写这样的代码

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)
                        }
                    }}
            };

感谢您的帮助和指点。

由于MT.Dialog是开源的,您可以随意修改RootElement属性和构造函数。我不认为有任何东西可以立即满足您的需要,所以您必须扩展对话框以满足您的需要


另外,听起来您可能误解了RootElement的意图。RootElement只是所有节和元素所在的主容器。在RootElement上有一个公开指示器或徽章似乎没有意义,因为这不是RootElement的意图。我可能只是误解了你。但是,如果您想在元素上使用徽章等进行自定义样式设置,则可以创建从OwnerDrawneElement继承的自定义元素类,覆盖它的两个抽象方法。但是,在这样做之前,请阅读Miguel对类似问题的回答。

由于MT.Dialog是开源的,您可以随意修改RootElement属性和构造函数。我不认为有任何东西可以立即满足您的需要,所以您必须扩展对话框以满足您的需要


另外,听起来您可能误解了RootElement的意图。RootElement只是所有节和元素所在的主容器。在RootElement上有一个公开指示器或徽章似乎没有意义,因为这不是RootElement的意图。我可能只是误解了你。但是,如果您想在元素上使用徽章等进行自定义样式设置,则可以创建从OwnerDrawneElement继承的自定义元素类,覆盖它的两个抽象方法。但是,在这样做之前,请阅读Miguel对类似问题的回答。

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

    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;
        }   
    }

这个问题由来已久,但如果其他人遇到它,您可以对RootElement类进行子类化以添加图标。我的代码如下:

    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;
        }   
    }

感谢您的回答,我只是想知道在编写我自己的之前是否已经存在任何东西,但是因为根元素可以很容易地放置在其他部分中,并且在这些情况下它们已经有了默认显示,所以我只想更改此默认显示。现在,我分别创建每个子元素,并根据需要使用touch事件来显示它们,而不是让monotouch.dialog自动为我完成这一切。有一天我可能会考虑做我最初想要做的事情:)根元素需要设置样式-例如,当根元素用于定义子根时,要更改附件视图。谢谢你的回答,我只是想知道在编写我自己的,但由于根元素可以很容易地放置在其他部分等中,并且在这些情况下它们已经有了默认显示,所以我只想更改这个默认显示。现在,我分别创建每个子元素,并根据需要使用touch事件来显示它们,而不是让monotouch.dialog自动为我完成这一切。有一天,我可能会考虑做我最初想要做的事情:)根元素需要设置样式-例如,在使用根元素定义子根时,更改附件视图。