I have a crash I cannot reproduce in a test program. I'm allowing the user to change the number of maps on the screen from 1 to 4. When switching from 4 maps to 1 map (for example), I remove the DataContext for the maps that will be hidden. I do this because I will still be updating the ViewModel for every map and do not want the map to reflect these changes if it's not visible. This causes an instant crash for maps 3 and 4. Here is the applicable stack trace:
at Telerik.Windows.Controls.Map.TilesVisualizationLayer.CalculateViewports()
at Telerik.Windows.Controls.Map.TilesVisualizationLayer.MultiscaleImage_MotionFinished(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at Telerik.Windows.Controls.Map.MultiScaleImage.<RaiseMotionFinishedEvent>b__2()
It appears to crash because there is no longer a provider. Whether the map is visible or not makes no difference. Any ideas?