title: How can I get DrawGeometry to draw along device pixel lines in WPF?
body: <p>I'm trying to use <code>DrawingContext.DrawGeometry</code> get a rectangle with 1 device pixel wide sides.</p>
  
  <pre><code>var geometry = (defined elsewhere from a Rect {0.0, 0.0, 8.0, 18.0})
  var brush = new SolidColorBrush(Color.FromArgb(30, 0xff, 0xff, 0xff));
  
  // Note: the pen is declared with a 1.0 thickness
  var pen = new Pen(new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF)), 1.0)
  
  drawingContext.DrawGeometry(brush, pen, geometry);
  </code></pre>
  
  <p>I have verified that the <code>Rect</code> I'm building the geometry with is whole numbers, not fractional points (manually verified), and the <code>Pen</code> I'm drawing the geometry with is <code>1.0</code> units wide.</p>
  
  <p>The problem is that the rect is being drawn on screen 2 device pixels wide. How can I draw this rectangle on exact device pixels? I'm expecting that at 96dpi, this will come out to 1 pixel.</p>