Query only

This sample demonstrates using the ArcGIS Runtime SDK for WPF for the retrieval and display of local data independent of any mapping. Specify the query in the TextBox control and click the Do Query Button to retrieve and display records.

In the code-behind, the sample uses a QueryTask to retrieve data from a local map service. The text input to the Query executed is the content of the TextBox control. A handler is specified for the task's ExecuteCompleted event. The method specified is called when the QueryTask has finished executing and the results are then added to a DataGrid control. A handler is also specified for the task's Failed event, which fires when there is a problem executing the query.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalQueryWithoutMap"
    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"/>
            <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>
        <Canvas x:Name="ResultsDisplayCanvas" HorizontalAlignment="Center" VerticalAlignment="Top" Width="547" Height="200" Margin="0,30,0,0" >
            <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="{StaticResource PanelGradient}" Canvas.Left="0" Canvas.Top="0" Width="547" Height="200" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Canvas.Left="10" Canvas.Top="20" Width="530" Height="170"  />
            <TextBlock x:Name="DataDisplayTitle" Text="Using Query tasks without maps" Foreground="White" FontSize="9" Canvas.Left="10" Canvas.Top="4" FontWeight="Bold" />
            <StackPanel Orientation="Horizontal" Margin="5,0,15,0" Canvas.Top="25" >
                <TextBlock Text="US State Name contains:" Margin="10,0,0,0" VerticalAlignment="Center"/>
                <TextBox x:Name="StateNameTextBox" Text="New" Height="23" HorizontalAlignment="Left" VerticalAlignment="Center" Width="125" TextWrapping="NoWrap" 
                     Margin="10,0,10,0" FontSize="12" Background="White" AcceptsReturn="False" />
                <Button x:Name="BtnQuery" Content="Do Query" Width="75" VerticalAlignment="Center" HorizontalAlignment="Right" Click="QueryButton_Click" Margin="0,0,10,0" Cursor="Hand" IsEnabled="False" />
            </StackPanel>

            <DataGrid x:Name="QueryDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="Column" Background="White"
                             IsReadOnly="True" Canvas.Left="10" Canvas.Top="50" Height="140" Width="530"
                             HorizontalScrollBarVisibility="Hidden">
                <DataGrid.Columns>
                    <DataGridTextColumn Width="85" Binding="{Binding Attributes[STATE_NAME]}" Header="State Name"/>
                    <DataGridTextColumn Width="110" Binding="{Binding  Attributes[SUB_REGION] }" Header="Region"/>
                    <DataGridTextColumn Width="45" Binding="{Binding  Attributes[STATE_FIPS] }" Header="FIPS"/>
                    <DataGridTextColumn Width="85" Binding="{Binding  Attributes[STATE_ABBR] }" Header="Abbreviation"/>
                    <DataGridTextColumn Width="103" Binding="{Binding  Attributes[POP2000] }" Header="Population 2000"/>
                    <DataGridTextColumn Width="102" Binding="{Binding  Attributes[POP2010] }" Header="Population 2010"/>
                </DataGrid.Columns>
            </DataGrid>
        </Canvas>
        <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