I am writing this major memory trainer using the MVVM pattern by animating labels containing 2 digit numbers across the screen and asking the user to quickly type in the corresponding mnemonic for each number. It is entirely up to the View how the animation is done so there will be some code behind for this. When the correct mnemonic is typed into the UI or when the number disappears off the screen Commands will be executed from the View to relay that this has happened.
In the ViewModel I want to periodically fire off new numbers with which the View animates (as it pleases).
What's the best way of achieving this? I can have an ObservableCollection<> in the ViewModel but I want to do more than simply bind to it, I will need to execute a method in the code behind when numbers are added and removed.
Is it in accordance with MVVM to use simple .NET events in the ViewModel and subscribe to them with: DataContext.NumberAdded += new NumberAddedEventHandler(....) or is there another way I should be doing it?
DataTemplate
and handle the animation with triggers. No event required. – Proparoxytone