title: wpf DataGridTemplateColumn CellEditingTemplate - combobox's itemssource issue
body: <p>I have TabControl with two items.</p>
  
  <pre><code>    &lt;Window x:Class="WpfApplication1.MainWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Title="MainWindow" Height="350" Width="525"&gt;
          &lt;Grid&gt;
              &lt;TabControl&gt;
                  &lt;TabItem Header="Tab1" Content="{Binding}" ContentTemplate="{StaticResource Tab1}"/&gt;
                  &lt;TabItem Header="Tab2" ContentTemplate="{StaticResource Tab2}"/&gt;
              &lt;/TabControl&gt;
          &lt;/Grid&gt;
      &lt;/Window&gt;
  </code></pre>
  
  <p>There are DataGrid control in one tabItem of TabControl. DataTemplates of TabItems:</p>
  
  <pre><code>    &lt;DataTemplate x:Key="Tab1"&gt;
          &lt;DataGrid ItemsSource="{Binding Entities}" x:Name="dataGridEx"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100"/&gt;
                  &lt;DataGridTemplateColumn Header="Position" Width="150"&gt;
                      &lt;DataGridTemplateColumn.CellTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;TextBlock Text="{Binding Position}"/&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;ComboBox SelectedItem="{Binding Position, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                        ItemsSource="{Binding Path=DataContext.Positions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"/&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
                  &lt;/DataGridTemplateColumn&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
      &lt;/DataTemplate&gt;
  
      &lt;DataTemplate x:Key="Tab2"&gt;
          &lt;Grid&gt;
              &lt;TextBox Text="Empty tab"&gt;&lt;/TextBox&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>DataContext of MainWindow:</p>
  
  <pre><code>public class MainWindowViewModel
  {
      public ObservableCollection&lt;Entity&gt; Entities { get; set; }
  
      public List&lt;string&gt; Positions { get { return new List&lt;string&gt;() { "Manager", "Seller" }; } }
  
      public MainWindowViewModel()
      {
          Entities = new ObservableCollection&lt;Entity&gt;()
                         {
                             new Entity() {Name = "John", Position = "Manager"},
                             new Entity() {Name = "Mark", Position = "Seller"},
                             new Entity() {Name = "Alice"}
                         };
      }
  
  }
  </code></pre>
  
  <p>The Entity class:</p>
  
  <pre><code>public class Entity : INotifyPropertyChanged
  {
      private string _name;
      private string _position;
  
      public string Name
      {
          get { return _name; }
          set
          {
              _name = value;
              OnPropertyChanged("Name");
          }
      }
      public string Position
      {
          get { return _position; }
          set
          {
              _position = value;
              OnPropertyChanged("Position");
          }
      }
  
      #region INotifyPropertyChanged
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      private void OnPropertyChanged(string property)
      {
          if (PropertyChanged != null)
              PropertyChanged(this, new PropertyChangedEventArgs(property));
      }
  
      #endregion
  }
  </code></pre>
  
  <p>Application is running. I edit the Position column. Then I switch to the 2nd tab and then the 1st tab again. Position value of edited row is deleted.</p>
  
  <p>If I write data directly to tabItems - it works okay</p>
  
  <pre><code>        &lt;Grid&gt;
              &lt;TabControl&gt;
                  &lt;TabItem Header="Tab1"&gt;...&lt;/TabItem&gt; 
                  &lt;TabItem Header="Tab2"&gt;...&lt;/TabItem&gt; 
              &lt;/TabControl&gt;
          &lt;/Grid&gt;
  </code></pre>
  
  <p>But I need to use DataTemplates for tabItems in my solution.</p>
  
  <p>I have some idea.. Using style, not datatemplate inside editing mode</p>
  
  <pre><code>    &lt;DataGridComboBoxColumn Header="Position" SelectedItemBinding="{Binding Position, UpdateSourceTrigger=PropertyChanged}"&gt;
              &lt;DataGridComboBoxColumn.ElementStyle&gt;
                      &lt;Style TargetType="ComboBox"&gt;
                              &lt;Setter Property="ItemsSource" Value="{Binding Path=DataContext.Position, ElementName=dataGridEx}" /&gt;
                      &lt;/Style&gt;
              &lt;/DataGridComboBoxColumn.ElementStyle&gt;
              &lt;DataGridComboBoxColumn.EditingElementStyle&gt;
                      &lt;Style TargetType="ComboBox"&gt;
                              &lt;Setter Property="ItemsSource" Value="{Binding Path=DataContext.Variables, ElementName=dataGridEx}" /&gt;
                      &lt;/Style&gt;
                  &lt;/DataGridComboBoxColumn.EditingElementStyle&gt;
              &lt;/DataGridComboBoxColumn&gt;
  </code></pre>
  
  <p>In this way everything works okay.</p>
  
  <p>But I have custom control like IntelliSense instead of ComboBox. It is requires to use DataGridTemplateColumn with DataTemplates for CellTemplate and CellEditingTemplate. What Should I do in this case? Maybe I need to create custom DataGridComboBoxColumn?</p>
  
  <p>Can you help me with my issue?</p>