Here’s an interesting little experiment. Put a simple TextBlock in the content grid with a very large FontSize set:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="Hello!"
FontSize="96"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
As you know, you can move that FontSize setting from the TextBlock to the PhoneApplicationPage tag (replacing the existing FontSize setting) and you’ll get the same effect:
<phone:PhoneApplicationPage . . .
FontSize="96"
. . . >
. . .
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="Hello!"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
. . .
</phone:PhoneApplicationPage>
That’s property inheritance at work. Now put the TextBlock in a Button. You can make the text very large by setting the FontSize on the TextBlock:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Text="Hello!"
FontSize="96" />
</Button>
</Grid>
Or, you can achieve the same effect by setting the FontSize on the Button itself:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="96">
<TextBlock Text="Hello!" />
</Button>
</Grid>
But what doesn’t work is setting the FontSize on the PhoneApplicationPage. It seems as if property inheritance should cause the value to trickle down to the TextBlock:
<phone:PhoneApplicationPage . . .
FontSize="96"
. . . >
. . .
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Text="Hello!" />
</Button>
</Grid>
. . .
</phone:PhoneApplicationPage>
But it doesn’t work. Something is blocking the TextBlock from inheriting that FontSize value.
Button is defined in the System.Windows library, and that library also contains a default style and template for the Button. This is known as a theme style, and for the Button it includes a style setting for the FontSize property. In regular Silverlight, that’s not the case, but the developers of Windows Phone 7 apparently decided that text in a Button needed to be a little larger by default to provide a more substantial touch target. So they gave this default theme style a FontSize property, and that setting has precedence over property inheritance.
That table can now be enpanded:
Local Settings have precedence over
Style Settings, which have precedence over the
Theme Style, which has precedence over
Property Inheritance, which has precedence over
Default Values