The way I do is that I have "sub-viewmodels". For example, in the case of the MainViewModel, let's imagine that you have a PrintCommand
and a CancelPrintCommand
. You can have a new class called PrinterViewModel
, and expose an instance of this class in the MainViewModel
. Have the PrintCommand
and the CancelPrintCommand
in this PrinterViewModel
(this also allows modular unit testing, which is neat).
Then in XAML:
Command="{Binding Main.Printer.PrintCommand}"
Alternatively, you could do
new RelayCommand(() => Printer.DoSomething())
Does that make sense?
Cheers Laurent