We have an ArcGISDynamicMapServiceLayer that has several layers defined in the Map Service and several Dynamic Layers added on the fly at run time because this map service is connected to an SDE Workspace. I need to get the extent of each layer within the ArcGISDynamicMapServiceLayer so our uses can have a Zoom to Layer capability. I have it working for only the layers that are statically defined in the map service but not for the layers added at run time. This is what I have so far. In my XAML I have a context menu item defined in the LayerTempate DataTemplate for the ESRI Legend. This is the basic idea I have for my XAML.<DataTemplate x:Key="LayerTemplate">
.....
<ContextMenu>
<MenuItem Header="Zoom To" CommandParameter="{Binding}" Command ="{ ... DoZoomToLayer ... }" />
</ContextMenu>
....
</DataTemplate>
Then in my ViewModel I have the following C# code.public void DoZoomToLayer(ESRI.ArcGIS.Client.Toolkit.Primitives.LayerITemViewModel layerItemViewModel) {
Action<ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, Exception> action = (featureLayerIfno, exception) => {
if (exception == null) {
if (featureLayerInfo != null) {
App.Map.Extent = featureLayerInfo.Extent;
}
}
};
((ArcGISDynamicMapServiceLayer)layerItemViewModel.Layer).GetDetails(layerItemViewModel.SubLayerID, action);
}
If the layer is a dynamic layer added on the fly at run time then the featureLayerInfo object is null. This make some sense because the GetDetails() call asks the server side map service for details on a layerID that does not exist. So how can I get the extent of a dynamic layer added on the fly at run time?