The item list select list is not working properly?

in connection with my previous question, List of binding lists in XAML? My problem is facing a small problem. enter image description here

The above window has a ListView control, where each of its ListViewItem is a different ListView. Thus, the parent ListView consists of 8 elements (ListView), where each child ListView consists of 1,1,1,2,1,2,1,2 elements, respectively. The picture below was taken when I try to click on the β€œBug Life” poster. However, the selection does not update the bottom two TextBlock controls bound to the ViewModel Movie property. He still shows the 3 Idiots films that were selected earlier. However, if I click on the 27 Dresses poster, it will update the Movie property. Please help me in identifying and solving this problem.

+1
source share
1 answer

In the ViewModel you need to reset SelectedItem for all ListView (setting it to null ) before assigning a new value as follows:

 private Movie m_SelectedMovie; public Movie SelectedMovie { get { return m_SelectedMovie; } set { if (m_SelectedMovie != value) { m_SelectedMovie = null; OnPropertyChanged("SelectedMovie"); // -> So the ListViews unselect everything m_SelectedMovie = value; OnPropertyChanged("SelectedMovie"); } } } 
+1
source

All Articles