<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Zoom to query results from datagrid in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/zoom-to-query-results-from-datagrid/m-p/233027#M5988</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.)&amp;nbsp; 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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;private void FindResults_SelectionChanged(object sender, SelectionChangedEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; // Highlight the graphic feature associated with the selected row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; DataGrid dataGrid = sender as DataGrid;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int selectedIndex = dataGrid.SelectedIndex;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (selectedIndex &amp;gt; -1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; FindResult findResult = (FindResult)resultsDataGrid.SelectedItem;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Graphic graphic = findResult.Feature;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = findResult.Feature.Geometry.Extent;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.XMin - 500,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.YMin - 500,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.XMax + 500,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.YMax + 500);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MapApplication.Current.Map.ZoomTo(displayExtent);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;string StrGeometry = findResult.Feature.Geometry.GetType().ToString();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.MapPoint"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.Symbol = Circle;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polygon"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.Symbol = Fill;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polyline"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.Symbol = YellowLine;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphicsLayer.ClearGraphics();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphicsLayer.Graphics.Add(graphic);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Aug 2013 19:25:40 GMT</pubDate>
    <dc:creator>KarenEllett</dc:creator>
    <dc:date>2013-08-08T19:25:40Z</dc:date>
    <item>
      <title>Zoom to query results from datagrid</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/zoom-to-query-results-from-datagrid/m-p/233027#M5988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.)&amp;nbsp; 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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;private void FindResults_SelectionChanged(object sender, SelectionChangedEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; // Highlight the graphic feature associated with the selected row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; DataGrid dataGrid = sender as DataGrid;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int selectedIndex = dataGrid.SelectedIndex;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (selectedIndex &amp;gt; -1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; FindResult findResult = (FindResult)resultsDataGrid.SelectedItem;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Graphic graphic = findResult.Feature;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = findResult.Feature.Geometry.Extent;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.XMin - 500,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.YMin - 500,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.XMax + 500,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; selectedFeatureExtent.YMax + 500);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MapApplication.Current.Map.ZoomTo(displayExtent);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;string StrGeometry = findResult.Feature.Geometry.GetType().ToString();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.MapPoint"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.Symbol = Circle;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polygon"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.Symbol = Fill;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polyline"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphic.Symbol = YellowLine;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; graphicsLayer.ClearGraphics();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphicsLayer.Graphics.Add(graphic);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 19:25:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/zoom-to-query-results-from-datagrid/m-p/233027#M5988</guid>
      <dc:creator>KarenEllett</dc:creator>
      <dc:date>2013-08-08T19:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to query results from datagrid</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/zoom-to-query-results-from-datagrid/m-p/233028#M5989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;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.)&amp;nbsp; 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.&lt;BR /&gt; &lt;BR /&gt;private void FindResults_SelectionChanged(object sender, SelectionChangedEventArgs e)&lt;BR /&gt; {&lt;BR /&gt; // Highlight the graphic feature associated with the selected row&lt;BR /&gt; DataGrid dataGrid = sender as DataGrid;&lt;BR /&gt; &lt;BR /&gt;int selectedIndex = dataGrid.SelectedIndex;&lt;BR /&gt; if (selectedIndex &amp;gt; -1)&lt;BR /&gt; {&lt;BR /&gt; FindResult findResult = (FindResult)resultsDataGrid.SelectedItem;&lt;BR /&gt; Graphic graphic = findResult.Feature;&lt;BR /&gt; ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = findResult.Feature.Geometry.Extent;&lt;BR /&gt; &lt;BR /&gt;ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(&lt;BR /&gt; selectedFeatureExtent.XMin - 500,&lt;BR /&gt; selectedFeatureExtent.YMin - 500,&lt;BR /&gt; selectedFeatureExtent.XMax + 500,&lt;BR /&gt; selectedFeatureExtent.YMax + 500);&lt;BR /&gt; &lt;BR /&gt;MapApplication.Current.Map.ZoomTo(displayExtent);&lt;BR /&gt; &lt;BR /&gt;string StrGeometry = findResult.Feature.Geometry.GetType().ToString();&lt;BR /&gt; &lt;BR /&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.MapPoint"))&lt;BR /&gt; {&lt;BR /&gt; graphic.Symbol = Circle;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polygon"))&lt;BR /&gt; {&lt;BR /&gt; graphic.Symbol = Fill;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt;if (StrGeometry.Equals("ESRI.ArcGIS.Client.Geometry.Polyline"))&lt;BR /&gt; {&lt;BR /&gt; graphic.Symbol = YellowLine;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyGraphicsLayer"] as GraphicsLayer;&lt;BR /&gt; graphicsLayer.ClearGraphics();&lt;BR /&gt; &lt;BR /&gt;graphicsLayer.Graphics.Add(graphic);&lt;BR /&gt; &lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is a sample screenshot from our applications.&amp;nbsp; You perform a find. . in this case for a neighborhood and the results show up in a data grid.&amp;nbsp; You then double click on the found result in the data grid and it will zoom and place a graphic.&amp;nbsp; Are you trying to do something similar?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 18:46:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/zoom-to-query-results-from-datagrid/m-p/233028#M5989</guid>
      <dc:creator>IanPeebles</dc:creator>
      <dc:date>2013-08-21T18:46:08Z</dc:date>
    </item>
  </channel>
</rss>

