Question

Inside a WP8 project I have 2 views - using MVVMCross - GameView & GameOverView.

I play some animations - relative to a specific user control using as DataTemplate inside an ItemsControl - in GameView which crash my app when switching to GameOverView.
My animation is performed in code using a storyboard.
When no animation are playing when switching views everything is fine.
When animation is playing when switching app crashes.

Is there a way to tell animation to stop when relative usercontrol lost focus or this kind of thing?

Or have I to to manually ensure animation is properly stopped when I navigate from GameView to GameOverView?
I tried this way by manually stopping animation during OnNavigatedFrom using IMvxMessenger event but stop order occur after navigation. Is there a way to use same thread to ensure everything is stopped before navigating? Or maybe can I sequentially access each of my dataTemplate user controls forcing them to stop?
What is the best strategy?

Any help appreciated. Regards

Was it helpful?

Solution

I would look into the animation code first. I have a setup where I also have a userControl with simple storyboard (just to continuous flip) from xaml, and I animate it from code behind. I never had a crash of moving to another view while animating.

If you are in OnNavigatedFrom, can't you just stop the animation instead of using messenger; that's the event one should really clean up all subscriptions.

On my control, I have just added a method Animate(bool start) and use .Begin() and .Stop()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top