Change Font Family of the title of the Window WPF C#

8.3k views Asked by At

How to change the font family of a Window in WPF,Other than creating a template for the Window and using it??

1

There are 1 answers

1
Olaru Mircea On BEST ANSWER

I usually use this in Application.Resources:

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

And add this in the Window constructor after the InitializeComponent:

Style = (Style)FindResource(typeof(Window));

Pretty straightforward.

Or maybe use this in the same constructor after the InitializeComponent:

 Application.Current.MainWindow.FontFamily = new FontFamily("Cambria");

Note: For the second approach you don't need that Style anymore.

See windows font families here:

Edit 1

Unfortunately i wasn't paying maximum attention on what you are asking. Indeed there is not an easy way to accomplish that. I don't know what have you found or done until now but i used once this project and it behaved well.

Another example would be this. I didn't try it but looks promissing: WPF Custom Chrome Library

Indeed a lot of work is needed for that.

From MSDN :

The non-client area of a window is implemented by WPF and includes the parts of a window that are common to most windows, including the following:

A border.

A title bar.

An icon.

Minimize, Maximize, and Restore buttons.

A Close button.

A System menu with menu items that allow users to minimize, maximize, restore, move, resize, and close a window.

And those "non-client" areas are controlled by windows.