As we tend not to handle UI events directly, when using MVVM, we need alternative ways to implement the same functionality that they provide. Different methods are required to reproduce the functionality of different events. For example, the functionality of the SelectionChanged event of a collection control is typically reproduced by data binding a View Model property to the SelectedItem property of the collection control:
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding CurrentItem}" />
In this example, the setter of the CurrentItem property will get called by the WPF Framework each time a new item is selected from the ListBox. Therefore, instead of handling the SelectionChanged event in the code behind, we can call any method directly from the property setter in the View Model:
public TypeOfObject CurrentItem { get { return currentItem; } set { currentItem = value; DoSomethingWithTheNewlySelectedItem...