title: How to populate a datagrid based on value in combobox
body: <p>I am facing a question (maybe very basic).
  I have a combobox1 and it has filled values (say 1,2,3,4,5) from earlier controls.</p>
  
  <p>Now based on choosing a value from the combobox1, I want to populate the columns of a datagrid.</p>
  
  <p>Now, the datagrid has 4 columns, 
  one DataGridcheckboxcolumn(value set to checked as default), 
  one DataGridtextboxcolumn1 for autopopulation from the combobox1(the most important part), one DataGridTextBoxColumn2(to set as default value) and 
  one DataGridComboBoxColumn(set to default value AVS_DB frm AVS,DB,AVS_DB).</p>
  
  <p>My question is very basic.</p>
  
  <p>How do I get the values in the datagrid populated.</p>
  
  <p>The xaml and the codebehind are as follows:</p>
  
  <pre><code>&lt;DataGrid Name="dtgQCNumbers" Width="400" AutoGenerateColumns="False" 
            Grid.ColumnSpan="2" Height="100" Grid.RowSpan="5" Grid.Row="6" 
            SelectionChanged="dtgQCNumbers_SelectionChanged" 
            Grid.Column="1" Margin="3,10,125,15"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridCheckBoxColumn Header="Enter_Choice" Width="100" 
              Binding="{Binding Path=DataGridCheckBox_Option}" /&gt;
          &lt;DataGridTextColumn Header="QC_ID" Width="100" 
              Binding="{Binding Path=DataGridTextBox_QCList1}" /&gt;                               
          &lt;DataGridTextColumn Header="Summary" Width="100"
              Binding="{Binding Path=DataGridTextBox_QCSummary}" /&gt;
          &lt;DataGridComboBoxColumn Header="ControlOption" Width="100"
              SelectedItemBinding="{Binding Path=DataGridComboxBox_Control}"&gt;
              &lt;DataGridComboBoxColumn.ItemsSource&gt;
                  &lt;col:ArrayList&gt;
                      &lt;sys:String&gt;AVS&lt;/sys:String&gt;
                      &lt;sys:String&gt;DB&lt;/sys:String&gt;
                      &lt;sys:String&gt;AVS_DB&lt;/sys:String&gt;
                  &lt;/col:ArrayList&gt;
              &lt;/DataGridComboBoxColumn.ItemsSource&gt;
          &lt;/DataGridComboBoxColumn&gt;
          &lt;/DataGrid.Columns&gt;
              grid.ColumnWidth = new DataGridLength(100);
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p><em>The code to populate the ComboBox (before the datagrid) is:</em></p>
  
  <pre><code>private void ddlCR_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
       btnSubmit.IsEnabled = true;
       ClearStatusMessages();
       if (ddlCR.SelectedIndex &gt; 0)
       {
          PopulateQCIdList();
       }
    }
  </code></pre>
  
  <p>Now the PopulateQCIdList() should populate the DataGrid Columns (all 4 Columns, 3 default values and value driven from what we choose from the combobox)</p>
  
  <p>The codebehind is what I want to know to populate data after the ComboBox has been populated, i.e. I want to know how exactly to fill the DataGrid using the PopulateQCIdList() method.</p>
  
  <p>Please edit/let me know if I missed any information</p>