How to set textblock or label with resizable font size in WPF?
Asked Answered
B

2

4

In WPF, if i put any controls in grid, if i resize the grid, it automatically resizes all the controls in it.But in label or textblock or any other text elements, all the control sizes will change but font size remains same, it will not change.

If font has to change as per grid size, What should be done?

Boom answered 23/9, 2009 at 6:2 Comment(0)
E
7

You can achieve this by using a ViewBox. It will transform (not resize) your font (well, the control) depending on the control size.

Look at this here for more information;

<Viewbox Stretch="Uniform">
    <TextBlock Text="Test" />
</Viewbox>
Eastsoutheast answered 23/9, 2009 at 6:7 Comment(1)
Sure. Please remember to accept the answer if it worked for you.Eastsoutheast
M
1

The following lines also give the expected result.

<Viewbox>
        <TextBlock TextWrapping="Wrap" Text="Some Text" />
</Viewbox>
Mallorymallow answered 7/11, 2012 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.