FontFamily不存在

时间:2014-05-15 20:13:45

标签: xaml windows-store-apps

想要在FontFamily中设置全局FontSizeResourceDictionary,但这不是一个选项。为什么呢?

enter image description here

1 个答案:

答案 0 :(得分:0)

这对我有用:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App59">
    <FontFamily
        x:Key="MyFamily">Consolas</FontFamily>
    <x:Double
        x:Key="MyFontSize">48</x:Double>
</ResourceDictionary>

<Page
    x:Class="App59.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App59"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
                    Source="SomeResourceDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBlock
            Text="Hello"
            FontSize="{StaticResource MyFontSize}"
            FontFamily="{StaticResource MyFamily}"></TextBlock>
    </Grid>
</Page>