This is my first time working with Microfoft Expression Blend. My project is Silverlight Prototype(sketchflow). I have a TextBox(TextBox = logUser) and I want to change it's Foreground color.
I tried logUser.Foreground = Brushes.Black
which I read in a different post(How do you change the text colour of a label programmatically in Microsoft Expression Blend 4), but it doesn't work.
Silverlight does not have a Brushes class , hence it throws you an error .
I went through the defination of System.Windows.Media and got to know that it provides you a SolidColorBrush which is inherited from Brush
#region Assembly System.Windows.dll, v2.0.50727
using System.Windows;
using System.Windows.Markup;
namespace System.Windows.Media
{
// Summary:
// Paints an area with a solid color.
[ContentProperty("Color", true)]
public sealed class SolidColorBrush : Brush
{
// Summary:
// Identifies the System.Windows.Media.SolidColorBrush.Color dependency property.
//
// Returns:
// The identifier for the System.Windows.Media.SolidColorBrush.Color dependency
// property.
public static readonly DependencyProperty ColorProperty;
// Summary:
// Initializes a new instance of the System.Windows.Media.SolidColorBrush class
// with no color.
public SolidColorBrush();
//
// Summary:
// Initializes a new instance of the System.Windows.Media.SolidColorBrush class
// with the specified System.Windows.Media.Color.
//
// Parameters:
// color:
// The color to apply to the brush.
public SolidColorBrush(Color color);
// Summary:
// Gets or sets the color of this System.Windows.Media.SolidColorBrush.
//
// Returns:
// The brush's color. The default value is System.Windows.Media.Colors.Transparent.
public Color Color { get; set; }
}
}
So to achieve what you are looking for , you will have to use SolidColorBrush like below :
logUser.Foreground = new SolidColorBrush(Colors.Black);