Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use SnapToDevicePixels and StrokeDashArray

Tags:

wpf

xaml

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 horribly fuzzy on my screen. Is there a solution?

like image 882
user380719 Avatar asked Jan 01 '26 22:01

user380719


1 Answers

If you just want a crisp, dashed path and you may be able to get the results you want by declaring the RenderOptions.EdgeMode as Aliased to prevent the framework from interpolating the path outline when a dash falls between pixel boundaries:

<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>
like image 148
C8H10N4O2 Avatar answered Jan 06 '26 01:01

C8H10N4O2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!