Selecting a FeatureLayer Online

This sample demonstrates selecting individual features, using a rectangle, in a feature layer. Buttons for selecting new features, adding more features to the existing selection set, removing features from the existing selection set, and clearing all the features in the selection set are provided. The 'Keyboard' button enables the use of keyboard shortcuts to select features. Hold the Ctrl key and drag mouse to add new features to existing selection. Hold the Shift key and drag mouse to remove features from existing selection. Points in the FeatureLayer are rendered using a SimpleRenderer with a specified SimpleMarkerSymbol. MapTips on the FeatureLayer are provided to display attributes for a particular feature when the mouse is hovered over a selection.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.FeatureLayerSelection"
    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>
            <esri:Editor x:Key="MyEditor" Map="{Binding ElementName=MyMap}" LayerIDs="CensusDemographics"
             SelectionMode="Rectangle" ContinuousMode="True" />
            <esri:SimpleRenderer x:Key="YellowMarkerRenderer">
                <esri:SimpleRenderer.Symbol>
                    <esri:SimpleMarkerSymbol Size="20">
                        <esri:SimpleMarkerSymbol.Color>
                            <RadialGradientBrush>
                                <GradientStop Color="Yellow" Offset="0.578"/>
                                <GradientStop Color="#FF0E0D07" Offset="1"/>
                            </RadialGradientBrush>
                        </esri:SimpleMarkerSymbol.Color>
                    </esri:SimpleMarkerSymbol>
                </esri:SimpleRenderer.Symbol>
            </esri:SimpleRenderer>
            <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" esri:Editor.SnapDistance="0" Loaded="MyMap_Loaded" WrapAround="True" Background="#FFE3E3E3">
            <esri:ArcGISTiledMapServiceLayer ID="BaseLayer" 
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            <esri:ArcGISDynamicMapServiceLayer ID="CensusLayer"
                Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer" />
            <esri:FeatureLayer ID="CensusDemographics" 
                Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0"
                Mode="SelectionOnly"         
                Renderer="{StaticResource YellowMarkerRenderer}" 
                OutFields="FIPS,POP2000">
                <esri:FeatureLayer.MapTip>
                    <Border CornerRadius="10" BorderBrush="#FF222957" Background="AliceBlue" 
                            BorderThickness="3" Margin="0,0,15,15">
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" />
                        </Border.Effect>
                        <StackPanel Margin="7">
                            <TextBlock Text="{Binding [FIPS]}" FontWeight="Bold" Foreground="Black"  />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Population: " Foreground="Black" />
                                <TextBlock Text="{Binding [POP2000]}" Foreground="Black" />
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </esri:FeatureLayer.MapTip>
            </esri:FeatureLayer>
        </esri:Map>

        <Border Background="{StaticResource PanelGradient}" BorderThickness="1" CornerRadius="5"
                        HorizontalAlignment="Right"  VerticalAlignment="Top"
                        BorderBrush="Black" Margin="5">
            <Border.Effect>
                <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" />
            </Border.Effect>
            <StackPanel  x:Name="EditorToolStrip" Margin="0,5,5,0" DataContext="{StaticResource MyEditor}">
                <StackPanel x:Name="EditorTools" Orientation="Horizontal">
                    <Button x:Name="SelectButton" Margin="2" 
                            Content="New" 
                            Command="{Binding Select}" 
                            CommandParameter="New">
                    </Button>
                    <Button x:Name="AddSelectButton" Margin="2" 
                            Content="Add" 
                            Command="{Binding Select}" 
                            CommandParameter="Add">
                    </Button>
                    <Button x:Name="RemoveSelectButton" Margin="2"  Foreground="Black"
                            Content="Remove"
                            Command="{Binding Select}"
                            CommandParameter="Remove"
                            >
                    </Button>
                    <Button x:Name="EnableKeyboardButton" Margin="2"  Foreground="Black"
                            Content="Keyboard"
                            Command="{Binding Select}"
                            CommandParameter="Keyboard"
                            >
                    </Button>
                    <Button x:Name="ClearSelectionButton" Margin="2" Foreground="Black"
                            Content="Clear"
                            Command="{Binding ClearSelection}"
                                >

                    </Button>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox x:Name="ContinuousCheckBox" VerticalAlignment="Center" Margin="2"
                          IsChecked="{Binding Path=ContinuousMode, Mode=TwoWay}" 
                          Content="Continuous Action" />
                </StackPanel>
            </StackPanel>
        </Border>

        <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,10,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" 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" />
            <TextBlock x:Name="ResponseTextBlock" Text="The feature layer is in SelectionOnly mode.  Use the selection tools to select/unselect features (blue points) in the census demographics layer, an ArcGIS dynamic map service.  Selections are displayed as client graphics in the feature layer. When Keyboard is activated use the mouse to select new features.  Hold the Ctrl key and drag mouse to add new features to existing selection.  Hold the Shift key and drag mouse to remove features from existing selection." 
                 Width="200" TextAlignment="Left" Margin="30,20,20,30" TextWrapping="Wrap" Foreground="Black" />
        </Grid>
    </Grid>
</UserControl>



Sample code usage restrictions
5/16/2014