变化的全球应用程序的字体在Windows 8.1的应用程序 [英] Change global application font in a Windows 8.1 app

查看:183
本文介绍了变化的全球应用程序的字体在Windows 8.1的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多的文章在网上关于如何嵌入自定义字体,打造字体样式,并将其应用到控件。但是,一个人如何可以覆盖全球应用的字体,这样每个控件使用该字体,而不是手动设置的FontFamily属性为每个控件的。就我而言,我不希望使用自定义的字体作为全局字体而是一个系统的字体,如宋体或宋体。

There are lots of articles online about how to embed custom fonts, create font styles and apply them to controls. But how can one override the global application font such that each control uses that font instead of setting the FontFamily property manually for each control. In my case, I do not wish to use a custom font as the global font but a system font such as Tahoma or Calibri.

推荐答案

在WinRT的默认fontFamily中所有控件ContentPresenter为的Segoe UI 及其关键就是 ContentControlThemeFontFamily

In winrt default Fontfamily for all controls ContentPresenter is Segoe Ui and its key is ContentControlThemeFontFamily.

- *您可以更改或ResourceDictionary中fontFamily中控按钮,comboboxitem,一个ListBoxItem等,因为他们有模板属性(contenpresenter或itempresenter)

1)围棋到StandardStyles.xaml

1) Go to StandardStyles.xaml

2)添加<的FontFamily X:键=ContentControlThemeFontFamily>宋体< /的FontFamily> 默认和。像下面ThemeDictionaries的高反差的ResourceDictionary

2) Add <FontFamily x:Key="ContentControlThemeFontFamily">Tahoma</FontFamily>in default and Highcontrast resourcedictionary of ThemeDictionaries like below.

   <ResourceDictionary.ThemeDictionaries>
    <ResourceDictionary x:Key="Default">
        <x:String x:Key="BackButtonGlyph">&#xE071;</x:String>
        <x:String x:Key="BackButtonSnappedGlyph">&#xE0BA;</x:String>
        <FontFamily x:Key="ContentControlThemeFontFamily">Tahoma</FontFamily>
    </ResourceDictionary>
    <ResourceDictionary x:Key="HighContrast">
        <FontFamily x:Key="ContentControlThemeFontFamily">Tahoma</FontFamily>
        <x:String x:Key="BackButtonGlyph">&#xE071;</x:String>
        <x:String x:Key="BackButtonSnappedGlyph">&#xE0C4;</x:String>
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>



但文本块是不是有模板属性,以便您可以更改其属性如下图所示

But Textblock is not having template property so you can change its property like below

1。第一种方法

 <TextBlock  FontFamily="{StaticResource ContentControlThemeFontFamily }" >dfdsfsdf</TextBlock>



2。第二种方法

<Page
x:Class="App3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
mc:Ignorable="d" FontFamily="{StaticResource ContentControlThemeFontFamily}">
<Grid>
    <TextBlock>Hello World</TextBlock>
</Grid>



这篇关于变化的全球应用程序的字体在Windows 8.1的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆