MVVM and animation, revisited

A while back, quite a while back to be honest, I wrote a blog post about using animations in the MVVM pattern. And even if the way of doing it mentioned in the post still works, I would not recommend using it.

Adding the animation support in the way that that blog post says, will couple your VM to the StoryboardManager. Not that this really matters, as it will still be quite testable and so on. But it feels wrong…and I don’t like things that feel wrong…

In this post, I aim to cover a couple of ways that we can trigger animations and state changes based on the VM. And yes, these techniques have been hashed and rehashed on several other blogs, and you might already have read about it, but I still have people come to my blog to read the old post. So apparently it is still an issue for some…

More...

MVVM and animations…

Right now I am working on a Silverlight project for my company. In that project, as in most projects with Silverlight I need to run some animations. And since I’m working with MVVM this becomes a little cumbersome and complicated. I don’t want my view to be dependent on the viewmodel. So the view cant tell the model what storyboards to play. And I don’t want the viewmodel to be dependent on the view either. So i don’t want to give the viewmodel a referens to the view. I guess I could get some separation using interfaces, but it still felt a little off… So I thought a little about this, and then I Googled it. Do you know what I found when googling for “patterns mvvm animations”. Nothing really useful. A bunch of questions. I even tried to search for WPF and tried to leverage the WPF delelopers knowledge…no luck… So I had to figure something our myself. And I think I have actually found a pretty nice separation by using a Storyboard manager object.

More...