Click here to Skip to main content
12,501,082 members (41,763 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.5K views
142 downloads
10 bookmarked
Posted

Improve WPF performance with RenderOptions

, 31 Mar 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Improve WPF performance with RenderOptions and TextOptions

Introduction

Too many articles have been presented on how to improve WPF performance with several global methods.

Here, we introduce another basic ways of improving WPF performance:

  • RenderOptions: Provides options for controlling the rendering behavior of objects.

Using the Code

For more details, please go to read MSDN (RenderOptions class). Here just for telling you with these, your application's performance should be improved.

Here is an example. You could see the difference between the two:

In the code block, you can see that certain settings could be inherited by childs element in XAML element-tree:

 <StackPanel Grid.Column="0" Margin="5"
            TextOptions.TextRenderingMode="Grayscale"
            RenderOptions.ClearTypeHint="Enabled"
            RenderOptions.BitmapScalingMode="NearestNeighbor"
            RenderOptions.EdgeMode="Aliased">
    <TextBlock Text="With RenderOptions and TextOptions" HorizontalAlignment="Center"
               TextOptions.TextHintingMode="Fixed" TextWrapping="Wrap" Width="300"
               TextAlignment="Center"/>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <Image Source="_AUT.png" Width="30" RenderOptions.ClearTypeHint="Enabled"
           RenderOptions.BitmapScalingMode="NearestNeighbor"/>
        <Image Source="_CHE.png" Width="30" RenderOptions.ClearTypeHint="Enabled"
           RenderOptions.BitmapScalingMode="NearestNeighbor"/>
        <Image Source="_CHN.png" Width="30" RenderOptions.ClearTypeHint="Enabled"
           RenderOptions.BitmapScalingMode="NearestNeighbor"/>
        <Image Source="_DEU.png" Width="30" RenderOptions.ClearTypeHint="Enabled"
            RenderOptions.EdgeMode="Aliased"
           RenderOptions.BitmapScalingMode="NearestNeighbor"/>
        <Image Source="_CHL.png" Width="30" RenderOptions.ClearTypeHint="Enabled"
            RenderOptions.EdgeMode="Aliased"
           RenderOptions.BitmapScalingMode="NearestNeighbor"/>
        <Image Source="_BEL.png" Width="30" RenderOptions.ClearTypeHint="Enabled"
            RenderOptions.EdgeMode="Aliased"
           RenderOptions.BitmapScalingMode="NearestNeighbor"/>
    </StackPanel>
    <Grid Margin="0,0">
        <Canvas Height="60" Width="60" VerticalAlignment="Center">
            <Polygon Points="2,59 30,2 59,39" Fill="Red">
            </Polygon>
        </Canvas>
    </Grid>
</StackPanel>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

comiscience
Software Developer (Senior)
France France
A foolish 18 years old boy
Just got an Microsoft C# Specialist Certification. Objectif of this year : MCSD

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionGood stuff about how to improve WPF performance with RenderOptions Pin
Volynsky Alex6-Apr-14 12:56
professionalVolynsky Alex6-Apr-14 12:56 
QuestionTextOptions is not a performance fix. Pin
Pete O'Hanlon31-Mar-14 2:57
protectorPete O'Hanlon31-Mar-14 2:57 
AnswerRe: TextOptions is not a performance fix. Pin
comiscience31-Mar-14 3:14
professionalcomiscience31-Mar-14 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 31 Mar 2014
Article Copyright 2014 by comiscience
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid