制作自己的Windows 8应用主题 [英] Make own windows 8 app theme

查看:84
本文介绍了制作自己的Windows 8应用主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,并希望将自己的样式应用于该应用程序. XAML有一些称为主题目录的东西,我试图将其用于主题. 事实证明,窗口具有3个预定义的主题.浅色,深色和高对比度. 当我在包含要使用的主题的资源目录上设置x:Key属性而不是3个预定义或默认之一时,它不起作用.有人知道为什么吗?

I'm working on an app, and want to apply my own style to it. XAML have something called theme directories which I trying to use for my themes. As it turns out, windows has 3 predefined themes; Light, Dark, and HighContrast. When I set the x:Key property on the Resource Directory containg the theme I want to use to something else than one of the 3 predefined or Default, it does not work. Anyone know why?

<ResourceDictionary.ThemeDictionary>
    <ResourceDictionary x:key="Default"> // Does work
        (...)
    </ResourceDictionary>
    <ResourceDictionary x:key="MyOwnThemeKey"> // Does not work
        (...)
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionary>

推荐答案

来自

主题字典是合并字典的一种特殊类型,它是 旨在容纳随主题而变化的资源 用户当前正在其PC上使用.例如,光" 主题可能使用白色画笔,而默认主题可能使用 使用深色画笔.笔刷会更改,但否则 使用画笔作为资源的控件的组成可能是 相同,只是引用主题资源.

A theme dictionary is a special type of merged dictionary that is intended to hold the resources that vary depending on which theme a user is currently using on his or her PC. For example, the "light" theme might use a white color brush whereas the default theme might use a dark color brush. The brush changes, but otherwise the composition of a control that uses the brush as a resource could be the same, just by referencing a theme resource.

并从此处:

一个或多个ResourceDictionary对象元素.每个这样 ResourceDictionary必须具有x:Key属性.的价值 属性必须是唯一的,并且应引用已知的主题名称.每个 资源字典及其内容应旨在 提供命名资源的主题值,否则将被消耗 其他资源.例如,"HighContrast"的主题词典 可能包括对部分或全部笔刷"或颜色"的重新定义 在其他地方以其他样式使用的关键资源或过渡资源, 为了产生必要的对比度水平以满足 高对比度的设计要求.

One or more ResourceDictionary object elements. Each such ResourceDictionary must have an x:Key attribute. The value of that attribute must be unique and should reference a known theme name. Each resource dictionary and the contents thereof should be intended to supply theme values for named resources that are otherwise consumed by other resources. For example, a theme dictionary for "HighContrast" might include redefinitions for some or all of the Brush or Color keyed resources used elsewhere in other style or transition resources, in order to produce the necessary contrast levels to satisfy high-contrast design requirements.

基本上,主题词典旨在修改现有主题,并根据当前OS主题进行选择.如果没有该名称的OS主题,则无法选择它.

Basically a theme dictionary is intended to modify an existing theme and is selected based on the current OS theme. If there is no OS theme of that name then there is no way to select it.

这篇关于制作自己的Windows 8应用主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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