title: WPF Center Ellipse at X, Y
body: <p>I have an ItemsControl that draws thousands of Ellipses in a scatter plot on a Canvas. My problem is, if I position an Ellipse at the coordinates (4, 6) with a Height and Width of 10. The top left of the Ellipse is at (4, 6) and the shape extends down and to the right.</p>
  
  <p>What I'd like to do is center the Ellipses on specific coordinates in XAML without having to use adjustments in my ViewModel layer.</p>
  
  <p>Here's the working UserControl that has my graph:</p>
  
  <pre><code>&lt;Grid&gt;
          &lt;ItemsControl ItemsSource="{Binding State.Data}"&gt;
  
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;Canvas  ClipToBounds="False"/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
  
              &lt;ItemsControl.ItemContainerStyle&gt;
                  &lt;Style TargetType="ContentPresenter"&gt;
                      &lt;Setter Property="Canvas.Left" Value="{Binding Path=X}" /&gt;
                      &lt;Setter Property="Canvas.Top" Value="{Binding Path=Y}" /&gt;
                  &lt;/Style&gt;
              &lt;/ItemsControl.ItemContainerStyle&gt;
  
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Ellipse Fill="Red"  VerticalAlignment="Center" HorizontalAlignment="Center"  Width="10" Height="20"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
  
          &lt;/ItemsControl&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>This works great except for the uncentered ellipses. Any ideas?</p>