I've added some layers to Folders in AGX. However, now I need to remove the entire folder. I'm getting unexpected results when attempting this. For some of my Folders the entire folder is being removed but for others the Folder isn't being removed. Two folders are created and each contain a set of layers. Once I add the two folders with layers they are added. Then, the second time I load the layers I try to remove the current Folders but only one of them will be removed. Here's the very simple code to remove the folders:
IEnumerable<MapItem> mapItems = mapDisplay.Map.Descendants;
foreach (MapItem mi in mapItems)
{
if (mi is Folder)
mi.RemoveFromParent();
}
I've also tried using the following code:
MapItemCollection collection = mapDisplay.Map.ChildItems;
for (int i = 0; i <= collection.Count-1; i++)
{
if (collection is Folder)
collection.Remove(collection);
}
If I use mapDisplay.Map.ChildItems.Clear() all the Folders are removed but I need a little more control over what Folders are removed.
Any help is appreciated. This seems like a bug in AGX.