Programmatically set TextBlock Foreground Color

后端 未结 4 1361
孤城傲影
孤城傲影 2021-01-31 13:30

Is there a way to do this in Windows Phone 7?

I can reference the TextBlock in my C# Code, but I don\'t know exactly how to then set the foreground color of it.

4条回答
  •  悲哀的现实
    2021-01-31 14:21

    You could use Brushes.White to set the foreground.

    myTextBlock.Foreground = Brushes.White;
    

    The Brushes class is located in System.Windows.Media namespace.

    Or, you can press Ctrl+. while the cursor is on the unknown class name to automatically add using directive.

提交回复
热议问题