Attribute Query Online

This sample demonstrates performing an attribute query, adding the results to the map and a DataGrid, and zooming 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 map service layer 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.AttributeQuery"
    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>
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#500000FF" BorderBrush="Blue" BorderThickness="1" />
            <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" Extent="-15000000,2000000,-7000000,8000000" WrapAround="True">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
                      Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
            <esri:GraphicsLayer ID="MyGraphicsLayer" />
        </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>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014