1

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]
patrick
  • 16,091
  • 29
  • 100
  • 164

2 Answers2

1

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.

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
-1

I would do a setAttribute("hide") = currentValue in the mother TAG (allowed just ensure uniqueness in naming) onblur ListBox1

...and - onfocus I would getElementById("").getAttribute("hide");

MikeyKennethR
  • 600
  • 4
  • 16