Style Inheritance

The Windows SDK includes a generic.xaml file that contains, among other things, the XAML for Styles defined by the framework. You can locate it in %ProgramFiles(x86)%\Windows Kits\8.1\Include\WinRT\Xaml\Design\generic.xaml. This file contains many good examples, including some hidden gems you might want to use or tweak for your apps.

The following Style called BaseTextBlockStyle sets several properties to make a TextBlock match the typical style of labels in apps (and remove those pesky side bearings, explained in Chapter 11, “Text”):

<Style x:Key="BaseTextBlockStyle" TargetType="TextBlock">   <Setter Property="FontSize"           Value="{ThemeResource ControlContentThemeFontSize}"/>   <Setter

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.