Implementation and use of ICommand, MVVM

Although I have fallen deeply in love with the MVVM pattern, it seems that I have many problems that I cannot (yet) figure out for myself.

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

eg. void Execute(object parameter);

I tie my view to a model of presentation like this

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

and therefore " parameter " will always be null.

Any hints are welcome.

Thanks!

Update: Darn, a minute after I posted this question, I found the answer at https://stackoverflow.com/a/220860/ .... Obviously, controls have the CommandParameter property.

+7
command wpf mvvm
source share
2 answers

You can add CommandParameter = "" to pass the parameter. Usually you pass in the link or identifier of this part of the binding, so the team knows which record to work with.

+6
source share

I am just creating something useful for this.

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

This is a new markup extension called {MethodCommand}, it converts the public method of the current DataContext into an instance of ICommand ...

This is just an idea :-)

Best wishes

+2
source share

All Articles