My Development KB

Odds and ends related to software development

WPF – TextBox lagging performance

Posted by Ben G on August 11, 2010

I had a WPF TextBox that was showing a painful lag when typing. Tracked it down to the fact that a parent in the visual tree had a Bevel BitmapEffect applied. It wasn’t obvious to me that a BitmapEffect like that would affect the visual performance of any descendant controls, but it does. The fix for me was simple.

Instead of structuring my tree like this, with the children nested under the Border with the Bitmap effect:

<Border>
<Border.BitmapEffect>
<BevelBitmapEffect />
</Border.BitmapEffect>
<Grid>
<!--Children-->
</Grid>
</Border>

I simply changed it to this, moving the BitmapEffected element out of the ancestry of the rest of the tree:

<Grid>
<Border>
<Border.BitmapEffect>
<BevelBitmapEffect />
</Border.BitmapEffect>

</Border>
<Grid>
<!--Children-->
</Grid>
</Grid>

Now the grid that contains the children is a sibling of the BitmapEffected Border, not a descendant.

Advertisement

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 )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.