的Windows Phone 8改变口音与主题颜色 [英] Windows Phone 8 Change Accent and Theme Colour

查看:164
本文介绍了的Windows Phone 8改变口音与主题颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的Windows Phone 8的应用程序,我想无论改变由手机操作系统用户设置的主题的主题色彩,以同样的方式,其他应用程序做到这一点(例如Skype的)。

I am creating an Application for Windows Phone 8, and I would like to change the theme colour irrespective of the theme set by the user in the phone OS, in the same way that other applications do this (for example Skype).

到目前为止,我只设法改变背​​景颜色,在XAML访问LayoutRoot元素:

So far I have only managed to change the background colour, by accessing the LayoutRoot element in XAML:

this.LayoutRoot.Background = new SolidColorBrush(Colors.White);

和前景色颜色:

(App.Current.Resources["PhoneForegroundBrush"] as SolidColorBrush).Color = Colors.Green;



但是以下在Windows Phone 8不工作:

However the following does not work on Windows Phone 8:

(App.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush).Color = Colors.White;
(App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color = Colors.Yellow;



我不知道为什么我不能更改 PhoneBackgroundBrush PhoneAccentBrush ,我曾尝试使用Google的解决方案然而,他们只与Windows Phone 7的SDK.The教程的的工作,但不是WP 8 />这里。

I do not know why I cannot change the PhoneBackgroundBrush or the PhoneAccentBrush and I have tried googling solutions however they only work with the windows phone 7 SDK.The Tutorial here works on WP 7 but not WP 8.

感谢您!

推荐答案

法布里斯绝对是正确的轨道上。获取默认PhoneAccentBrush并改变它的颜色是要走的路。

Fabrice is definitely on the right track. Getting the default PhoneAccentBrush and changing it's color is the way to go.

此代码添加到您的应用程序的构造函数的结束,它会覆盖WP8的强调文字颜色为您的应用程序:

Add this code to the end of your App's constructor and it would override WP8's Accent colour for your app:

    Resources.Remove("PhoneAccentColor");
    Resources.Add("PhoneAccentColor", Colors.Magenta);
    ((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = Colors.Magenta;

当我们运行这段代码并单击<按钮/> 您可以看到新的强调文字颜色:

When we run this code and click a <Button /> you can see the new Accent colour:

点击的按钮与背景品红

这篇关于的Windows Phone 8改变口音与主题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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