title: How to add items to combobox in WPF which is bound to datatable?
body: <p>When I try to add item to combobox in WPF which is already bound I get an error. How to achieve this ? My target is to add default value to the combobox.</p>
  
  <p>KINDLY HELP.</p>
  
  <pre><code>    public static void BindControl(ref ComboBox obj, DataTable DT, String key, String value, String defaultvalue)
              {                  
                  try
                  {
                      if (DT.Rows.Count &gt; 0)
                      {                   
                              obj.DataContext = DT;
                              obj.SelectedValuePath = DT.Columns[value].ColumnName;
                              obj.DisplayMemberPath = DT.Columns[key].ColumnName;        
                              obj.SelectedIndex = 0;
  
  
                              ComboBoxItem x = new ComboBoxItem();
                              x.Content = defaultvalue;
                              obj.Items.Add(x);
                              obj.Items.Insert(0, x); //THIS THROWS ERROR
                  }
                  catch (System.Exception ex)
                  {
                  }
  </code></pre>