title: WPF DataGrid ComboBox SelectedItem Property Setter
body: <p>I am looking for an example of how to use the SelectedItem property inside a combobox in a WPF DataGrid, I have</p>
  
  <pre><code>&lt;DataGridComboBoxColumn SelectedValueBinding="{Binding CID, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                          SelectedValuePath="CID"  
                          Header="CID" 
                          Width="70"&gt;
          &lt;DataGridComboBoxColumn.EditingElementStyle&gt;
              &lt;Style TargetType="ComboBox"&gt;
                  &lt;Setter Property="ItemsSource" Value="{Binding DataContext.ListCustomerCollection, 
                    RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"/&gt;
                  &lt;Setter Property="DisplayMemberPath" Value="Name"/&gt;
                  &lt;Setter Property="SelectedItem" Value="{Binding DataContext.Customer, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}"&gt;&lt;/Setter&gt; 
              &lt;/Style&gt;
          &lt;/DataGridComboBoxColumn.EditingElementStyle&gt;
          &lt;DataGridComboBoxColumn.ElementStyle&gt;
              &lt;Style TargetType="ComboBox"&gt;
                  &lt;Setter Property="ItemsSource" Value="{Binding DataContext.ListCustomerCollection, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"/&gt;
                  &lt;Setter Property="DisplayMemberPath" Value="Name"/&gt;
                  &lt;Setter Property="HorizontalAlignment" Value="Center"&gt;&lt;/Setter&gt;
                  &lt;Setter Property="SelectedItem" Value="{Binding DataContext.Customer, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}"&gt;&lt;/Setter&gt;
              &lt;/Style&gt;
          &lt;/DataGridComboBoxColumn.ElementStyle&gt;
  </code></pre>
  
  <p>The DataContext I bind to (ListCustomerCollection) is a List object</p>
  
  <pre><code>  List&lt;Customer&gt; 
  </code></pre>
  
  <p>so the property in the ViewModel property I have set is </p>
  
  <pre><code>private Customer m_Customer = null;
  public Customer Customer
  {
      get { return m_Customer; }
      set
      {
          m_Customer = value;
          OnPropertyChanged("Customer");
      }
  }
  </code></pre>
  
  <p>So how do I writethe XAML to set the above property with the SelectedItem?</p>