Make a class and create a method to bind data into combo box control.
Here is the sample code to bind the combobox control.
public void BindComboBoxDataContext(ComboBox comboBox, DataTable dtDataContext, string displayMemberPath, string selectedValueMemberPath)
{
try
{
comboBox.DataContext = dtDataContext;
comboBox.DisplayMemberPath = displayMemberPath;
comboBox.SelectedValuePath = selectedValueMemberPath;
comboBox.SelectedIndex = -1;
}
catch (Exception ex)
{ LogExceptionDetails(ex); }
}
Whenever required to set the data for the control, just make an object for this class and call this method.