2012-04-12 55 views
0

我与Monotouch.Dialog工作,并遇到了此问题:MonoTouch.Dialog - rootElement的公司集团为空或不是一个RadioGroup中

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”,仍然得到相同的错误。我之前做过几次这样的事情,不能为我的生活弄清楚我做错了什么。有任何想法吗?两个RadioGroups不为空,如果我注释掉groupSortElement和nameDisplayElement,会出现一个空视图,告诉我这是与这些元素有关的事情。

回答

4

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