I have a ListBox (ListBox1) of Agency types {Police, Fire, Emergency}
When the user selects an Agency type, Another ListBox (ListBox2) is populated with (Name, CheckBox) by setting the items source.
The problem is if I select Police, then check a CheckBox, then select Fire, and select Police again, the CheckBox state is lost. I know the CheckBox state is lost because I'm resetting ItemsSource, but I'm wondering what's the correct way to go about this.
ListBox1
[Police] is selected
[Fire]
[Emergency]
ListBox2
[ Name, CheckBox for Police agency 1]
[ Name, CheckBox for Police agency 2]
[ Name, CheckBox for Police agency 3]
You should have the status checked in your viewmodel. The first listbox model should have a collection of agency, ad each agency model have a bool for the checkbox. So just bind that to the view and it will preserve.