Reputation: 759
This is for WP7. I have a button in a listbox itemtemplate. In the associated ViewModel, I have RelayCommand, which I have bound to the Click event of the Button (using MVVMLight EventToCommand). All I want is to pass in the ListItem of the ListBox when the button is clicked.
Any ideas?
Upvotes: 1
Views: 328
Reputation: 259
use in xaml CommandParameter="{Binding}"
which will pass your selected ListItem to the command
then in view model
private RelayCommand<ListItem> _command;
public RelayCommand<ListItem> Command
{
get
{
return _command ?? (_command = new RelayCommand(Method));
}
}
public void Method(ListItem item)
{
...
}
Upvotes: 5