Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:43:20+00:00 2026-05-16T14:43:20+00:00

I have a general question about WPF performance. We have a relatively simple forms

  • 0

I have a general question about WPF performance. We have a relatively simple forms application. Some team members believe that redesigning the templates for basic controls will improve performance and maintainability. One preferred technique is to create multiple control templates for a control, and swap them out with triggers. The belief is that a smaller visual tree will be more performant.

For example, the checkbox template is now two templates, one checked and one unchecked:

    <ControlTemplate x:Key="CheckedCheckBoxCT" TargetType="{x:Type CheckBox}">
    <Grid x:Name="gLayoutRoot" VerticalAlignment="Center" HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="colCheck" />
            <ColumnDefinition x:Name="colContentLabel" />
        </Grid.ColumnDefinitions>
        <Rectangle x:Name="rectOuter" 
                Stroke="{TemplateBinding BorderBrush}" 
                StrokeThickness="0.5" 
                Fill="White" 
                Width="13" Height="13"   />
        <Rectangle x:Name="rectInner" 
                Stroke="{TemplateBinding OpacityMask}" 
                StrokeThickness="0.5" 
                Width="9" Height="9" 
                Fill="{TemplateBinding Background}"/>
        <Path x:Name="CheckMark"                
                  Data="{DynamicResource CheckSymbol}" 
                  Fill="{TemplateBinding Foreground}"/>
        <ContentPresenter x:Name="cpContent" />
    </Grid>
</ControlTemplate>

and then the unchecked (note there’s no path element):

    <ControlTemplate x:Key="CheckBoxCT" TargetType="{x:Type CheckBox}">
    <Grid x:Name="gLayoutRoot" 
           VerticalAlignment="Center" 
          HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="colCheck" />
            <ColumnDefinition x:Name="colContentLabel" />
        </Grid.ColumnDefinitions>
        <Rectangle x:Name="rectOuter" 
                   Stroke="{TemplateBinding BorderBrush}" 
                   StrokeThickness="0.5" 
                   Fill="White" 
                   Width="13" Height="13"   />
        <Rectangle x:Name="rectInner" 
                   Stroke="{TemplateBinding OpacityMask}" 
                   StrokeThickness="0.5" 
                   Fill="{TemplateBinding Background}" 
                   Width="9" Height="9" />
        <ContentPresenter x:Name="cpContent" 
                    Margin="5,0,0,0" 
                    VerticalAlignment="Center" 
                    Grid.Column="1" />
    </Grid>
</ControlTemplate>

There is a similar discussion on making a read-only textbox with selectable text, using triggers to swap out a textblock (that you can’t select text from) with a textbox.

Does this really improve performance to any appreciable degree? With the checkbox, would a trigger to show/hide the check, instead of two different control templates, be about the same, or better?

I really don’t care, but it seems like there’s a lot of complexity added for not much gain. I was curious what others’ opinions were, esp. if based on objective experience. (You can see I don’t care enough to set up some sample apps and test performance on them. 🙂 )

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:43:21+00:00Added an answer on May 16, 2026 at 2:43 pm

    Here is a blog post discussing performance issues with regards to Visual Studio, they mention that simplifying the visual tree was not something they looked into much. In your example I think having two templates for a checkbox would hinder rather than improve maintainability as modifying the look will require changes to both. Also switching the template when clicking is likely to be slower than adjusting the visibility of an element.

    With regards to overall performance I would pay more attention to Effects, VisualBrushes e.t.c but simplifying Templates used a lot (ItemTemplates) can be worthwhile, if the situation with the read only textbox is in an ItemControl with lots of elements and most would be disabled I would be inclined to do it. There are quite a few resources about WPF performance including some mentioned in that post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a general question about writing web apps. I have an application that
I have a general question about the way that database indexing works, particularly in
I have a general question that is rather open-ended (i.e. depends on platform, application
I'm reading about the WPF Navigation Services and I have a general question. At
I have a general question about debugging a .NET process that has been built
I'm creating a backup utility in WPF and have a general question about threading
I have a general question about rails controllers/models: I have a model Providers, that
I have general question about designated initializer. I have a some class and from
I have some general question about algorithms, when You have some problem and You
I have a general question about Django forms (specifically, a contact form) when it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.