title: How do I place a Popup in my DataGridTemplateColumn.CellEditingTemplate correctly?
body: <p>I have the following XAML ..</p>
  
  <pre><code>&lt;DataGridTemplateColumn Header="Comparison key"&gt;
      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Grid DataContext="{Binding Columns}"&gt;
                  &lt;Popup x:Name="popKeyComparison" 
                                  Placement="Bottom" 
                                  IsOpen="True"
                                  Width="200" Height="100"&gt;
                      &lt;StackPanel Orientation="Vertical" Background="Gray" &gt;
                          &lt;TextBlock Text="{Binding Name}"&gt;&lt;/TextBlock&gt;
                          &lt;Button&gt;
                              &lt;TextBlock&gt;Somethingn here&lt;/TextBlock&gt;
                          &lt;/Button&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Popup&gt;
              &lt;/Grid&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
                  &lt;TextBlock Text="{Binding KeyStatusText}" Name="txtKeyStatus"&gt;
                  &lt;/TextBlock&gt;
          &lt;/DataTemplate&gt;                                
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>I am trying to show a Popup when editing the cell, this works fine but the problem is that the Popup does not close when clicking outside of the DataGrid. If for example I move the Window the Popup remains open but does not move with the Window. </p>
  
  <p>Can anybody help with a solution to this?
  Cheers.</p>