I'm reposting this here from ESRI's ArcGIS for WPF Forum in hopes of getting some more exposure. Original post is here.

I'm intermittently experiencing an error when rapidly changing map scales on an ArcGIS WPF Map Control (v. 10.1.1) (i.e. from very large to very small, or vice-versa) wherein my application will crash. It appears that the LayerCanvas.ArrangeOverride is, for some reason, attempting to set an invalid Width property on the FrameworkElement's dependency property. Based on this link, it appears that the issue was carried over from the Silverlight API.

Has anyone else encountered this problem and been able to work around it?

The following is a snippet of the stack trace with the offending method:

System.ArgumentException: '-907.750834278924' is not a valid value for property 'Width'.
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.FrameworkElement.set_Width(Double value)
   at ESRI.ArcGIS.Client.LayerCanvas.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

1 Answer 1


It turns out this problem was in an ESRI.ArcGIS.Client.ElementLayer in the map which has an attached property for its envelope. If a negatively sized envelope gets passed up through to the layer, it is unhandled in ESRI's API. Inserting a check like below gets around the issue:

    Envelope arcGISEnvelope = new Envelope()
        XMin = topLeftMap.X,
        YMin = bottomRightMap.Y,
        XMax = bottomRightMap.X,
        YMax = topLeftMap.Y
    //Check here to prevent an unhandled ESRI exception.
    if (arcGISEnvelope.Width < 0 || arcGISEnvelope.Height < 0)
    this.imageControl.SetValue(ElementLayer.EnvelopeProperty, arcGISEnvelope);

This seems to only happen at very large map scales. In any event, I hope that this helps someone else down the road.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.