Layer List Online

This sample includes a Map with one tiled map service layer and two dynamic map service layers. A layer list shows the layer (service) name, a visibility check box, and a slider to adjust opacity.
Element binding in XAML is used to populate the ListBox contents and enable runtime interactivity between layers and UI elements in the layer.
Download Sample Application<UserControl x:Class="ArcGISWPFSDK.LayerList" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <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="-15000000,2000000,-7000000,8000000" Background="#FFE3E3E3"> <esri:ArcGISTiledMapServiceLayer ID="Basemap" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer"/> <esri:ArcGISDynamicMapServiceLayer ID="USA" Url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer" /> </esri:Map> <Border Background="{StaticResource PanelGradient}" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20" Padding="5" BorderBrush="Black" > <ListBox x:Name="MyList" ItemsSource="{Binding ElementName=MyMap, Path=Layers}" Margin="3" Background="#DDFFFFFF"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="2"> <!--Layer visibility checkbox--> <CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" /> <!--Opacity slider--> <Slider Minimum="0" Maximum="1" Width="30" Value="{Binding Opacity, Mode=TwoWay}" Height="22" /> <!--Layer name--> <TextBlock Text="{Binding ID, Mode=OneWay}" Margin="5,0,2,0" > <!-- Tooltip on hover--> <ToolTipService.ToolTip> <StackPanel MaxWidth="400"> <TextBlock FontWeight="Bold" Text="{Binding CopyrightText}" TextWrapping="Wrap" /> <TextBlock Text="{Binding Description}" TextWrapping="Wrap" /> </StackPanel> </ToolTipService.ToolTip> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Border> </Grid> </UserControl>
5/16/2014