Styling tips for WPF Simple Styles
Microsoft Expression Blend enables you to go above and beyond simply working with default or system controls as you design the user interface (UI) for your application. Instead, you can actually customize and style controls to your liking to make them perform the way you want and—through the use of resources in Expression Blend—give them a unique, attractive look to differentiate your application from others as a way to create a highly branded experience or to create a consistent UI across all of your applications.
What are simple styles?
Simple styles are a set of custom, ready-to-use style resources for a set of common system controls, such as the Button and ListBox controls. Expression Blend provides these simple style resources because modifying the style of a system control requires some knowledge of Windows Presentation Foundation (WPF) styles and templates in order to not break the functionality of the control. You can use the simple styles in Expression Blend as a self-contained set of resources that you can quickly modify to create a unique look for your application, without having to start with an understanding of WPF styles and templates.
Creating a simple style control
Simple styles are available in the Assets panel, in the Styles category, by clicking Simple Styles. After you select a simple style from the Assets panel, the icon for the simple style appears underneath the Assets button and is selected, ready to be drawn on the artboard. When you draw a simple style (such as the SimpleButton) onto the artboard, you actually create an instance of the system control (such as the Button), but with the SimpleButton style applied to it.
The Assets panel showing the available simple style controls
The following table lists the available simple styles and the controls to which they apply.
Simple style |
Control to which it applies |
Icon |
---|---|---|
SimpleButton |
Button |
|
SimpleCheckBox |
CheckBox |
|
SimpleComboBox |
ComboBox |
|
SimpleComboBoxItem |
ComboBoxItem |
|
SimpleExpander |
Expander |
|
SimpleLabel |
Label |
|
SimpleListBox |
ListBox |
|
SimpleListBoxItem |
ListBoxItem |
|
SimpleMenu |
Menu |
|
SimpleMenuItem |
MenuItem |
|
SimpleProgressBar |
ProgressBar |
|
SimpleRadioButton |
RadioButton |
|
SimpleRepeatButton |
RepeatButton in a ListBox control |
|
SimpleScrollBar |
ScrollBar |
|
SimpleScrollBarRepeatButtonStyle |
RepeatButton in a ScrollBar control |
|
SimpleScrollViewer |
ScrollViewer |
|
SimpleSeparator |
Separator in a ListBox, Menu, or ToolBar control |
|
SimpleSlider |
Slider |
|
SimpleSliderThumb |
Thumb in a Slider control |
|
SimpleTabControl |
TabControl |
|
SimpleTabItem |
TabItem in a TabControl |
|
SimpleTextBox |
TextBox |
|
SimpleThumbStyle |
Thumb in a ScrollBar in a ListBox control |
|
SimpleTreeView |
TreeView |
|
SimpleTreeViewItem |
TreeViewItem in a TreeView control |
|
SimpleTreeViewItemToggleButton |
ToggleButton in a TreeView control |
Modifying simple styles
The simple style resources are contained in a resource dictionary named SimpleStyles.xaml. After you add a simple style to the artboard from the Tools panel, the SimpleStyles.xaml resource dictionary is added to your project, and all of the simple style resources are visible in the Resources panel.
The SimpleStyles.xaml resource dictionary includes brush resources and other templates that are used by the simple styles. You can make any of the following changes to the simple styles:
**Change the colors ** The colors that are used by all of the simple styles are stored as resources that you can change.
To change one of the color resources, click the down arrow button next to the color resource in the Resources panel.
For information about brushes, see Setting colors, brushes, and masks.
Choosing to edit a brush resource in the Resources panel
**Change the style ** You can use the style of a control in Expression Blend to specify properties and triggers that will be used as defaults by the control to which the style is applied. The properties (such as the background brush color) will affect the control's appearance, and the triggers will affect how the control responds to property changes and events. For example, the SimpleButton style includes a trigger for the IsMouseOver property such that the button's appearance is changed when the user moves their mouse pointer over the control. The trigger occurs when the IsMouseOver property changes from False to True.
To change one of the simple styles, click the Edit Resource button next to the simple style in the Resources panel.
Choosing to edit a style resource in the Resources panel
**Change the control template ** The template of a control defines its appearance by defining the child controls that are contained within the control. For example, the control template for the SimpleTextBox element contains a Grid element, which in turn contains a Border element, which contains a ScrollViewer element named PART_ContentHost. The ScrollViewer element displays the content of the TextBox when the SimpleTextBox style is applied to a TextBox on the artboard. Just like the style, you can set property and event triggers in the control template.
To change the control template for a simple style, click the Edit resource button next to the simple style in the Resources panel, right-click the Style element that appears in the Objects and Timeline panel, point to Edit Template, and then click Edit Current.
Choosing to edit the control template when starting from the editing scope of the style
Tip
Control templates are wrapped inside styles so that the style that is applied to a control includes both the appearance (parts) and the behavior for the control. This is important to remember when choosing between Edit a Copy and Edit Current.
For a detailed comparison between styles and templates, see Styling a control that supports templates.
Applying a style resource to an existing control on the artboard
The simple styles are resources that can be applied and managed like any other resource.
For an example, see Apply a style resource.
For more information about resources, see Creating reusable resources.