Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Phone-笔刷不存在_C#_Windows Phone - Fatal编程技术网

C# Windows Phone-笔刷不存在

C# Windows Phone-笔刷不存在,c#,windows-phone,C#,Windows Phone,我想更改按钮的前景,但出现了一个错误,提示“当前上下文中不存在名称“笔刷” 代码如下: private void AddButton_Click(object sender, RoutedEventArgs e) { Button but = new Button(); but.Content = "Task"; but.Background = (SolidColorBrush)Application.Current.Resources

我想更改按钮的前景,但出现了一个错误,提示“当前上下文中不存在名称“笔刷”

代码如下:

 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);
    }
另外,使用系统。绘图不起作用。 我尝试了几种选择,但我的应用程序也无法识别Windows.UI.Color。

答案:

but.Foreground = new SolidColorBrush(Colors.Orange);