I ma binding the result to graphic layer and from graphics layer i am publishing the attributes into feature data grid but the zoom to selected feature is not working at allBelow is the code
void queryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs e)
{
GraphicsLayer graphicsLayer = Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
FeatureSet featureset = e.FeatureSet;
featureset.SpatialReference = Map.SpatialReference;
if (featureset != null && featureset.Features.Count>0 )
{
foreach (Graphic resultfeature in featureset.Features)
{
switch (featureset.GeometryType.ToString())
{
case "Polygon":
resultfeature.Symbol = LayoutRoot.Resources["DefaultQueryFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
case "Polyline":
resultfeature.Symbol = LayoutRoot.Resources["DefaultQueryLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
case "Point":
resultfeature.Symbol = LayoutRoot.Resources["DefaultQueryMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
}
graphicsLayer.Graphics.Add(resultfeature);
System.Windows.Data.Binding bind = new System.Windows.Data.Binding();
bind.ElementName = "Map";
bind.Path = new PropertyPath("Layers.[MyGraphicsLayer]");
MyDataGrid.SetBinding(ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.GraphicsLayerProperty, bind);
MyDataGrid.UpdateLayout();
}
}
}
private void MyDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
DataGrid datagrid = sender as DataGrid;
int selectedindex = datagrid.SelectedIndex;
if (selectedindex > -1)
{
FindResult findresult = (FindResult)MyDataGrid.SelectedItem;
Graphic graphic = findresult.Feature;
switch (graphic.Attributes["Shape"].ToString())
{
case "Polygon":
graphic.Symbol = LayoutRoot.Resources["DefaultQueryFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
case "Polyline":
graphic.Symbol = LayoutRoot.Resources["DefaultQueryLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
case "Point":
graphic.Symbol = LayoutRoot.Resources["DefaultQueryMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
}
GraphicsLayer graphicsLayer = Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
graphicsLayer.Graphics.Add(graphic);
}
}
also i am assigning symbology in graphics layer directly. I want to assign the symbology when i am selecting record from feature data grid and zoom to feature.Thank you in advance.I tried example from find and query from esri blog still not working..