Search code examples
c#windows-phone

Windows Phone - Brushes does not exist


I want to change the foreground of my button, but I got an error saying "The name 'Brushes' does not exist in the current context"

Here is the code :

 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);
    }

Plus, using System.Drawings doesn't work. I tried several alternatives, but my application doesn't recognize Windows.UI.Colors neither.


Solution

  • Answer:

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