SelectionChanged event binding in Silverlight+MVVM-Light
- by Budda
The handler of the "SelectionChanged" event of the ComboBox control has the following signature:
void SelectionChangedMethod(object sender, SelectionChangedEventArgs e)
How to bind to that property under Silverlight 4 and MVVM-Light to the corresponding method of the ViewModel object?
As far as I know, I need to do something like this:
public void Changed(Object obj, SelectionChangedEventArgs e)
{
// .... implement logic here
}
RelayCommand<Object, SelectionChangedEventArgs> _command;
public ICommand ObjectSelectionChanged
{
get
{
if (_command == null)
{
_command = new RelayCommand<Object, SelectionChangedEventArgs>(Changed);
}
return _command;
}
}
The problem is that RelayCommand class in the MVVM-Light framework doesn't support 2 generic parameters...
Is there any solution or workaround for this case? How bind control event to the method with 2 parameters?