All of Xceed's WPF themes define implicit styles for Page and Window, which will set certain general properties, such as Background, Foreground, and sometimes FontFamily. However, in a typical application, Page- and Window-derived classes are used instead of the base classes, to which implicit styles are not applied. There are three ways to accomplish this manually.
1. Assign the desired properties using the theme resource files.
XAML |
Copy Code |
---|---|
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xcpt="http://schemas.xceed.com/wpf/xaml/themes" Background="{x:Static xcpt:GlassResources.ApplicationBackgroundBrush}"> |
2. Define an implicit style using a BasedOn of the implicit Page or Window style. The advantage of this method is that it will work with any theme.
XAML |
Copy Code |
---|---|
<Page x:Class="WpfApplication1.Page1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xcpt="http://schemas.xceed.com/wpf/xaml/themes" xmlns:local="clr-namespace:WpfApplication2"> <Page.Resources> <Style TargetType="local:Page1" BasedOn="{StaticResource {x:Type Page}}" /> |
3. Define an implicit style using a BasedOn of a style exposed by a property in a theme resource file.
XAML |
Copy Code |
---|---|
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xcpt="http://schemas.xceed.com/wpf/xaml/themes" xmlns:local="clr-namespace:WpfApplication2"> <Window.Resources> <Style TargetType="local:Window1" BasedOn="{x:Static xcpt:GlassResources.WindowStyle}" /> |