在 Windows 8.1 中创建主题 [英] Create a theme in Windows 8.1

查看:21
本文介绍了在 Windows 8.1 中创建主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In Windows 8, you were able to create your own themes for your application (here's a tutorial).

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

In Windows 8.1 Applications, themes are handled differently: you can change them at run-time and set a theme for a specific control in your XAML (if you don't want to apply the theme to the whole Application).

例如:

<Grid x:Name="MainGrid" RequestedTheme="Dark">

但是,我找不到创建自己的主题的方法.属性 RequestedTheme 采用枚举(其类型为 FrameworkElement.RequestedTheme),并且不能扩展定义的枚举(在 C# 中).另外,如果我想定义一个新的Theme Dictionary,我会写:

However, I could not find a way to create my own themes. The property RequestedTheme takes an enumeration (its type is FrameworkElement.RequestedTheme) and an enumeration by definition cannot be extended (in C#). Also, if I want to define a new Theme Dictionary I would have written:

<ResourceDictionary.ThemeDictionaries>

但它在 Windows 8.1 中不可用.

But it is not available in Windows 8.1.

如何在 Windows 8.1 中创建主题?我是否仅限于现有的(浅色和深色)?

How can one create a theme in Windows 8.1? Am I limited to the existing ones (light & dark)?

推荐答案

是的,我相信你仅限于 3 个主题

Yes you're restricted to 3 themes I believe

默认(浅色)黑暗的高对比度

Default (light) Dark High Contrast

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

You can create new styles or override existing ones for the 3 themes like this in 8.1

 <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>

这篇关于在 Windows 8.1 中创建主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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