Kruthika

Kruthika

  • NA
  • 1
  • 1.9k

Binding SelectedItem of a Inner ListBox

Feb 21 2013 8:05 AM
Hi,

I am having trouble binding selected item of a ListBox in my application
(IDE : Visual Studio 2010 and Technology : WPF).

Requirement: There is a list of interfaces and another list of devices
connected to each interface. The pattern of displaying these 2 lists is as
follows:

  • Interface 1
  1.    Device 1
  2.    Device 2
  3.    Device 3

  • Interface 2
  1.    Device 1
  2.    Device 2
   

  • Interface 3
  1.    Device 1
  2.    Device 2
  3.    Device 3
  4.    Device 4

and so on.

If any interface is selected then by default the first device must be
selected and if any device is selected then the corresponding interface
must be selected. I am able to do the first part but not the second part.
How can I make the selected Item to be unique across all the inner list
of devices?

i.e. if Device 1 (within Interface 1) is selected currently and then the user selects Device 2 under Interface 2 then, the SelectedItem of outer ListBox must be Interface 2 and the SelectedItem of the Inner ListBox must be Device 2 and then the background color of the previously selection (i.e. Device 1 under Interface 1) should be that of the outer ListBox.

I hope I am clear.

Please do tell me if there is any wpf control for this or should I develop
a new ListBox for this or is there a simple solution for this?

Regards
Kruthika