I want to create at style that will set the fontfamily for my entire application and allow me to change the font family in one place and have the new font show up throughout my application. I created the following style but my controls like my labels still default to segoe. How can I create a style that will set my all my controls to the same font family except where I override the style with a local style.

<Style TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Constantia"/>

Re: Windows Presentation Foundation (WPF) Default FontFamily for application

Eddie Li

Hi, what you can do is to define a "global" style for the Control class, like what you have already done, then have other control-specific styles to be derived or BasedOn that, then apply that style to the actual control. For example:

<StackPanel xmlns=""
<Style TargetType="{x:Type Control}" x:Key="ControlStyle">
<Setter Property="FontFamily" Value="Constantia"/>

<Style TargetType="{x:Type Label}" x:Key="LabelStyle" BasedOn="{StaticResource ControlStyle}">
<Setter Property="FontWeight" Value="Bold" />
<Style TargetType="{x:Type Button}" x:Key="ButtonStyle" BasedOn="{StaticResource ControlStyle}">
<Setter Property="Background" Value="Blue"/>

<Label Style="{StaticResource LabelStyle}">This is a Label</Label>
<Button Style="{StaticResource ButtonStyle}">This is a Button</Button>

This way, both the Label and Button will have Constantia font but also have their own styles. (Bold for Label, and Blue background for Button)

Hope this helps.


Re: Windows Presentation Foundation (WPF) Default FontFamily for application

Zhou Yong

Presumably <Application TextElement.FontFamily="Constantia"/> should do the trick for you.


Re: Windows Presentation Foundation (WPF) Default FontFamily for application

Chris Han MSFT

This may not apply to your app, but it's worth noting that the default font properties for FlowDocuments are different from that of controls (we did this since properties you use for document text is often different from UI text). So you'd likely have to have a seperate Style setting for <FlowDocument/>.


Re: Windows Presentation Foundation (WPF) Default FontFamily for application



When I try to do what you're suggesting I get the following exception:

'Constantia' value cannot be assigned to property 'FontFamily' of object 'WindowsApplication1.App'. Object of type 'WindowsApplication1.App' cannot be converted to type 'System.Windows.DependencyObject'. Error at object 'WindowsApplication1.App' in markup file 'WindowsApplication1;component/app.xaml' Line 5 Position 5.

If I'm guessing right, it boiles down to the fact that you can only attach dependency properties to dependency objects, and Application is not a DependencyObject (it's a DispatcherObject)

So the original poster's question remains, what's the recommended way of setting a default font for the entire application

I've spent several hours today trying to find the answer, but haven't found a satisfactory solution. In my case, I have an application with many Pages, and I want to avoid having to remember to set a font family on each new Page that is created. I understand I can specify the font using something like "FontFamily={DynamicResource MyAppDefaultFont}", but this still means that I (or my developers) must remember to add that line to each Window or Page.

It would be so much easier if I could specify the default font in a resource dictionary once and for all.


Re: Windows Presentation Foundation (WPF) Default FontFamily for application


hi, when I tried this, everything that used the styles complained that they could only base on a style that is base type "text block" (for the text blocks) or whatever control they were. So I can't base a style on anything that is not written for the same type.
I'm sure I tried this ages ago, out of one of the books we have here, and it did not work either, even though it is supposed to....

Re: Windows Presentation Foundation (WPF) Default FontFamily for application

Chad Magendanz

Is there perhaps a way to package a local copy of "GlobalUserInterface.CompositeFont" that would override the "Global User Interface" FontFamily definition with your custom font fallback chain