Runtime SDK for Mobile 3.1 - Selecting features

2602
1
11-29-2012 01:26 PM
ChrisSeabrooke
New Contributor III
We are updating from Windows Mobile 10 to Runtime SDK for Mobile 3.1. In our Mobile 10 application, the user can search for a feature by selecting attributes from a combo box. The results display in a listview. The user can select an item and click on a menu item to zoom to the selected feature on the map.

In Mobile 10, the code behind the menu zoom click event sets the feature as selected on the map, then zooms the map to an envelope created using the feature geometry. The code to select the feature is:

SelectionGraphicLayer lyr = _map.MapGraphicLayers.GetFirstLayerOfType(typeof(SelectionGraphicLayer)) as SelectionGraphicLayer;
lyr.SelectedGeometries.Add(featureDataRow.Geometry);

I'm having trouble setting a feature as selected using the RuntimeSDK v3.1. In v3.1, the SelectionGraphicLayer is a  MapGraphicLayer which takes Graphics (not geometries). Graphics is a read-only list. So I can't add to the SelectionGraphicLayer like I did in Mobile 10.
public IList<MapGraphic> Graphics {get;}

If you are selecting features in code, please provide an example of how to do it.
0 Kudos
1 Reply
ChrisSeabrooke
New Contributor III
Figured out how to select feature. But now the feature layer is not displaying the feature when the selection is cleared. Code to select feature:
MapGraphic locGraphic = new MapGraphic();

locGraphic.Symbol = new ESRI.ArcGIS.Mobile.FeatureCaching.SimpleMarkerSymbol(Color.Purple, 3, Color.Purple, 3, SimpleMarkerStyle.Circle);
locGraphic.Geometry = featureDataRow.Geometry;
frmMap.selectionMapAction.SelectionFeatureSources.Clear();
frmMap.selectionMapAction.SelectionFeatureSources.Add(featureLayer);
frmMap.selectionMapAction.SelectionGraphicLayer.Graphics.Add(locGraphic;

This code clears the selection graphic but is also causing the feature layer graphic to not display.
frmMap.selectionMapAction.SelectionFeatureSources.Clear();
frmMap.selectionMapAction.SelectionFeatureSources.Add(featureLayer);
frmMap.selectionMapAction.SelectionGraphicLayer.Graphics.Add(locGraphic);

Does anyone know how to do this so the features from the feature source layer display when the graphich layer is cleared?
0 Kudos