Controls overview
Microsoft Expression Blend provides an extensive list of controls that enable you to design a versatile user interface for your Windows Presentation Foundation (WPF) and Silverlight 2 applications.
Note
For a list of controls that are available in Microsoft Silverlight 1.0 projects, see the "Controls" section of the Overview of Silverlight 1.0.
Expression Blend enables you to go above and beyond simply working with default or system WPF controls. Instead, you can actually customize and style controls to your liking to make them perform the way you want. You can also—through the use of resources in Expression Blend—give your custom controls a unique, attractive look, to differentiate your application from others as a way to create a highly branded experience or to create a consistent user interface (UI) across all of your applications. One of the greatest benefits of the control editing model that is present in Expression Blend is that designers can design the appearance of an application at the same time that developers are writing the programming logic. Because a designer can create a design directly, the design won't get lost in translation from mockup to implementation.
What are controls?
Controls (or UI design elements) are the visible components of an application. Controls (such as buttons or lists of selectable items) make it possible for users to interact with your application. If you understand the controls that are available to you in Expression Blend and how to customize them, you can make your application look and behave exactly the way you want.
Expression Blend makes it possible for you to work with controls visually on the artboard, and to configure their appearance and behavior in the Properties panel and Interaction panel. For example, you can add a Button control to the artboard, change its appearance by modifying values in the Properties panel, and then start an animation timeline when the button is clicked by adding an event trigger for the button in the Interaction panel.
Beyond those simple actions, you can also do the following things to a control:
Convert a property (such as a brush color) into a resource that you can apply to other controls to create a unique and consistent look for your application. For an example, see Create a resource.
Create a new template and style for a control that defines its appearance and behavior, also resulting in a unique and consistent look for your application. Templates and styles can include triggers and can use resources to set properties. For more information, see Styles and templates below. For WPF examples, see Create a style resource and Create or edit a control template. For Silverlight 2 examples, see Create a reusable template for a system control and Create a skin for a control in a Silverlight 2 project.
Add animations and interactivity to your control. For an example, see Create simple animation.
Program more complicated behavior for your control in event handler methods in a code-behind file. For a WPF example, see Create a new event handler method. For a Silverlight 2 example, see Load a new page dynamically in your Silverlight 2 application.
Design your own custom controls and use them in Expression Blend. For WPF examples, see Try it: Create a custom WPF control and Try it: Create a WPF user control. For a Silverlight 2 example, see Create a new user control in your Silverlight 2 project.
Back to top
Categories of controls
In Expression Blend, you can use many different types of controls to quickly design a visually unique application.
All of the controls are available from the Asset Library by clicking the Asset Library button at the bottom of the Toolbox. The Toolbox is along the left side of Expression Blend. When you select a UI element from the Asset Library, the icon for that element appears above the Asset Library button, enabling you to easily select that element again later. The most common UI elements are already displayed above the Asset Library button so that you can locate them quickly.
The following illustration shows the artboard after some of the common UI elements have been added as objects. The Pen tool generates a Path object. The Image icon appeared in the Toolbox after the Image control was selected from the Asset Library.
From the Toolbox to the artboard
A path object named Path_40, representing the shape of the orange color swatch. |
An unnamed button object, representing the button in the application that is labeled "Reset Image". Under Objects and Timeline, the underscore (_) is used to identify the access key for the button. |
||
A rectangle object named Rectangle_44, representing one of the paint chips on the color swatch. |
An image object named photo_bathroom, representing the background image of the room. |
||
An unnamed text block identified by the text that it contains, representing the title of the application, "Color Swatch Sample Pack 1". |
To help you decide which control to use, think of the controls in terms of the following categories:
Category |
Use |
Examples |
---|---|---|
Shapes (available in Silverlight 1.0 projects) |
Used to create rich visual elements by using ellipses, lines, and rectangles, whose appearance you can make as simple or as complex and colorful as you wish. For more information, see Drawing shapes and paths. You can customize the appearance and behavior of these elements in Expression Blend by using the Properties panel, or by using styles only (not by using templates). For more information, see Edit a style. |
Rectangle Ellipse Path (generated by the Line , Pen , and Pencil drawing tools) |
Layout panels |
Used as a container for other UI elements, to specify their position and window resizing behavior. Unlike most UI elements, some layout panels (such as the Grid) can contain more than one child element. This is useful for organizing and laying out your application design. For more information, see Layout. You can customize the appearance and behavior of these elements in Expression Blend by using the Properties panel, or by using styles (not templates). For more information, see Edit a style. |
Canvas (available in Silverlight 1.0 projects) Dock Grid Stack Wrap |
Document/Text |
Used to define document presentation and text formatting. For more information, see the Text and typography overview. You can customize the appearance and behavior of these elements in Expression Blend by using the Properties panel, or by using styles and templates. For more information, see Create or edit a control template and Edit a style. |
TextBox TextBlock (available in Silverlight 1.0 projects) RichTextBox Label PasswordBox |
Controls |
Used to provide a way for your user to interact with your application. You can customize the appearance and behavior of these elements in Expression Blend by using the Properties panel, or by using styles and templates. For more information, see Create or edit a control template and Edit a style. |
Button ListBox Menu RadioButton CheckBox |
Decorators |
Used to apply effects to another element. Decorators can include a single child element, usually the element whose appearance they affect. Typically these elements are used within templates that are applied to other controls, for example, the ButtonChrome element in the template of a button. You can customize the appearance and behavior of the Decorator elements themselves by using the Properties panel, or by using styles only (not by using templates). For more information, see Edit a style. |
Border ButtonChrome Viewbox |
For more information about the characteristics of these control types, see the topic Type Families in the Windows Presentation Foundation section of MSDN.
Back to top
Creating and modifying controls
You can add a control to the artboard by double-clicking its icon in the Toolbox, or by selecting its icon in the Toolbox and then using your mouse to draw the element on the artboard. For more information, see the how-to topics listed in Controls. Double-clicking a control in the Asset Library inserts the control into the current active element at a default size. This is useful because in many cases the default size will be set to Auto so that the control will size correctly as content is added to it.
After you add a control to the artboard in Expression Blend, it becomes an object in your application. You can modify objects in many ways by using on-object handles to resize, move, rotate, flip, or skew the objects, or by using the Properties panel where you can enter precise values for size, position, and rotation. For more information, see Add or modify an object, or see the how-to topics that are listed in Working with objects and properties.
Expression Blend is unique in the way in which it allows you to manipulate controls. You can place any other control, panel, or shape element within a control. This is useful in combining controls together. For example, if you want to create a button with an image and text in it, you simply place a Stack panel control into the button and then add an image and text control into the Stack panel.
Controls follow certain inheritance rules. For instance, some controls act as a parent element and can have child elements (content) nested within them. Other controls do not support child elements. Expression Blend always attempts to add child elements to the root (or topmost panel) within a document. This means that the LayoutRoot element is considered the root when you first start working in Expression Blend and will, by default, be the destination for all child elements that you insert into the document. If you want to add child elements to a different control within a document, you need to activate that control by double-clicking its name under Objects and Timeline. A yellow highlight identifies the activated element so that you know where a new control will be added.
Expression Blend supports the following different types of controls, which are categorized by the type of inheritance that they support:
Category |
Description |
Examples |
---|---|---|
Simple controls |
Simple controls consist of the controls themselves and the properties that can be set on them. Simple controls do not take content. In other words, they cannot have child elements within them. |
Image (available in Silverlight 1.0 projects) ScrollBar |
Content controls |
Content controls can take another element (or can show a string as text for simple scenarios). Content controls have a Content property. This means that they can contain singular content such as a string. Also, content controls can contain another element, such as a layout panel. For an example, see the topic Create a content control. |
CheckBox RadioButton |
Items controls |
Items controls include a collection of child elements. You can either manually add items to the Items collection property, or you can bind a data collection to the ItemsSource property. Items controls expose items collections and have no Content property and no Header property. For an example, see the topic Create an items control. |
ComboBox ListBox |
Headered controls |
Headered controls include a header child element that labels the control. Headered controls can either include content (headered content control) or a collection of items (headered items control). For an example, see the topic Create a headered control. |
TabControl TabItem MenuItem |
For more information about the characteristics of these control types, see the topic "Content Models" in the Windows Presentation Foundation section of MSDN.
Back to top
Styles and templates
As mentioned previously under Controls overview, you can customize controls in many ways, including by creating templates and styles for controls, resulting in a unique and consistent look for your application. Templates and styles define the pieces that make up a control and the default behavior of the control, respectively. You create templates and styles by making copies of the default system styles and templates for a control (because you can't modify system styles and templates). Modifying templates and styles is an easy way to essentially make new controls in Design view of Expression Blend, without having to use code. For more information, see the Style and template overview.
Back to top