New WPF Features: LayoutRounding


This is part of a series on New WPF Features


LayoutRounding – If you are familiar with Silverlight, this is nothing new. If you are unfamiliar with it, all it does is that it rounds up lengths..


Take for example the code below (hypothetical case) 


<Border Width=”33.9111111″ Height=”80.11111″ BorderBrush=”Red” Margin=”2.1222222″ BorderThickness=”3.955″>
<
Border Width=”15.3333333″ Height=”40.11111″ BorderBrush=”Black” Margin=”2.3333333″ BorderThickness=”3.89898555″></Border>



The one on the left is a bit blurry due to the subpixel positioning and doesnt use LayoutRounding. The one on the left is rendered with LayoutRounding and has crisper lines.


The property to enable LayoutRounding is UseLayoutRounding=”true” … By default this is set to false (unlike SL)


You can also take a look at the MSDN documentation


Share this post

 

Comments (3)

  1. Rico Alexander says:

    What’s SL and how do you and where do you set the LayoutRounding.

  2. Rico Alexander says:

    What’s SL and how do you and where do you set the LayoutRounding.

  3. llester says:

    SL–> Silverlight.. layout rounding comes by default