Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You might consider using guidelines (see <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.guidelineset.aspx" rel="nofollow noreferrer">GuidelineSet on MSDN</a>) and overriding the Rectangles' OnRender methods so that their boundaries line up with the pixel boundaries of the device. WPF uses guidelines to determine whether and where to snap drawings.</p> <p>Internally, it's exactly what SnapsToDevicePixels is using to ensure that objects line up with the device's pixels, but by placing guidelines manually you'll be able to control when the snapping behaviour is applied and when it is not (so when your image is zoomed all of the way out, you can avoid drawing guidelines, or only draw guidelines where your shapes lie next to other shapes, and rely on WPF's anti-aliasing to take care of the rest). You <em>might</em> be able to do it with an attached property so that you can apply it to any element, though if it's only one type of element (e.g. Rectangle) that you need this behaviour on, it's probably not worth the extra effort.</p> <p>It seems like Microsoft is aware of this problem, too - <a href="http://blogs.msdn.com/jaimer/archive/2009/05/27/wpf-4-and-net-framework-4-beta-1-list-of-features-totrack.aspx" rel="nofollow noreferrer">WPF 4.0 is expected to feature Layout Rounding</a>, which, <a href="http://msdn.microsoft.com/en-us/library/cc896566(VS.95).aspx" rel="nofollow noreferrer">like the version in Silverlight</a>, rounds off non-integer values at the Render pass when layout rounding has been enabled.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload