更改WPF C#窗口标题的字体系列

5
如何在WPF中更改窗口的字体,除了创建窗口模板并使用它之外还有什么其他方法吗?
1个回答

0

我通常在Application.Resources中使用这个:

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

在 InitializeComponent 后,将以下内容添加到 Window 构造函数中:
Style = (Style)FindResource(typeof(Window));

很简单。 或者在InitializeComponent之后在同一个构造函数中使用它:
 Application.Current.MainWindow.FontFamily = new FontFamily("Cambria");

注意:对于第二种方法,您不再需要那个样式。

在此处查看Windows字体系列:

编辑1

很遗憾我没有完全关注您的问题。确实没有一种简单的方法来完成这个任务。我不知道您到目前为止找到或完成了什么,但我曾经使用过 这个项目 ,它表现良好。

另一个例子是这个。我没有尝试过,但看起来很有前途: WPF自定义Chrome库

确实需要大量工作。

来自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.

而那些“非客户端”区域则由窗口控制。


4
你好Mircea,我尝试了上面的方法,样式已应用于窗口的所有元素,但窗口标题仍然是默认字体。 - keerthee

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接