简体   繁体   English

Windows Phone 8.1的自定义主题

[英]Custom Themes for Windows Phone 8.1

After writing my application I started testing different scenarios. 编写应用程序后,我开始测试不同的场景。 When I changed my theme background from dark to light from system settings, some of the controls in the pages changed color accordingly. 当我通过系统设置将主题背景从黑暗更改为浅色时,页面中的某些控件会相应地更改颜色。 As I am using ThemeResources that is a normal behavior but that made the pages quiet unusable as most of them were designed according to a dark background. 当我使用ThemeResources时,这是正常现象,但由于大多数页面是根据深色背景设计的,因此使页面变得无法使用。

So I started searching the net about themes in order to implement my own theme and fix the issue. 因此,我开始在网上搜索有关主题的信息,以实现自己的主题并解决该问题。 Unfortunately I was unable to find a good solution after my research and stuck with some questions about creating custom themes for my application. 不幸的是,研究之后,我找不到一个好的解决方案,并且对创建针对应用程序的自定义主题存在一些疑问。

Firstly is there a way to override the system theme. 首先,有一种方法可以覆盖系统主题。 For example even though user selects the light theme can I apply the dark theme in my application. 例如,即使用户选择了浅色主题,我也可以在应用程序中应用深色主题。 I want to support system themes in the future but not in the beginning so being able to do that would ease my work greatly. 我希望将来支持系统主题,而不是一开始就支持,因此能够做到这一点将大大简化我的工作。

Secondly what is the best way of creating a new theme. 其次,创建新主题的最佳方法是什么。 While searching for a solution I read that copying a whole theme from generic.xaml and working on it with a new key is an easy solution. 在寻找解决方案时,我读到从generic.xaml复制整个主题并使用新密钥进行工作是一个简单的解决方案。 Is it OK to that, is it a good practice? 可以吗,这是一个好习惯吗?

Lastly if I create multiple themes, say blue and red, is there a way to fetch these theme names programmatically using C#. 最后,如果我创建多个主题(例如蓝色和红色),是否可以使用C#以编程方式获取这些主题名称。

As always thanks for all your helps. 一如既往地感谢您的所有帮助。

First Question: Yes You can also do so by using following snippet... you have to override RequestedTheme here 第一个问题:是的,您也可以通过使用以下代码段来实现此目的...您必须在此处覆盖RequestedTheme

<Application x:Class="App2.App"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:local="using:App2"
 RequestedTheme="Dark">
</Application>

Second Question: Yes this is good way for beginners. 第二个问题:是的,这对初学者是个好方法。

For More info visit this 欲了解更多信息,请访问这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM