This is a migrated thread and some comments may be shown as answers.

Crash when removing the DataContext

1 Answer 15 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 26 Nov 2018, 10:18 PM

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?

1 Answer, 1 is accepted

Sort by
0
Jason D
Top achievements
Rank 1
Veteran
answered on 26 Nov 2018, 10:52 PM
Of course, I found the cause now. I had assigned each map the same Provider. If I assign each a different provider, it works. I guess this is some sort of threading issue / "you can't do it like that".
Tags
Map
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Jason D
Top achievements
Rank 1
Veteran
Share this question
or