Index: Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs =================================================================== diff -u -rd5148ec8ecdd565af77d2e78fb93a7cdc8e6cfe5 -r817ccce7f9bd089ee86aba9dc7d95deaecdbda35 --- Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision d5148ec8ecdd565af77d2e78fb93a7cdc8e6cfe5) +++ Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 817ccce7f9bd089ee86aba9dc7d95deaecdbda35) @@ -360,7 +360,8 @@ { var mapDataCollection = (MapDataCollection) context.WrappedData; - Dictionary childStates = MapDataCollectionHelper.GetChildVisibilityStates(mapDataCollection); + Dictionary childStates = mapDataCollection.GetFeatureBasedMapDataRecursively().ToDictionary(child => child, child => child.IsVisible); + Dictionary nestedCollectionVisibilityStates = MapDataCollectionHelper.GetNestedCollectionVisibilityStates(mapDataCollection); MapDataCollectionVisibility collectionOriginalVisibility = mapDataCollection.GetVisibility(); @@ -369,13 +370,25 @@ mapDataCollection.NotifyObservers(); NotifyMapDataCollectionChildren(childStates); + NotifyNestedMapDataCollections(nestedCollectionVisibilityStates); NotifyMapDataParents(context); } - private static void NotifyMapDataCollectionChildren(Dictionary childStates) + private static void NotifyNestedMapDataCollections(Dictionary childStates) { - foreach (KeyValuePair child in childStates) + foreach (KeyValuePair child in childStates) { + if (child.Key.GetVisibility() != child.Value) + { + child.Key.NotifyObservers(); + } + } + } + + private static void NotifyMapDataCollectionChildren(Dictionary childStates) + { + foreach (KeyValuePair child in childStates) + { if (child.Key.IsVisible != child.Value) { child.Key.NotifyObservers(); Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapDataCollectionContextTreeNodeInfoTest.cs =================================================================== diff -u -rd5148ec8ecdd565af77d2e78fb93a7cdc8e6cfe5 -r817ccce7f9bd089ee86aba9dc7d95deaecdbda35 --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapDataCollectionContextTreeNodeInfoTest.cs (.../MapDataCollectionContextTreeNodeInfoTest.cs) (revision d5148ec8ecdd565af77d2e78fb93a7cdc8e6cfe5) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapDataCollectionContextTreeNodeInfoTest.cs (.../MapDataCollectionContextTreeNodeInfoTest.cs) (revision 817ccce7f9bd089ee86aba9dc7d95deaecdbda35) @@ -286,8 +286,8 @@ } [Test] - [TestCase(true, 3)] - [TestCase(false, 1)] + [TestCase(true, 4)] + [TestCase(false, 3)] public void OnNodeChecked_WithContext_NotifyObserversOfChangedChildrenOnly(bool initialVisibility, int expectedNotifications) { // Setup @@ -300,8 +300,14 @@ { IsVisible = initialVisibility }; + var featureBasedMapData3 = new TestFeatureBasedMapData + { + IsVisible = initialVisibility + }; var nestedMapDataCollection = new MapDataCollection("nested"); nestedMapDataCollection.Add(featureBasedMapData1); + nestedMapDataCollection.Add(featureBasedMapData3); + var mapDataCollection = new MapDataCollection("test"); mapDataCollection.Add(nestedMapDataCollection); mapDataCollection.Add(featureBasedMapData2); @@ -311,6 +317,7 @@ nestedMapDataCollection.Attach(observer); featureBasedMapData1.Attach(observer); featureBasedMapData2.Attach(observer); + featureBasedMapData3.Attach(observer); // Call info.OnNodeChecked(context, null);