Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
Windows Phone

The App Bar and Controls - Theme Styles and Precedence

- 2015 Chevrolet Camaro Z28 - The Legend Returns
- Wagon Audi Allroad Vs. Subaru Outback
- 996 Carrera 4S is Driving Perfection
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

Top Search -----------------
- Windows Server 2008 R2 : Work with RAID Volumes - Understand RAID Levels & Implement RAID
- Windows Server 2008 R2 Administration : Managing Printers with the Print Management Console
- Configuring Email Settings in Windows Small Business Server 2011
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Implement Permissions
- Monitoring Exchange Server 2010 : Monitoring Mail Flow
- Windows Server 2008 R2 :Task Scheduler
- Windows Server 2008 R2 : File Server Resource Manager
- Windows Server 2008 R2 : Installing DFS
- Exchange Server 2010 : Managing Anti-Spam and Antivirus Countermeasures
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Share Folders
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
 
 
Most view of day
- Microsoft Outlook 2010 : Processing Messages Automatically - Using Rules to Move Messages Between Accounts & Running Rules Manually and in Specific Folders
- Accessing and Using Your Network : Working with Offline Files and the Sync Center (part 2) - Synchronizing Offline Files, Handling Synchronization Conflicts
- Active Directory Domain Services 2008 : Manage Active Directory Domain Services Data - Move User Object
- Windows 7 : Virtualization (part 2) - Native Hard Disk Support in Windows 7
- The Two Templates : Custom Controls
- Windows Server 2008 R2 : Remote Desktop Services - Why Implement Remote Desktop Services
- Working with the Windows Home Server 2011 Registry : Starting the Registry Editor & Navigating the Registry
Top 10
- Windows Phone 8 : Configuring Basic Device Settings - Providing Feedback
- Windows Phone 8 : Configuring Basic Device Settings - About Your Phone
- Windows Phone 8 : Configuring Basic Device Settings - Find My Phone
- Windows Phone 8 : Configuring Basic Device Settings - Accessibility (part 2) - Enabling the Screen Magnifier, Using Speech for Phone Accessibility
- Windows Phone 8 : Configuring Basic Device Settings - Accessibility (part 1) - Adjusting the Text Size, Enabling High Contrast
- Microsoft Visio 2010 : Linking External Data to Shapes (part 6) - Using Link Data - Linking Data to Shapes Using Link Data
- Microsoft Visio 2010 : Linking External Data to Shapes (part 5) - Using Link Data - Preparing a Master for Link Data , Importing Data for Link Data
- Microsoft Visio 2010 : Linking External Data to Shapes (part 4) - Using the Database Wizard - Taking the Data-Linked Light Bulb Shape for a Spin
- Microsoft Visio 2010 : Linking External Data to Shapes (part 3) - Using the Database Wizard - Setting Up the Excel File as a Data Source
- Microsoft Visio 2010 : Linking External Data to Shapes (part 3) - Using the Database Wizard - Setting Up the Excel File as a Data Source
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro