C# Dialog-RootElement的组为null或不是RadioGroup

C# Dialog-RootElement的组为null或不是RadioGroup,c#,xamarin.ios,monotouch.dialog,C#,Xamarin.ios,Monotouch.dialog,我正在使用Monotouch.Dialog,遇到以下错误: The RootElement's Group is null or is not a RadioGroup 我使用的代码如下所示,我添加了注释,告诉您变量的状态: var groupSortChoices = new RadioGroup("S", Extensions.GetValues<PeopleDirectoryGroupSortEnum>().IndexOfItem (i => i.Ele

我正在使用Monotouch.Dialog,遇到以下错误:

The RootElement's Group is null or is not a RadioGroup
我使用的代码如下所示,我添加了注释,告诉您变量的状态:

        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,就会出现一个空视图,告诉我这与这些元素有关。

我找到了答案。我试图将RootElement直接添加到RootElement中,而不是添加到由RootElement包含的节中。

我找到了答案。我试图将RootElements直接添加到RootElement中,而不是添加到由RootElement包含的节中