How to use SnapToDevicePixels and StrokeDashArray

I have the following XAML code:

<Path Data="M0,0 L 12 0 L 12 12 L 0 12 Z M 6 0 L 6 12 M 0 6 L 12 6" StrokeDashArray="1 1" Stroke="Black" StrokeThickness="1" SnapsToDevicePixels='True">
</Path>

However, it looks terribly fuzzy on my screen. Is there a solution?

+3
source share
1 answer

If you need a crispy dashed path and you can get the results you want by declaring RenderOptions.EdgeMode as Aliased to prevent the outline structure of the outline from being interpolated when the stroke falls between pixel borders:

<Path Data="M0,0 L 12 0 L 12 12 L 0 12 Z M 6 0 L 6 12 M 0 6 L 12 6" StrokeDashArray="1 1" Stroke="Black" StrokeThickness="1" RenderOptions.EdgeMode="Aliased">
</Path>
+4
source

Source: https://habr.com/ru/post/1757874/


All Articles