WPF - change global font size at runtime?

Luckily FontSize uses Property Value Inheritance . That means that so long as don't override it FontSize will be automatically propagated to all child text elements. As a result, you can set a single.

Up vote 5 down vote favorite 1 share g+ share fb share tw.

I need to add one functionality to my simple application - to allow user to change font size for whole aplication. Is it easy to do? Can you give me any hint how to start?

It's required to have only 3 predefined font sizes but the first and only solution which came to my mind is to create 3 different themes. Is it possible to make it simplier? Wpf xaml wpf-controls link|improve this question asked Dec 28 '10 at 21:44tomo586824 82% accept rate.

Luckily, FontSize uses Property Value Inheritance. That means that so long as don't override it, FontSize will be automatically propagated to all child text elements. As a result, you can set a single: and it will apply to all text elements in that window that don't have a font size.

To change it in code is simple as well: this. FontSize = 20; in the code-behind of the window will change all unspecified font sizes on the fly. This also works for things that don't seem to support font size: The same is true for the other text properties you mentioned.

At the most basic level you need to bind the FontSize property of your TextBlocks etc, to a variable which you can then change to be one of your three predefined values: However, you would need to remember to add this to all your text. A better solution would be to bind the size of the styles you use, but again all text would have to be styled. If you used an implicit style then you wouldn't have to remember to add the reference to your text, but all your text would have to look the same.

Whether that's a problem or not will depend on your application.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions