O'Reilly logo

Microsoft® Silverlight® Edition: Programming Windows® Phone 7 by Charles Petzold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Colors and Brushes

Let’s return the TextBlock to its pristine condition:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <TextBlock Text="Hello, Windows Phone 7!" />
</Grid>

The text shows up as white (or black, depending on the theme your selected) because the Foreground property is set on the root element in MainPage.xaml. You can override the user’s preferences by setting Background for the Grid and Foreground for the TextBlock:

<Grid x:Name="ContentPanel" Background="Blue" Grid.Row="1" Margin="12,0,12,0">
    <TextBlock Text="Hello, Windows Phone 7!"
               Foreground="Red" />
</Grid>

The Grid has a Background property but no Foreground property. The TextBlock has a Foreground property but no Background property. The Foreground property is inheritable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required