本文介绍了Windows Phone 8.1 SolidColorBrush和触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用VS2013创建Windows Phone 8.1应用程序,我想从cs文件更改某些控件的color属性,并且遇到了两个问题:

I'm using VS2013 creating a Windows Phone 8.1 App, I want to change the color property of some controls from the cs files, and I have encountered two problems:

1.我在App.xaml中创建了<Application.Resources>,但我却找不到在线说明中所述的<Style.Triggers>(是最近取出的吗?

1.I create <Application.Resources> in App.xaml, I could never find <Style.Triggers> as the instructions online says(is it taken out recently?

2.我想更改.cs文件中特定按钮的前景色,我使用了button_1.Foreground = new SolidColorBrush(Colors.Red),但是编译器报告错误,提示名称'Colors'在当前上下文中不存在",我还尝试了RGB和#ffffffff等,没有任何效果.

2.I want to change the foreground color of a particular button in the .cs file, and I used button_1.Foreground = new SolidColorBrush(Colors.Red), but the compiler reports error saying "The name 'Colors' does not exist in current context", I also tried RGB and #ffffffff and so on, nothing works.

第二个问题的屏幕截图:

Screenshot of the second problem:

推荐答案

您需要使用Colors的完全限定名称,

You need to use the fully qualified name of Colors, like this.

button_1.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);

或在代码窗口顶部添加using指令.

Or add a using directive to the top of your code window.

using Windows.UI;

请参见MSDN上的使用指令

这篇关于Windows Phone 8.1 SolidColorBrush和触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:21