I tested your code with the FeatureLayerSimple interactive sample and it looks working (despite there is only one feature layer).
Could you give more info on how to reproduce the issue? Thanks
The code does work with a feature layer when the count is greater than 1 what I am talking is when the feature layer count is 1..i.e only one feature....for example in a graphics layer also when the graphic count is 1 the graphicsLayer.FullExtent.Width and graphicsLayer.FullExtent.Height is 0.0 but when the graphics count is greater than 2 it has valuesFeatureSet featureSet = e.FeatureSet;
if (featureSet != null && featureSet.Features.Count > 0)
{
// If an item has been selected
GraphicsLayer graphicsLayer = mainPage.map.Layers["tempGraphicLayer"] as GraphicsLayer;
if (graphicsLayer == null)
{
graphicsLayer = new GraphicsLayer();
graphicsLayer.ID = "tempGraphicLayer";
mainPage.map.Layers.Add(graphicsLayer);
}
Graphic selectedFeature = null;
for (int i = 0; i < featureSet.Features.Count; i++)
{
// Show selected feature attributes in DataGrid
selectedFeature = featureSet.Features;
selectedFeature.Symbol = LayoutRoot.Resources["MarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
graphicsLayer.Graphics.Add(selectedFeature);
}
graphicsLayer.Opacity = 0.7;
double expandPercentage = 30;
double widthExpand = graphicsLayer.FullExtent.Width * (expandPercentage / 100);
double heightExpand = graphicsLayer.FullExtent.Height * (expandPercentage / 100);
if (graphicsLayer != null)
{
ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
graphicsLayer.FullExtent.XMin - (widthExpand / 2),
graphicsLayer.FullExtent.YMin - (heightExpand / 2),
graphicsLayer.FullExtent.XMax + (widthExpand / 2),
graphicsLayer.FullExtent.YMax + (heightExpand / 2));
mainPage.map.ZoomTo(displayExtent);
KeyValuePair<int, string> str = (KeyValuePair<int, string>)lstChainage.SelectedItem;
mainPage.lblcustomStatusBar.Content = str.Value + " located";
mainPage.lblcustomStatusBar.Foreground = new SolidColorBrush(Colors.Blue);
}
}