Animation with MVVM pattern
Asked Answered
D

1

7

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!

Deathless answered 16/12, 2009 at 0:17 Comment(0)
M
3

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.

Marseillaise answered 16/12, 2009 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.