Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Phone

The App Bar and Controls - Theme Styles and Precedence

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3/17/2011 4:39:26 PM
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

Other -----------------
- The App Bar and Controls - The Concept of Content
- The App Bar and Controls - The Basic Button
- The App Bar and Controls - RangeBase and Slider
- The App Bar and Controls - Elements and Controls
- The App Bar and Controls - Jot and the ApplicationBar
- The App Bar and Controls - Jot and Touch
- The App Bar and Controls - Jot and Application Settings
- The App Bar and Controls - ApplicationBar Icons
- Issues in Application Architecture - Xna Tombstoning and Settings
- Issues in Application Architecture - Isolated Storage
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server