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.
如何更改容器中所有子控件的字体,例如Canvas?我想要一个滑块,以便用户可以立即控制屏幕中所有内容的字体大小。
Thanks
谢谢
1 个解决方案
#1
20
The FontSize property of the container should be inherited by child controls unless they explicitly override the property.
容器的FontSize属性应该由子控件继承,除非它们显式覆盖该属性。
<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.
但是,某些控件不遵循正常的继承机制。 ListBox和Button不会从父级继承其Background设置,尽管它们会继承字体属性。
#1
20
The FontSize property of the container should be inherited by child controls unless they explicitly override the property.
容器的FontSize属性应该由子控件继承,除非它们显式覆盖该属性。
<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.
但是,某些控件不遵循正常的继承机制。 ListBox和Button不会从父级继承其Background设置,尽管它们会继承字体属性。