Possible Duplicate:
Passing two command parameters using a WPF binding
I need that send two parameters to my RelayCommand like:
public RelayCommand<String,Int> MyCommand {get;set;} Or
public RelayCommand<EventArgument,String> MyCommand {get;set;}
Possible Duplicate:
Passing two command parameters using a WPF binding
I need that send two parameters to my RelayCommand like:
public RelayCommand<String,Int> MyCommand {get;set;} Or
public RelayCommand<EventArgument,String> MyCommand {get;set;}
Wrap them in an object:
public RelayCommand<MyModel> MyCommand { get; set; }
where MyModel will contain the two properties:
public class MyModel
{
public int Id { get; set; }
public string Name { get; set; }
}
You can use a distinct model class in order to pass several parameters. And in order to initialize them, you can use xaml elements like this:
<Button Command="{Binding YourCommand}">
<Button.CommandParameter>
<YourNS:YourModel Id="{Binding PathForId}" Name="{Binding PathForName}"/>
</Button.CommandParameter>
</Button>
This will construct a new YourModel object to pass to a command, and then will initialize its properties via bindings.