Select to view content in your preferred language

Nested Legend -

3718
10
Jump to solution
07-20-2012 05:14 AM
LakshmananVenkatesan
Frequent Contributor
Hello
I have a map document which has nested groups like below and published as dynamic service layer

Layers
   Group A
     A.1
     A.2
     A.3
   Group B
     B.1
     B.2
   Layer C
   Layer D
   Group E
       Group E1
          E1.1
          E1.2
       Group E2
         E2.1
         E2.2
   Layer F

using sliverlight API , I want to do below  actions
a) remove layers B.2 , Layer D, E1.2, E2.2     
b) Based on user preferences - set these layers to visible E1.1 , E2.1, Layer C,
c) All other available layerrs set to invisible

I have just provided a layers names which needs to be removed and make visible/invisible. How to acheive this?. Bascically am
looking for recursive loop kind of logic to make all these changes and display in legend. Please give me an psuedo code.
0 Kudos
10 Replies
DominiqueBroux
Esri Frequent Contributor
A.2 layer is visble in map. But A.2 has been removed successfully on legend refreshed event


Removing a layerItem from the legend doesn't change anything for the layer or sublayer visibility in the map.

You have to do it by code at the same time you remove the layerItem.
Something like:
foreach (var pair in toDeletes) {     var parentLayerItem = pair.Item1;     var layerItemToDelete = pair.Item2;      parentLayerItem.LayerItems.Remove(layerItemToDelete);      Layer layer = parentLayerItem.Layer;     int subID = layerItemToDelete.SubLayerID;     if (layer is ISublayerVisibilitySupport && subID > 0)*         (layer as ISublayerVisibilitySupport).SetLayerVisibility(subID, false);     parentLayerItem.Layer.SetSublayerViisbility(layerItemToDelete.SublayerId, false); }
0 Kudos