Reputation: 1887
I have gone through few MVVM examples in SL/WPF and the very basic thing here is to implement ICommand
interface. I have understood how MVVM works. However, I have a doubt regarding Execute
method of ICommand
interface.
The class which implements ICommand
has Execute
method as shown below.
public void Execute(object parameter) //Method to call when the command is invoked
{
// pointer to a method to be executed
}
In every example, I see that parameter in above method is NULL
. Why? Can someone post a simple example of MVVM where this object parameter is put to use and not null ?
Upvotes: 0
Views: 838
Reputation: 2448
In the XAML you can set a CommandParameter
<Button Command="{Binding MyCommand}" CommandParameter="SomeData" />
Upvotes: 5