<esri:Legend.LayerTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <!--Busy indicator--> <ContentControl ContentTemplate="{StaticResource BusyIndicatorTemplate}" Visibility="{Binding BusyIndicatorVisibility}"/> <CheckBox ToolTipService.ToolTip="{Binding localizationResources.strShowlayer}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" IsEnabled="{Binding IsInScaleRange}" > </CheckBox> <Image x:Name="imgZoomTo" Source="/MIB.Map.Presentation;component/Images/zoom.png" DataContext="{Binding ElementName=Toc,Path=ViewModel}" ToolTipService.ToolTip="Zoom" Tag="{Binding Content, ElementName=lblLayerName}" Cursor="Hand"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <i:InvokeCommandAction Command="{Binding ZoomToCommand}" CommandParameter="{Binding ElementName=imgZoomTo}" /> </i:EventTrigger> </i:Interaction.Triggers> </Image> <RadioButton x:Name="rbLayer" DataContext="{Binding ElementName=Toc,Path=ViewModel}" IsChecked="False" GroupName="grpSelectedLayer" Tag="{Binding Content, ElementName=lblLayerName}" ToolTipService.ToolTip="{Binding localizationResources.strSelectLayer}" Content="" > <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <i:InvokeCommandAction Command="{Binding RadioButtonCheckedCommand}" CommandParameter="{Binding ElementName=rbLayer}" /> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <sdk:Label x:Name="lblLayerName" Content="{Binding Label}"> <ToolTipService.ToolTip> <StackPanel MaxWidth="400"> <TextBlock FontWeight="Bold" Text="{Binding Layer.ID}" TextWrapping="Wrap" /> <TextBlock FontWeight="Bold" Text="{Binding Label}" TextWrapping="Wrap" /> <TextBlock Text="{Binding Description}" TextWrapping="Wrap" /> <TextBlock Text="{Binding MinimumResolution, StringFormat='Minimum Resolution : {0:F6}'}" /> <TextBlock Text="{Binding MaximumResolution, StringFormat='Maximum Resolution : {0:F6}'}" /> </StackPanel> </ToolTipService.ToolTip> </sdk:Label> </StackPanel> </DataTemplate> </esri:Legend.LayerTemplate>
One way that I use for certain things is to set the Visibility="{Binding Tag}" for the radio button and change the layers tag to xxxx.Tag = Visibility.Collapsed or Visibility.Visible in the Code Behind.
esri:Legend Map="{Binding ElementName=MyMap}"
LayerIDs="......."
LayerItemsMode="Tree"
ShowOnlyVisibleLayers="False"
Refreshed="Legend_Refreshed"
LayoutUpdated="Legend_LayoutUpdated"
Background="#FF1B1D1D"
Foreground="White" Opacity="0.75" Grid.Row="1" >
<RadioButton x:Name="rbLayer"
DataContext="{Binding ElementName=Toc,Path=ViewModel}"
IsChecked="False"
GroupName="grpSelectedLayer"
Tag="{Binding Content, ElementName=lblLayerName}"
ToolTipService.ToolTip="{Binding localizationResources.strSelectLayer}"
Visibility="{Biniding Tag}"
Content="" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Checked">
<i:InvokeCommandAction Command="{Binding RadioButtonCheckedCommand}"
CommandParameter="{Binding ElementName=rbLayer}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
if (e.LayerItem.Layer.ID == "SomeLayerName") e.LayerItem.Tag = Visibility.Collapsed;