Skip to content


How to create a ControlTemplate for a WPF TextBox

This is a short post, but has one specific piece of information I want to keep.

Q: If you want to create a ControlTemplate to provide a custom style for a TextBox, how do you specify where the text goes when it’s used in WPF?

A: The answer was hidden in the depths of the MSDN Documentation. You have to include a <ScrollViewer> within your ControlTemplate with an x:Name value of “PART_ContentHost”.

Here’s a noddy example:


Did you like this? Share it:

Posted in C#, Software Development, WPF.

Tagged with , , , , , , , , , , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. Handling events from within a ControlTemplate in WPF | Richard Dutton linked to this post on 13 February, 2010

    [...] About « How to create a ControlTemplate for a WPF TextBox [...]



Some HTML is OK

or, reply to this post via trackback.