July 8, 2011 1 Comment
We saw how to set the background of a control to a solid color by specifying a color value for the Background property. Similarly, you can set the foreground color of a control using the Foreground property. For controls that contain text, the foreground color is generally the color of the text.
Since the Foreground property’s type is System.Windows.Media.Brush, the property is set to an instance of a Brush object. In XAML, you can set the property using the name of a predefined color, which maps to a predefined SolidColorBrush in the Brushes class.
<Button Content="Take a Trip" Foreground="DarkViolet" Width="100" Margin="10"/>