Search code examples
wpfgridresizetextblock

WPF resizing TextBlock


I have a textblock in a grid in WPF.

I want the text to dynamically size (font) when resized. At the moment textboxes, comboboxes do this, but the the textblock stays the same. Is it possible?


Solution

  • Instead of trying to manually rig a TextBlock to do this, just edit the default template of a TextBox and remove the border and background, then in the style make it set the IsReadOnly flag. This way you get the textblock sizing, as well as copy-paste for free.