How to turn off the anti-aliasing in WPF shapes?

Joan Venge picture Joan Venge · Apr 7, 2011 · Viewed 16.9k times · Source

I draw a rectangle using:

<Rectangle Width="300" Height="100" Stroke="Blue" StrokeThickness="6"> </Rectangle>

but there is anti-aliasing applied to it. Is there a way to turn this off? I want it to be sharp and clear.

Answer

Fredrik Hedblad picture Fredrik Hedblad · Apr 24, 2012

A little late but RenderOptions.EdgeMode="Aliased" does the trick

<Rectangle Width="300"
           Height="100"
           Stroke="Blue"
           StrokeThickness="6"
           RenderOptions.EdgeMode="Aliased"/>