Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation with MVVM pattern

What is the best way to trigger an animation while using the MVVM pattern? More specifically, I have a form which has several fields. When a user click's the save Button, I would like to show an animation. I have been able to achieve this by exposing a property ShowMessage and setting it to True and a DataTrigger picks up this value and starts an animation. However, while the animation is still active, I would like to reset the form to a clean state. So far I've done the reset by subscribing to the Complete event on the Storyboard and resetting the view model's state on that event.

Ideally I would like to be able to somehow trigger an animation from the view model (because the save would be an asynchronous operation) and let the animation run to completion. The way I have it now wouldn't work because once I change the value of the ShowMessage property (on the reset), the animation stops and doesn't run to completion.

Does any one have a better solution?

Thanks!

like image 912
Pavel Avatar asked Dec 16 '09 00:12

Pavel


1 Answers

Two options comes into my mind. The first is VSM, and the second is attached behaviors. You may find useful the following post from Marlon Grech: Animations and MVVM.

Hope this helps.

like image 163
Anvaka Avatar answered Nov 15 '22 09:11

Anvaka