0

I'm working with Monotouch.Dialog, and running into this error:

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

The code I'm working with is as follows, I've added comments telling you the state of the variables:

        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;

I broke this code down to try to debug it. The error is definitely coming from groupSortElement and nameDisplayElement. I have tried initializing my groups without using "S" and "N" and still get the same error. I've done this a few times before and can't for the life of me figure out what I am doing wrong. Any ideas? The two RadioGroups are not null, and if I comment out the groupSortElement and the nameDisplayElement an empty view comes up, telling me it's something to do with these elements.

Derreck Dean
  • 3,708
  • 1
  • 26
  • 45

1 Answers1

4

I figured it out. I was trying to add RootElements directly to a RootElement, not into a Section contained by a RootElement.

Derreck Dean
  • 3,708
  • 1
  • 26
  • 45