Attribute Query

This sample demonstrates using the ArcGIS Runtime SDK for WPF to perform an attribute query on local data, add the results to the map and a DataGrid, and zoom to the result. To use the sample, select a state from the drop-down menu in the upper right corner of the application.

In the sample's code-behind, a QueryTask is used to query a states local map service based on the name selected in the drop-down menu. The result is then added as a Graphic to the map and displayed in the DataGrid.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalAttributeQuery"
             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" Background="White">
        <Grid.Resources>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#500000FF" BorderBrush="Blue" BorderThickness="1" />
            <esri:PictureMarkerSymbol x:Key="DefaultPictureSymbol" OffsetX="35" OffsetY="35" 
                 Source="\Assets\Images\i_about.png" />
            <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" MinimumResolution="2445.98490512499" >
            <esri:Map.Layers>
                <esri:ArcGISLocalTiledLayer ID="BaseMap" Path="..\\Data\\TPKs\\Topographic.tpk"/>
                <esri:ArcGISLocalDynamicMapServiceLayer Path="..\\Data\\MPKS\\USCitiesStates.mpk"/>
                <esri:GraphicsLayer ID="MyGraphicsLayer" />
            </esri:Map.Layers>
        </esri:Map>
        <StackPanel Orientation="Vertical" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Top" >
            <Grid x:Name="QueryGrid" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,7,7,0" >
                <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5">
                    <Rectangle.Effect>
                        <DropShadowEffect/>
                    </Rectangle.Effect>
                </Rectangle>
                <TextBlock x:Name="DataDisplayTitleBottom" Text="Query a layer" Foreground="White" FontSize="12" 
                      Margin="10,3,0,5" />
                <StackPanel Orientation="Vertical" Margin="15" HorizontalAlignment="Center" VerticalAlignment="Top" >
                    <ComboBox x:Name="QueryComboBox" MinWidth="150" SelectionChanged="QueryComboBox_SelectionChanged"
                         Margin="5,10,5,5" >
                    </ComboBox>
                    <ScrollViewer x:Name="DataGridScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"  
                         Width="230" MaxHeight="340" Visibility="Collapsed">
                        <DataGrid x:Name="QueryDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="None" 
                              Background="White">
                            <DataGrid.Columns>
                                <DataGridTextColumn Width="95" Binding="{Binding Path=Key}" FontWeight="Bold" IsReadOnly="True"/>
                                <DataGridTextColumn Width="115" Binding="{Binding Path=Value}" IsReadOnly="True"/>
                            </DataGrid.Columns>
                        </DataGrid>
                    </ScrollViewer>
                </StackPanel>
            </Grid>
        </StackPanel>
        <ProgressBar x:Name="MyProgressBar" IsIndeterminate="True" VerticalAlignment="Bottom" Width="200" Height="20" Margin="10" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014