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」を使用せずにグループを初期化しようとしましたが、それでも同じエラーが発生します。私はこれを数回前に行ったことがありますが、私の人生では何が間違っているのか理解できません。何か案は?2 つの RadioGroup は null ではなく、groupSortElement と nameDisplayElement をコメント アウトすると、空のビューが表示され、これらの要素に関係があることがわかります。