Best method for Binding ComboBox
Posted
by LnDCobra
on Stack Overflow
See other posts from Stack Overflow
or by LnDCobra
Published on 2010-04-16T10:29:39Z
Indexed on
2010/04/16
10:33 UTC
Read the original article
Hit count: 236
I am going to be developing a large project which will include a large number of ComboBoxes.
Most of these combo boxes will be bound to a database field which is a related to another daataset/table.
For instance.
I have the following 2 tables:
Company {CompanyID, CompanyName, MainContact}
Contacts {ContactID, ContactName}
And when the user clicks to edit a company, A TextBox will be there to edit a company name, but also a ComboBox will be there.
The way I am currently doing it is binding the ComboBox to the Contacts dataset, and manually updating the Company MainContact field in code behind.
Is there anyway for me to bind the selected item to the Company MainContact field in XAML and the items to the ContactName and eliminate the code behind?
Reason for this is when you start making 100's combo boxes all over the application it gets long winded each time creating code behind to do the update.
© Stack Overflow or respective owner