views:

85

answers:

1

I have an MVVM Silverlight 4 application that holds a list of modules (a UserControl plus some metadata) in the main window's ViewModel. I am displaying the UserControl of the module in a ContentControl (Content is bound to "CurrentModule.View").

I want to add a bit of pop to the app by annimating the transitions between views. I've created Visual States for PreLoaded, Normal and Unloaded. When the UserControl is instantiated, I set it's state to PreLoaded. I have attached a GoToStateAction to the the Loaded event of the UserControl which sets the state to "Normal", performing a nice animation to bring the View in to view. That works fine.

What I need to do now if animate it out of view when the user switches modules. I have another GoToStateAction attached to the "Unloaded" event of the UserControl which sets the state to "Unloaded". I know that current set up won't work. The ContentControl can only show one UserControl at a time - as soon as the switch happens, the previous module goes away. I can't say for certain if the animation is running on the view even though it's not visiable or not.

How do I accomplish what I'm after here? Please keep in mind that Iam trying to do this in an MVVM-friendly manner, though I'm not opposed to some code-behind when it's purely presentation-focused.

Thanks in advance! StackOverflow has never let me down!

Adam

A: 

Consider using the TransitioningContentControl.
It's a Silverlight Toolkit control that once you change the Content has a nice transition animation.

JustinAngel
I think this will work. It would be nice if there were more documentation on the available transitions. There is also a Telerik transition control that I wasn't ware of. It also works quite well with very little configuration.Thanks.
Adam Barney