Xaml 在Windows 8.1中创建主题

Xaml 在Windows 8.1中创建主题,xaml,windows-runtime,winrt-xaml,windows-8.1,Xaml,Windows Runtime,Winrt Xaml,Windows 8.1,在Windows 8中,您可以为应用程序()创建自己的主题 在Windows 8.1应用程序中,主题的处理方式不同:您可以在运行时更改它们,并在XAML中为特定控件设置主题(如果您不想将主题应用于整个应用程序) 例如: <Grid x:Name="MainGrid" RequestedTheme="Dark"> 但它在Windows 8.1中不可用 如何在Windows 8.1中创建主题?我是否仅限于现有主题(光明和黑暗)?是的,我认为您仅限于3个主题 默认值(灯光) 黑暗的 高对

在Windows 8中,您可以为应用程序()创建自己的主题

在Windows 8.1应用程序中,主题的处理方式不同:您可以在运行时更改它们,并在XAML中为特定控件设置主题(如果您不想将主题应用于整个应用程序)

例如:

<Grid x:Name="MainGrid" RequestedTheme="Dark">
但它在Windows 8.1中不可用


如何在Windows 8.1中创建主题?我是否仅限于现有主题(光明和黑暗)?

是的,我认为您仅限于3个主题

默认值(灯光) 黑暗的 高对比度

您可以为8.1中的3个主题创建新样式或替代现有样式

 <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Default">
                <Style TargetType="TextBlock">
                    <Setter Property="FontSize" Value="24" />
                    <Setter Property="Foreground" Value="Green"/>
                </Style>
            </ResourceDictionary>
            <ResourceDictionary x:Key="Dark">
                <Style TargetType="TextBlock">
                    <Setter Property="FontSize" Value="30" />
                    <Setter Property="Foreground" Value="Orange"/>
                </Style>
            </ResourceDictionary>
            <ResourceDictionary x:Key="HighContrast">
                <Style TargetType="TextBlock">
                    <Setter Property="FontSize" Value="24" />
                    <Setter Property="Foreground" Value="Blue"/>
                </Style>
            </ResourceDictionary>               
        </ResourceDictionary.ThemeDictionaries>

如果不创建新主题,将覆盖现有的3个主题。
 <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Default">
                <Style TargetType="TextBlock">
                    <Setter Property="FontSize" Value="24" />
                    <Setter Property="Foreground" Value="Green"/>
                </Style>
            </ResourceDictionary>
            <ResourceDictionary x:Key="Dark">
                <Style TargetType="TextBlock">
                    <Setter Property="FontSize" Value="30" />
                    <Setter Property="Foreground" Value="Orange"/>
                </Style>
            </ResourceDictionary>
            <ResourceDictionary x:Key="HighContrast">
                <Style TargetType="TextBlock">
                    <Setter Property="FontSize" Value="24" />
                    <Setter Property="Foreground" Value="Blue"/>
                </Style>
            </ResourceDictionary>               
        </ResourceDictionary.ThemeDictionaries>