Select to view content in your preferred language

Need help with Find by attribute and zoom to selected

909
0
01-03-2013 01:44 PM
EssyJames
New Contributor
I am close to getting this, but I am at a point where I need some direction:



Issues thus far:
1. "Search For" is not showing up.
2. Clicking "Find" Button does not zoom to the feature. I need it to display a data grid (not sure of implementation yet) and then when i click on the row found, it should zoom to feature.

Ultimately, I want a combination of the zoom to selected found at http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#AttributeQuery and the search button from http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#Find

Expression Blend 4, Silverlight 4, ArcGIS API for Silverlight 2.4,Visual Studio 2010.

XAML Code:

<userControls:DraggableWindow IsOpen="True" x:Name="TextLocator" Grid.Row="1" Margin="3"  HorizontalContentAlignment="Stretch" ContentBackground="White"
                                      VerticalAlignment="Top" HorizontalAlignment="Right" IsDraggable="True" IsHeightResizeable="True" IsWidthResizeable="False" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                      Padding="0"  IsHeaderVisible="True" VerticalContentAlignment="Stretch" Title="Text Locator"  Opacity="100" Background="White">
            <i:Interaction.Triggers>
                <i:EventTrigger>
                    <actions:ToggleWindowVisibilityAction/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <Border CornerRadius="5" BorderBrush="Gray" BorderThickness="1" Background="White" HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch" Margin="5" Padding="5" >
                <Border.Effect>
                    <DropShadowEffect/>
                </Border.Effect>
                <Grid MinWidth="550" >
                    <!--Find By '13-->
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Search for" Foreground="White" Grid.Column="0"
                           HorizontalAlignment="Left" Height="24" VerticalAlignment="Center"
                           FontWeight="Bold" FontSize="12" Margin="20,8,5,0"/>
                    <TextBox x:Name="FindText" Background="White" Text="Colorado" Height="23" Width="100" HorizontalContentAlignment="Center" Grid.Column="1" />
                    <TextBlock Text="in the attributes of States, Rivers, or Cities:" Foreground="White"  Grid.Column="2"
                           HorizontalAlignment="Center" Height="24" VerticalAlignment="Center"
                           FontWeight="Bold" FontSize="12" Margin="5,8,5,0"/>
                    <Button x:Name="ExecuteButton" Content="Find" Width="75" Height="24" VerticalAlignment="Center" Click="ExecuteButton_Click" 
                        Margin="5,0,5,0" Cursor="Hand"  Grid.Column="3" />
                </Grid>
               
            </Border>

C#:
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            QueryTask queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map...");
            queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            queryTask.Failed += QueryTask_Failed;

             ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
            query.ReturnGeometry = true;//
            query.Where = string.Format("STATE_NAME LIKE '%{0}%'", FindText.Text);
            query.OutSpatialReference = Map.SpatialReference;
            query.OutFields.Add("*");

            queryTask.ExecuteAsync(query, "ZoomToFeature");
        }

Thanks in advance...
0 Kudos
0 Replies