Changing FontSize relationally to the windowsize with WPF?

橙三吉。 提交于 2020-01-12 18:18:32

问题


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


回答1:


Wrap your text inside a Viewbox.

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <Viewbox>
        <TextBlock Text="Sizes to fit!"/>
    </Viewbox>
</Window>



回答2:


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.



来源:https://stackoverflow.com/questions/2071949/changing-fontsize-relationally-to-the-windowsize-with-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!