Tutorial by Examples

The easiest way to create a style is to copy an existing one and edit it. Create a simple window with two buttons: <Window x:Class="WPF_Style_Example.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsof...
Taking the previous example, removing the x:Key element of the style applies the style to all buttons in the Application scope. <Style TargetType="{x:Type Button}"> <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/> ...
Starting with the following ComboBoxes: <Window x:Class="WPF_Style_Example.ComboBoxWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft....
Having lots of styles in App.xaml will quickly become complex, so they can be placed in separate resource dictionaries. In order to use the dictionary, it must be merged with App.xaml. So, in App.xaml, after the resource dictionary has been created: <Application xmlns="http://s...
The following Window has been created: <Window x:Class="WPF_Style_Example.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/e...

Page 1 of 1