Your best bet is to wrap the Name
and ID
into a separate class, then bind the ItemsSource
to the collection of Name/ID pairs. Set the DisplayMemberPath
on the ComboBox
to "Name"
.
On the View Model, you can have a property for the selected Name/ID pair, or just the selected ID. If you want to do the latter, just set SelectedValuePath
to "ID"
and bind SelectedValue
to the ID property on your view model (note that if you do it this way, you can use the anonymous class projection from Servy's answer). Otherwise, just bind SelectedItem
to your selected Name/ID pair property (this version requires a named class).