Hello,I've added an <esri:FeatureLayer> to my map and I would like for the users to be able to click the <esri:Legend> to show and hide it. The Legend works fine with the ArcGISDynamicMapServiceLayer but it ignores the FeatureLayer. Is there a way to make the FeatureLayer appear in the Legend?Thank you.Here is a sample of my XAML showing the Legend and Map.
<!-- Legend -->
<Grid x:Name="MapLegendPanelGrid" ShowGridLines="False" Width="auto" Height="auto"
HorizontalAlignment="Left" Margin="0,10,0,0" Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="0"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<sdk:GridSplitter x:Name="grsplMapLegendPanelSplitter" Grid.Row="2" Grid.Column="0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
Height="5" Background="{StaticResource BaseColor}">
</sdk:GridSplitter>
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" Text="Layers" Margin="2,0,0,5" />
</StackPanel>
<ScrollViewer Width="395" BorderThickness="0" Height="Auto" HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.Column="0">
<esri:Legend Map="{Binding ElementName=Map}" Name="MapLegend" LayerItemsMode="Tree"
ShowOnlyVisibleLayers="False" Refreshed="MapLegend_Refreshed"
ScrollViewer.VerticalScrollBarVisibility="Hidden" Background="White" Width="390" Height="auto">
<esri:Legend.MapLayerTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Content="{Binding Label}" Width="220" 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>
</ScrollViewer>
</Grid>
<!-- Map -->
<esri:Map x:Name="Map" Background="{StaticResource MapBackgroundColor}" WrapAround="true"
MinimumResolution=".01" IsLogoVisible="False" ExtentChanged="Map_ExtentChanged"
Grid.Column="1" SnapToLevels="True">
<esri:Map.Extent>
<esri:Envelope XMax="{StaticResource MapXMax}" XMin="{StaticResource MapXMin}"
YMax="{StaticResource MapYMax}" YMin="{StaticResource MapYMin}">
<esri:Envelope.SpatialReference>
<esri:SpatialReference WKID="{StaticResource MapWKID}" />
</esri:Envelope.SpatialReference>
</esri:Envelope>
</esri:Map.Extent>
<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer ID="ArcGISBaseLayerTiled" Url="{StaticResource BasemapUrlAerialUsa}"
MinimumResolution="0.224896283" InitializationFailed="Layer_InitializationFailed" />
<esri:ArcGISDynamicMapServiceLayer ID="ArcGISBaseLayerDynamic" Url="http://. . . mapservice"
MinimumResolution="0.224896283" InitializationFailed="Layer_InitializationFailed" />
<esri:FeatureLayer ID="MyFeatureLayer"
Url="http://. . ./FeatureServer/0"
MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"
DisableClientCaching="True"
Mode="OnDemand"
SelectionColor="#FFFFFF00"
OutFields="*"
/>
</esri:Map.Layers>
</esri:Map>