Feature layer selection using attribute query

683
1
10-29-2010 04:40 AM
BrianPangtay
Occasional Contributor
How does one perform an attribute query but display the results as a feature selection?

The samples display the results of a query by adding geometry to a graphics layer and clears the graphics layer when a new query is performed.

I would like to select the appropriate features in the feature layer instead so that features can be added/removed interactively from the selection after performing the initial selection via an attribute query.

Thanks for your help.
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
Sure this can be done by setting the graphic's Selected property to true. Provided your FeatureLayer is added to your map, you can do something like:
        private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            FeatureSet featureSet = args.FeatureSet;
            foreach (var item in featureSet.Features)
                item.Selected = true;
        }


The FeatureLayer itself has a Where property too you can use to filter. You can look at this sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerFiltering
0 Kudos