Select to view content in your preferred language

C# alter Identify Task output

2036
1
12-30-2011 07:22 AM
NigelAlford
Occasional Contributor
"ESRI QUOTE :Each FindResult contains the feature found, the name and ID of the layer containing the feature, the name of the field containing the matching value, and other information."
what would I alter the find result to display the "other information"/columns associated with the identified feature?

Thanks in advance

private void ExecuteButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
         GraphicsLayer graphicsLayer = MyMap.Layers["Results"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            FindTask findTask = new FindTask("http://esoc1d/ArcGISTEST/rest/services/ITGIS/LOCOMOTIVE_LOCATION/MapServer");
            //added to label features on map and show messagebox if query was empty 
            //see line:1132
            findTask.ExecuteCompleted += new EventHandler<FindEventArgs>(findTask_ExecuteCompleted);
            findTask.Failed += FindTask_Failed;

            FindParameters findParameters = new FindParameters();
            // Layer ids to search
            findParameters.LayerIds.AddRange(new int[] { 5, 6, 7, 8 });
            // Fields in layers to search
            findParameters.SearchFields.AddRange(new string[] { "LOC_INIT", "LOC_NUM", "DTM", "LOC_TYPE", "FUEL_LEVEL", "ENGINE_ONOFF", "ENGINE_TEMP" });
            // Return features in map's spatial reference
            findParameters.SpatialReference = MyMap.SpatialReference;

             // Bind data grid to find results.  Bind to the LastResult property which returns a list
            // of FindResult instances.  When LastResult is updated, the ItemsSource property on the 
            // will update.  
            Binding resultFeaturesBinding = new Binding("LastResult");
            resultFeaturesBinding.Source = findTask;
            QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding);
            

            findParameters.SearchText = FindText.Text;
            findTask.ExecuteAsync(findParameters);

            // Since binding to DataGrid, handling the ExecuteComplete event is not necessary.
        }

        void findTask_ExecuteCompleted(object sender, FindEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["Results"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            if (e.FindResults.Count > 0)
            {
                foreach (FindResult result in e.FindResults)
                {
                    result.Feature.Symbol = LayoutRoot.Resources["Sample"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                    graphicsLayer.Graphics.Add(result.Feature);
                }
            }
            else
            {
                MessageBox.Show("No features found");
            }
        }
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
FindResult contain the following information: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tasks.Find...

You can use FindTask along with IdentifyTask to show more information about each feature. Please refer to the following SDK samples:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Find
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify
0 Kudos