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.I create <Application.Resources>
in App.xaml, I could never find <Style.Triggers>
as the instructions online says(is it taken out recently?
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:
You need to use the fully qualified name of Colors, like this.
button_1.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
Or add a using directive to the top of your code window.
using Windows.UI;
See Using Directives on MSDN
来源:https://stackoverflow.com/questions/30837529/windows-phone-8-1-solidcolorbrush-and-trigger