Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 409
keerthee Avatar asked Nov 09 '22 11:11

keerthee


1 Answers

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.

like image 142
Olaru Mircea Avatar answered Dec 02 '22 09:12

Olaru Mircea