Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing FontSize relationally to the windowsize with WPF?

Is it possible, that the FontSize getting smaller if I shrink the window and getting bigger if I enlarge the window?

like image 262
rakete Avatar asked Jan 15 '10 13:01

rakete


2 Answers

Wrap your text inside a Viewbox.

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <Viewbox>
        <TextBlock Text="Sizes to fit!"/>
    </Viewbox>
</Window>
like image 133
CannibalSmith Avatar answered May 30 '23 07:05

CannibalSmith


I've never tried this, but I imagine you can bind the font size property of your text to the window size through a converter method. I wouldn't try to bind directly, as that way madness lies.

The other option would be to handle the window resize events and send the font size to each control manually...

--edit-- Just searched Google and found this result, which may be what you want.

like image 42
ZombieSheep Avatar answered May 30 '23 09:05

ZombieSheep