2015-09-27 41 views
-1

我想改变我的按钮的前景,但我得到了一个错误说的Windows Phone - 刷不存在

这里的“名‘刷’并不在目前情况下存在”是代码:

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。

回答

1

答:

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