views:

2151

answers:

2

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.

+5  A: 

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.

Steven Robbins
+1  A: 

I just develop something useful to do this

http://thibaud60.blogspot.com/2009/02/convert-clr-method-to-icommand-with.html

It is a new markup extention named {MethodCommand}, It convert a public method of current DataContext to ICommand instance ...

It is just an idea :-)

Best regards