WPF Reflections

Jan 29 2008   4:17PM GMT

Combobox - using objects



Posted by: Mark Shurmer
WPF

I have seen a number of people getting confused about how to set up the various combobox properties for data binding.

Lets say you have a Person object, with a member called Employee which is a reference to an Employee object
When you want to bind to an Person object with an object reference you set:

  • SelectedItem - this points to the Employee member (typically set to {Binding Path=Employee})
  • DisplayMemberPath - point this to the member of the Employee that displays something meaningful, like Name. This will then get displayed in the drop down.
  • ItemsSource - point this to the ObservableCollection that holds the list of Employees

This is all you need to do :-)

Comment on this Post


You must be logged-in to post a comment. Log-in/Register