1

This should be simple, but I cannot find any documentation on how to do it. I have a legend that is bound to my map that contains several layers. I do not want all of the layers to appear on my Legend so I am using LayerIDs. The problem is that I do not know how to use multiple ones in the LayerIDs. Below is my code:

XAML(Legend):

<esri:Legend Map="{Binding ElementName=MyMap}"
                         LayerIDs="CalvertCity, WaterValves"
                         LayerItemsMode="Tree"
                         ShowOnlyVisibleLayers="False">
                    <esri:Legend.MapLayerTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox Content="{Binding Label}"
                                    IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                                    IsEnabled="{Binding IsInScaleRange}" >
                                </CheckBox>
                                <Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" />
                            </StackPanel>
                        </DataTemplate>
                    </esri:Legend.MapLayerTemplate>
                    <esri:Legend.LayerTemplate>
                        <DataTemplate>
                            <CheckBox Content="{Binding Label}"
                            IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                            IsEnabled="{Binding IsInScaleRange}" >
                            </CheckBox>
                        </DataTemplate>
                    </esri:Legend.LayerTemplate>
                </esri:Legend>

XAML(ESRI Maps):

<esri:Map x:Name="MyMap" Background="#FFE3E3E3" WrapAround="True"  MouseRightButtonDown="MyMap_MouseRightButtonDown" Extent="-9834972.92753924,4441899.425293319,-9833977.88119163, 4442762.485358352">
                <esri:Map.Layers>
                    <esri:ArcGISTiledMapServiceLayer ID="MyLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
                    <esri:GraphicsLayer ID="CandidateGraphicsLayer">
                        <esri:GraphicsLayer.MapTip>
                            <Grid>
                                <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="#77FF0000" Margin="0,0,0,5" >
                                    <Rectangle.Effect>
                                        <DropShadowEffect/>
                                    </Rectangle.Effect>
                                </Rectangle>
                                <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
                                <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="30,20,30,30">
                                    <TextBlock Text="{Binding [Address]}" HorizontalAlignment="Left" Foreground="Black" />
                                </StackPanel>
                            </Grid>
                        </esri:GraphicsLayer.MapTip>
                    </esri:GraphicsLayer>
                    <esri:ArcGISDynamicMapServiceLayer ID="CalvertCity" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer"/>
                    <esri:FeatureLayer ID="WaterValves" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer/0" Renderer="{StaticResource MySimpleRenderer}"
                                                  OutFields="WVAL_ID,SIZE,WVAL_USE,WVAL_TYPE,OPENS,TURNS" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"/>
                </esri:Map.Layers>                
            </esri:Map>

1 Answer 1

1

I accidentally answered my own question. I put the comma in there to explain that I wanted both of those layers and that is actually how you do it.

LayerIDs="CalvertCity, WaterValves"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.