WPF Reflections

Jan 29 2008   4:17PM GMT

Combobox – using objects

Mark Shurmer Profile: MarkWPF

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

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: