Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight Path is blurry - How to snap to pixels?

I have a Canvas onto which I draw a Path:

<Path Data="M 380 110 v -10 l 100 -100"
      Stroke="#C0C0C2" StrokeThickness="1" UseLayoutRounding="True" />

Even though the StrokeThickness is set to 1, the vertical part of the path is drawn across 2 pixels and in a lighter color.

Silverlight Path

I know that WPF has the SnapsToDevicePixels property that would fix it, and I read that in Silverlight there is a UseLayoutRounding property that you can use in some cases to have the same effect, however it does not seem to apply to Path.

Is there anything I can do to get that line drawn properly?

like image 634
Xavier Poinas Avatar asked May 31 '11 02:05

Xavier Poinas


1 Answers

There is a pixel snapper class over at MSDN on Dave Relyea's Silverlight Blog. That is what I have used in the past for Silverlight pixel snapping.

like image 53
Chris Grant Avatar answered Oct 26 '22 06:10

Chris Grant