Welcome to EMC Consulting Blogs Sign in | Join | Help

Howard van Rooijen's EMC Consulting Blog (2004 - 2010)

This blog has now moved to http://howard.vanrooijen.co.uk/blog - please update your subscriptions if you wish to receive new content.

WPF: Blurry UIElements

If you're writing a WPF application the chances are that you'll run across this little oddity fairly soon. On some monitors UIElements can appear slightly blurry or over anti-aliased, almost as if ClearType were over-compensating. The solution is to set the SnapsToDevicePixels property on the root element in your Visual Tree (all child element will then inherit this property).

Below the Username textbox with SnapsToDevicePixels set to false, N.B. the border is blurred:

blurry elements: SnapsToDevicePixels = false

Below the Username textbox with SnapsToDevicePixels set to true, N.B. the border is now crisp:

crisp elements: SnapsToDevicePixels = true

Seema Ramchandani has a great post explaining Pixel Snapping in more detail.

Published Wednesday, January 24, 2007 12:58 PM by howard.vanrooijen
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

john.rayner said:

Glad you pointed out the difference in these images, otherwise I wouldn't have spotted it.

January 24, 2007 1:48 PM
 

howard.vanrooijen said:

The joys of 1920 x 1200 laptop screen resolutions! If you're working at a lower monitor resolution it's much more noticeable.

January 24, 2007 2:45 PM
 

James Miles said:

This doesn't seem to work on the groupbox control (in 120 DPI). Any ideas?
April 18, 2007 8:23 AM
 

John said:

Does this eliminate the hideous blur effect WPF causes on images/icons as well as text in general? I doubt it affects the text based on the screenshots.
July 19, 2007 5:02 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

This blog has now moved - please visit http://howard.vanrooijen.co.uk/blog for new content!
Add to Live.com
Powered by Community Server (Personal Edition), by Telligent Systems