I have the following data template (and a corresponding view model, not shown):
<DataTemplate DataType="{x:Type logic:SnapshotListViewModel}">
<ListBox ItemsSource="{Binding Snapshots}" />
</DataTemplate>
ItemsSource is bound to a list of Snapshots, found inside the viewmodel. My goal is to clear the SelectedItem, so the listbox goes back to its initial, unselected state. The view model implements IPropertyNotified.
I added a binding in the XAML like so:
<ListBox SelectedItem={Binding SelectedSnapshot} .... />
In the view model, I set SelectedSnapshot = null, but nothing happens, even though RaisePropertyChanged was called on the property.
I tried again with SelectedIndex instead of SelectedItem. Still no luck.
I finally found the solution, which I will detail below.