views:

114

answers:

1

I'm pretty new to WPF and using the MVVM design pattern. To help learn this, I'm developing a simple dice-rolling application.

Right now, I have a Dice class and a DiceViewModel class. I also have a MainWindowViewModel class that contains an observable collection of DiceViewModels.

When a user clicks the "Roll" button, it launches a Command to my MainWindowViewModel to call Roll on each DiceViewModel.

I understand that Commands are used for GUI binding to the ModelView without requiring codebehind.

So to my question. Is it proper MVVM for my MainWindowViewModel to directly call Roll on each DiceViewModel, or should it be using Commands to do this?

Or to put it another way, should all (or most) viewmodel methods be accessed through commands when not being directly bound to by the GUI?

+2  A: 

No, it's fine having on VM call another. Just be mindful of the coupling it creates.

HTH, Kent

Kent Boogaart