MVVM Playing Sounds and Storyboard

May 28, 2010 at 2:09 AM

Ok how does one play sounds and trigger storyboard in a MVVM app.  Here is a simplified example to get the point across

Button Click-->ViewModel-->Checks to see if Button Color is Blue and User has Clicked twice-->If true then I play the Storyboard and the sound. I have looked for examples online but it seems like most just cheat around. I would like one way of doing it. Code would help.

Coordinator
Jun 1, 2010 at 11:03 AM

Hi,

Such functionality can be implemented by passing an ISoundService and IAnimationService to the ViewModel, two interfaces that the MainPage (or the MainWindow in WPF) can implement. This way you keep a neat separation of concerns.

Cheers,

Laurent

Jun 2, 2010 at 10:25 PM

If No one minds, Can i get example in code to see how it would be done. Just a simple example. I am new to MVVM so I don't know how it would fite. If I understand Something like

 

In the View-->Implement Interface

Pass the Interface to the ViewModel?