Select to view content in your preferred language

Legend control: any way to leave some layers from the map out?

902
5
04-04-2011 11:33 AM
SuiHuang
Frequent Contributor
Hi Everybody:

    I am using a Legend element to list all the layers in a map. However, I don't want the invisible graphic layer to show up in the legend. Is there any way for me to do that?
    Following is the code I have now (listing the graphic layer).
================================================
<esri:Legend x:Name="Legend" Map="{Binding ElementName=Map}" LayerItemsMode="Flat"  ShowOnlyVisibleLayers="False">
<esri:Legend.MapLayerTemplate>
   <DataTemplate>
      <StackPanel Orientation="Horizontal">
           <CheckBox Content="" IsChecked="{Binding IsEnabled, Mode=TwoWay}" ></CheckBox>
           <TextBlock Text="{Binding Label}"></TextBlock>
      </StackPanel>
   </DataTemplate>
</esri:Legend.MapLayerTemplate>
</esri:Legend>
================================================

Thank you.
0 Kudos
5 Replies
SuiHuang
Frequent Contributor
I set the LayerIDs property at the startup, and it works now.


Hi Everybody:

    I am using a Legend element to list all the layers in a map. However, I don't want the invisible graphic layer to show up in the legend. Is there any way for me to do that?
    Following is the code I have now (listing the graphic layer).
================================================
<esri:Legend x:Name="Legend" Map="{Binding ElementName=Map}" LayerItemsMode="Flat"  ShowOnlyVisibleLayers="False">
<esri:Legend.MapLayerTemplate>
   <DataTemplate>
      <StackPanel Orientation="Horizontal">
           <CheckBox Content="" IsChecked="{Binding IsEnabled, Mode=TwoWay}" ></CheckBox>
           <TextBlock Text="{Binding Label}"></TextBlock>
      </StackPanel>
   </DataTemplate>
</esri:Legend.MapLayerTemplate>
</esri:Legend>
================================================

Thank you.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
What was the problem with setting 'ShowOnlyVisibleLlayers' to true?
0 Kudos
SuiHuang
Frequent Contributor
Hi dbroux:

    The problem of setting "ShowOnlyVisibleLayers" is that: if I uncheck the checkbox binded to the visible property of the layer, then then layer will disappear immediately from the table of content, such that I cannot get it back into display.


What was the problem with setting 'ShowOnlyVisibleLlayers' to true?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The problem of setting "ShowOnlyVisibleLayers" is that: if I uncheck the checkbox binded to the visible property of the layer, then then layer will disappear immediately from the table of content, such that I cannot get it back into display.

I agree but what is the difference with setting LayerIds property at startup?
0 Kudos
SuiHuang
Frequent Contributor
I agree but what is the difference with setting LayerIds property at startup?


If I set the LayerIds property at startup, the legend item of the layer will not disappear even if I temporarily make the layer invisible from the map.
0 Kudos