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.