SubLayer List Online

This sample contains a Map with one tiled map service layer and one dynamic map service layer. A layer list shows the layers (sublayers) within the dynamic map service and a visibility check box. Element binding in XAML is used to populate the ListBox contents and enable runtime interactivity between sublayers and UI elements in the layer list.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.SubLayerList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client">
    <Grid x:Name="LayoutRoot" >
        <Grid.Resources>
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" WrapAround="True" Extent="-14930991.170,3611744.037,-11348896.882,5340571.181">
            <esri:ArcGISTiledMapServiceLayer ID="Street Map" 
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer"/>
            <esri:ArcGISDynamicMapServiceLayer ID="DynamicLayerCalifornia" x:Name="DynamicLayerCalifornia"  
                    Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer" Initialized="ArcGISDynamicMapServiceLayer_Initialized"/>
        </esri:Map>

        <Border Background="{ StaticResource PanelGradient}" BorderThickness="1" CornerRadius="5"
                HorizontalAlignment="Right"  VerticalAlignment="Top"
                Margin="20" Padding="10" BorderBrush="Black" >
            <StackPanel>
                <TextBlock Text="Layers in California service" FontWeight="Bold" Foreground="White" />
                <ListBox x:Name="List" ItemsSource="{Binding ElementName=DynamicLayerCalifornia, Path=Layers, Mode=OneWay}" Background="#DDFFFFFF">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox Margin="2" Content="{Binding Name, Mode=OneWay}" 
                                          IsChecked="{Binding DefaultVisibility, Mode=OneWay}" 
                                          Tag="DynamicLayerCalifornia"
                                          ClickMode="Press" Click="CheckBox_Click"  />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
        </Border>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014