【问题标题】:MonoTouch.Dialog - RootElement's Group is null or not a RadioGroupMonoTouch.Dialog - RootElement 的组为空或不是 RadioGroup
【发布时间】:2012-04-12 15:28:37
【问题描述】:

我正在使用 Monotouch.Dialog,但遇到了这个错误:

The RootElement's Group is null or is not a RadioGroup

我正在使用的代码如下,我添加了 cmets 告诉你变量的状态:

        var groupSortChoices = new RadioGroup("S", Extensions.GetValues<PeopleDirectoryGroupSortEnum>().IndexOfItem (i => i.Element == Extensions.GetValue<PeopleDirectoryGroupSortEnum>(Options.GroupAndSort)).Value);
// new RadioGroup("S", 0)
        var nameDisplayChoices = new RadioGroup("N", Extensions.GetValues<PeopleDirectoryNameDisplayEnum>().IndexOfItem (i => i.Element == Extensions.GetValue<PeopleDirectoryNameDisplayEnum>(Options.NameDisplay)).Value);
// new RadioGroup("N", 0)

        var gsElems = Extensions.GetValues<PeopleDirectoryGroupSortEnum>()
            .Select(e => new RadioElement(e, "S"))
            .ToArray();
// String[4] array of this enum's values
        var ndElems = Extensions.GetValues<PeopleDirectoryNameDisplayEnum>()
            .Select(e => new RadioElement(e, "N"))
            .ToArray();
// String[2] array of this enum's values

        groupSortElement = new RootElement("Grouping and Sorting", groupSortChoices)
        {
            new Section("Grouping and Sorting")
            {
                gsElems
            },
        };

        nameDisplayElement = new RootElement("Name Display", nameDisplayChoices)
        {
            new Section("Name Display")
            {
                ndElems
            }
        };

        var root = new RootElement("Directory Options")
        {
            groupSortElement,
            nameDisplayElement
        };

        this.Root = root;

我分解了这段代码来尝试调试它。错误肯定来自 groupSortElement 和 nameDisplayElement。我尝试在不使用“S”和“N”的情况下初始化我的组,但仍然出现相同的错误。我以前做过几次,但我一生都无法弄清楚我做错了什么。有任何想法吗?这两个 RadioGroup 不为空,如果我注释掉 groupSortElement 和 nameDisplayElement 会出现一个空视图,告诉我这与这些元素有关。

【问题讨论】:

    标签: c# xamarin.ios monotouch.dialog


    【解决方案1】:

    我想通了。我试图将 RootElements 直接添加到 RootElement,而不是添加到 RootElement 包含的部分中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多