Software Architect – New Feature – WFP 4.0 and Silverlight 4.0 – Layout Rounding

Layout Rounding is a new concept in WFP 4.0 and Silverlight 4.0
Which means that the layout rendering engine rounds off non integer values during layout pass.

UIElement Class has a UseLayoutRounding property. The default value of this property is true, which means that layout rounding is on by default.

Example:

Lets put some xaml on silverlight page as:

<Grid x:Name="LayoutRoot" Background="White" UseLayoutRounding="False" Width="388">
        <Button Content="Shahzad Sarwar"  Height="150.5" HorizontalAlignment="Left" Margin="12,64,0,0" Name="button1" VerticalAlignment="Top" Width="363.5"  BorderBrush="Black"  BorderThickness="4" Background="White" FontSize="38"/>
    </Grid>

Output of appears as shown in image below:

[Zoom till 600% to view the real details]

Note that Firstly, the border of button [Bottom + Right] has a shade of light grey color. Secondly, 4 corner of border has some shade effect. Thirdly, characters of text have some shade effect.
First shade effect is not required, but second shade effect is required to show the corner shape and third shade effect is required to show the edges of characters.
These effects are called “antialiasing effect”

Before version 4.0, there was no concept of LayoutRounding. So effect was same as false.

Change UseLayoutRounding to True as:

<Grid x:Name="LayoutRoot" Background="White" UseLayoutRounding="True" Width="388">
        <Button Content="Shahzad Sarwar"  Height="150.5" HorizontalAlignment="Left" Margin="12,64,0,0" Name="button1" VerticalAlignment="Top" Width="363.5"  BorderBrush="Black"  BorderThickness="4" Background="White" FontSize="38"/>
    </Grid>

Output will be as:


[Zoom till 600% to view the real details]

Note that First antialiasing effect at the border of button is gone which was causing bad visual effect. Second and Third antialiasing effects are still there which are usefull to have a better visual effect.

Advertisements

One Response to Software Architect – New Feature – WFP 4.0 and Silverlight 4.0 – Layout Rounding

  1. Mudasser says:

    Good Work.Keep it up

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: