title: WPF image host with centering and clipping
body: <p>I feel like I may need some converters, but this is what I want to do. I want a single Image control (since it is in a data template that is bound to real data) with the following parameters.</p>
  
  <ul>
  <li>Be centered in a space that is 90x90 (no stretching of any sort).</li>
  <li>Have a circular clipping of radius 40 pixels (both horizontal and vertical).</li>
  <li>If image is > 90x90, it should center within the 90x90 space and clip a 40x40 circle from the middle.</li>
  <li>If image is &lt; 90x90, it should center within the 90x90 space. The clipping circle should have no effect since the entire image is contained within the clip area.</li>
  </ul>
  
  <p>I have my XAML code below. This works as expected for pictures that are exactly 90x90 (i.e. they don't stretch, they center the image and the clipping works). For images > 90x90, the clipping works correctly but the image is not getting centered. For images &lt; 90x90, the image gets centered but the clipping seems to place the image in the top-left area of the Image content so, the clipping clips the top-left portion of the image.</p>
  
  <pre><code>&lt;Style x:Key="ImageStyle"&gt;
      &lt;Setter Property="Width" Value="90" /&gt;
      &lt;Setter Property="Height" Value="90" /&gt;
      &lt;Setter Property="Stretch" Value="None" /&gt;
      &lt;Setter Property="HorizontalAlignment" Value="Center" /&gt;
      &lt;Setter Property="VerticalAlignment" Value="Center" /&gt;
      &lt;Setter Property="Clip"&gt;
          &lt;Setter.Value&gt;
              &lt;EllipseGeometry Center="45,45" RadiusX="40" RadiusY="40" /&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  
  &lt;Grid&gt;
      &lt;!-- Other Stuff --&gt;
      &lt;Image Source="{Binding ImagePath}" Style="{StaticResource ImageStyle}" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>I can get rid of the second issue (small image clipping) by wrapping in a Grid and moving the clipping there, but large stuff doesn't center:</p>
  
  <pre><code>&lt;Grid&gt;
      &lt;!-- Other Stuff --&gt;
      &lt;Grid Width="90" Height="90"&gt;
          &lt;Grid.Clip&gt;
              &lt;EllipseGeometry Center="45,45" RadiusX="40" RadiusY="40" /&gt;
          &lt;/Grid.Clip&gt;
          &lt;Image Source="{Binding ImagePath}" Style="{StaticResource ImageStyle}" /&gt;
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  </code></pre>