Below I have a ListView with cities, when city is checked then the second list (with persons) must displays persons only from this city.
<ListView ItemsSource="{Binding Cities}">
<ListView.ItemTemplate >
<DataTemplate>
<StackPanel>
<Label Content="{Binding Name}" />
<CheckBox IsChecked="{Bidning IsChecked}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And the second list view with persons:
<ListView ItemsSource="{Binding Persons}">
<ListView.ItemTemplate >
<DataTemplate>
<StackPanel>
<Label Content="{Binding Name}" />
<Label Content="{Bidning Surname}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Below you can see view model with the lists which are binded with ListViews.
public ListCollectionView Cities
{
get { return _cities; }
set
{
_cities = value;
RaisePropertyChanged();
}
}
public ListCollectionView Persons
{
get { return _persons; }
set
{
_persons= value;
RaisePropertyChanged();
}
}
The question is how to handle when checkbox which is inside Cities ListView is checked by the user, so I can refresh the Persons list and return Persons only from checked City? I do not know what should I write in View Model, so I do not know how to handle when ListView children property has changed changed.
List<T>orObservableCollection<T>, where T is City or Person.