Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: changing the font of all controls in a given container

Tags:

formatting

wpf

How can I change the font of all the child controls in a container, for example a Canvas? I want to have a slider so the user can control the font size of everything in the screen at once.

Thanks

like image 291
Gus Cavalcanti Avatar asked Mar 31 '09 15:03

Gus Cavalcanti


1 Answers

The FontSize property of the container should be inherited by child controls unless they explicitly override the property.

<Canvas TextElement.FontSize="20">
    <TextBlock>Sample Text</TextBlock>
</Canvas>

Some controls don't follow the normal inheritance mechanism, however. The ListBox and the Button do not inherit their Background setting from the parent, although they do inherit font properties.

like image 186
alex Avatar answered Oct 22 '22 13:10

alex