//create new group layer & set ID GroupLayer siteIntentGrLyr = new GroupLayer(); siteIntentGrLyr.ID = "Site Intent Group Layer"; //access indidual feature layers from the collection & add them to the siteIntentGrLyr Layer plantFeatLyr = featLyrList.FirstOrDefault(x => x.LayerInfo.Name == "Plant"); Layer otherFeatPointFeatLyr = featLyrList.FirstOrDefault(x => x.LayerInfo.Name == "Other_Features_Point"); Layer Other_Feature_LineFeatLyr = featLyrList.FirstOrDefault(x => x.LayerInfo.Name == "Other_Features_Line"); Layer Other_Feature_BoundaryFeatLyr = featLyrList.FirstOrDefault(x => x.LayerInfo.Name == "Other_Feature_Boundary"); //add child feature layers to the group layer siteIntentGrLyr.ChildLayers.Add(plantFeatLyr); //on this very first line, I get error. siteIntentGrLyr.ChildLayers.Add(otherFeatPointFeatLyr); siteIntentGrLyr.ChildLayers.Add(Other_Feature_LineFeatLyr); siteIntentGrLyr.ChildLayers.Add(Other_Feature_BoundaryFeatLyr);
I am adding the child layer to the Group layer in the code behind (adding them in XAML is not feasible for me)and getting the exception "Value does not fall within the expected range".