I have a query task that then populates a datagrid with the results. I'd like to be able to zoom to a particular feature when it's clicked on in the datagrid using the SelectionChanged event; (I'm using selectionchanged rather than the mousedown event because I'm doing this as an add-in to the Silverlight Viewer, and mousedown doesn't work; I've posted this to the Viewer forum as well, but sometimes in the past I've had more response in this forum.) I have it working with the results from a FindTask, using the findresult, but I can't quite figure out how to make it work with QueryTask and FeatureSet. Can anyone help? I've included the code below for the FindTask code, but I haven't been able to correctly alter it to work for the Query results.private void FindResults_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Highlight the graphic feature associated with the selected row DataGrid dataGrid = sender as DataGrid;int selectedIndex = dataGrid.SelectedIndex; if (selectedIndex > -1) { FindResult findResult = (FindResult)resultsDataGrid.SelectedItem; Graphic graphic = findResult.Feature; ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = findResult.Feature.Geometry.Extent;ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope( selectedFeatureExtent.XMin - 500, selectedFeatureExtent.YMin - 500, selectedFeatureExtent.XMax + 500, selectedFeatureExtent.YMax + 500);MapApplication.Current.Map.ZoomTo(displayExtent);string StrGeometry = findResult.Feature.Geometry.GetType().ToString();if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.MapPoint")) { graphic.Symbol = Circle; }if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polygon")) { graphic.Symbol = Fill; }if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polyline")) { graphic.Symbol = YellowLine; }GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics();graphicsLayer.Graphics.Add(graphic);}}
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.