For Prism users:
@Diego Torres gave a nice answer in this thread. His xaml can be used directly in a MVVM situation with the Prism framework, with the following code in the ViewModel:
public DelegateCommand<object> SelectedItemChangedCommand { get; private set; }
In the constructor of your ViewModel:
SelectedItemChangedCommand = new DelegateCommand<object>(SelectedItemChanged);
The method to be executed:
private void SelectedItemChanged(object args)
{
// check for the datatype of args and
// Do something!
}