user5346812
user5346812

Reputation:

How do I globally change the Font Size in C# WPF?

Ok, so I am trying to make a global change in one of my programs via XAML. The first change I made was to the Font Family which seemed to work fine, I just put something like:

<Windows 
FontFamily = "Calibri"
</Window >

When I went to implement the same process for all of my FontSizes of my TextBoxes and Labels I tried:

<Windows 
FontFamily = "Calibri"
FontSize = "18"
</Window >

Everything seemed to work fine, but when I went to click that specific element on the XAML and then clicked Text and looked at the Font Size it actually said 13.5pt. What is going on exactly here? Shouldn't it say 18?

Upvotes: 4

Views: 5272

Answers (1)

Bobby
Bobby

Reputation: 487

This topic is covered pretty thoroughly here.

That thread also gives you some alternate implementations that you may be interested in. Specifically in answer to your question:

TextElement.FontSize is an inherit property, which means you can simply set the font size at root element, and all the children elements will use that size (as long as you don't change them manually)

You will still see the default specification of font-size in the designer, unless you overwrite it, but at run-time the controls should be inheriting the correct value from your global setting.

Upvotes: 3

Related Questions