Search code examples
windows-phone-8.1textblockforeground

How to set the foreground property of a TextBlock in C# for Windows Phone


For some reason I am having a problem setting the foreground of a TextBlock.

I've tried:

  • new SolidColorBrush(Windows.UI.Color); but there is no Color.White or any colors for that matter.
  • I can't find a Brushes.Color class

I'm working on a Windows Phone 8.1 app.


Solution

  • It must be the Colors class (but not Color). Example:

    var textblocks = new TextBlock() { Height = box_height, Width = box_width, Text = "Hello", FontSize = 30, Foreground = new SolidColorBrush(Colors.Black) };