Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing and using the ICommand interface, MVVM

Although I deeply fell in love with the MVVM pattern there seem to be a lot of problems I cannot (yet) figure out for myself.

I wonder what the parameters of the methods of the IComamnd interface are good for

e.g. void Execute(object parameter);

I tie my view to the view model like this

<Button Command="{Binding SomeCommand}" ... />

and so "parameter" will always be null.

Any hints are welcome.

Thanks!

Update: Darn, one minute after I posted this question I found the answer on Stackoverflow. Obviously controls do have a CommandParameter property.

like image 208
Alex Janzik Avatar asked Jan 27 '09 12:01

Alex Janzik


1 Answers

You can add CommandParameter="" to pass a parameter. Usually you'll pass in the binding, or an id that's part of the binding, so the command knows what record to work with.

like image 140
Steven Robbins Avatar answered Sep 28 '22 17:09

Steven Robbins