Good answers from Spencer and Martin to at to align your pixels.
As for how : I would also like to point out that in WPF 4.0 try using the UseLayoutRounding property instead of SnapsToDevicePixels .
UseLayoutRounding does what you do compatible with Silverlight ( SnapsToDevicePixels not available in Silverlight) ... and Microsoft also encourages the use of UseLayoutRounding over SnapsToDevicePixels in its own.
What is the difference between the two? Well, the big difference is that UseLayoutRounding happens during the UseLayoutRounding phase, and SnapsToDevicePixels happens during the render phase. This makes me suggest that UseLayoutRounding is probably a more efficient way to go (I haven't confirmed this yet).
All that said, there will still be reasons to use SnapsToDevicePixels . In fact, the MSDN documentation points to one. I will add another: only with SnapsToDevicePixels can you use recommendations for precise control.
Here are some resources on this subject (for example, pixel snapping and sharpness with images, text, and visual effects):
Heh. I know that my answer was a little more than what you asked for ... but this concept (i.e. independence from the resolution and the resulting problems that it causes and how to overcome them) can often be a point of frustration at work with WPF. At least I wanted to point you to a new WPF 4.0 property, UseLayoutRounding .
UPDATE
I just need to add since I saw it again and again ... sometimes SnapsToDevicePixels works when UseLayoutRounding not. I'm sorry I can't say why this is, but try UseLayoutRounding first, and if that doesn't work, feel free to try SnapsToDevicePixels .
This line is so sharp that it can cut you off!
cplotts Apr 08 '10 at 17:12 2010-04-08 17:12
source share