views:

22

answers:

0

Hi All

I am working on a small system for a summer camp in WPF. I have a database that is linked via ADO.Net Entity Framework. It contains two tables; Campers & Bunks. The structure is as follows:

Campers

  • CustomerID, INT (Key)
  • Name, NVARCHAR
  • BunkID, INT

Bunks

  • BunkID, INT (Key)
  • Name, NVARCHAR

There is a foreign key relationship to for the link between Campers.BunkID & Bunks.BunkID

I made a WPF Window that consists of a ListBox of all the customers and a UserControl that displays the details of the customer selected in the ListBox . The UserControl consists of a TextBlock for the CamperID , TextBox for the Name of the camper and ComboBox for the Bunk of the camper.

Now the hard part... I have two questions:

  1. What is the best method to bind the list of all the Campers to the ListBox ? What is the best way to bind the list of all the Bunks to the ComboBox in the UserControl ?
  2. I cannot figure out how to bind the ComboBox correctly such that it displays the Bunk for each Camper and can be updated by changing the value.

Currently I am doing both in the code behind in C# but with the strength of WPF, I can't imagine that a simpler and better solution does not exist...

Thanks in advance!

Mike