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

时间:2015-06-13 11:26:22

标签: wpf wpf-controls wpf-4.0

如何在WPF中更改窗口的字体系列,除了为窗口创建模板并使用它?

1 个答案:

答案 0 :(得分:1)

我通常在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");

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

See windows font families here:

修改1

不幸的是,我并没有最大限度地关注你的要求。实际上,没有一种简单的方法可以实现这一目标。我不知道你到目前为止发现或完成了什么,但我曾使用过this project并表现良好。

另一个例子就是这个。我没试过,但看起来很有意思:WPF Custom Chrome Library

确实需要做很多工作。

来自MSDN:

  

窗口的非客户区域由WPF实现并包含   大多数窗户共有的窗户部分,包括   以下内容:

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.

那些“非客户”区域由Windows控制。

相关问题