Crash when removing the DataContext

2 posts, 0 answers
  1. Jason D
    Jason D avatar
    130 posts
    Member since:
    Jan 2011

    Posted 26 Nov 2018 Link to this post

    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?

  2. Jason D
    Jason D avatar
    130 posts
    Member since:
    Jan 2011

    Posted 26 Nov 2018 in reply to Jason D Link to this post

    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".
Back to Top