Windows Phone - 笔刷不存在
Windows Phone - Brushes does not exist
我想更改按钮的前景,但我收到一条错误消息 "The name 'Brushes' does not exist in the current context"
这是代码:
private void AddButton_Click(object sender, RoutedEventArgs e)
{
Button but = new Button();
but.Content = "Task";
but.Background = (SolidColorBrush)Application.Current.Resources["PhoneAccentColor"];
but.Foreground = Brushes.Blue; //error here
TaskPanel.Children.Add(but);
}
此外,使用 System.Drawings 无效。
我尝试了几种替代方法,但我的应用程序也无法识别 Windows.UI.Colors。
答案:
but.Foreground = new SolidColorBrush(Colors.Orange);
我想更改按钮的前景,但我收到一条错误消息 "The name 'Brushes' does not exist in the current context"
这是代码:
private void AddButton_Click(object sender, RoutedEventArgs e)
{
Button but = new Button();
but.Content = "Task";
but.Background = (SolidColorBrush)Application.Current.Resources["PhoneAccentColor"];
but.Foreground = Brushes.Blue; //error here
TaskPanel.Children.Add(but);
}
此外,使用 System.Drawings 无效。 我尝试了几种替代方法,但我的应用程序也无法识别 Windows.UI.Colors。
答案:
but.Foreground = new SolidColorBrush(Colors.Orange);