- Types of text controls
- Working with text controls
- Making text editable in your application
- Using text in layout
- Transforming text
Because Microsoft® Expression Blend™ is used for creating a rich user interface for Microsoft Windows-based applications, text in Expression Blend is handled differently from text in other design tools. In Expression Blend, you can use the following types of text controls to include text in your application: TextBox, RichTextBox, TextBlock, PasswordBox, Label, and FlowDocumentScrollViewer.
|You can use other controls, such as a Button or Checkbox, to include text coupled with other functionality in your application. Those other controls do not allow for rich text editing.|
|TextBox||Provides an editable region that accepts text input. Use this control when you want users to be able to enter new text or edit existing text in your application. You can specify the font of the text at design time.|
|RichTextBox||Provides the same functionality as a TextBox object, but supports more text formatting properties and can contain any other type of object, such as an image or shape. Use this control when you want users to be able to enter rich text in multiple fonts with images and other objects.|
|TextBlock||Provides a block of static text that the users of your application cannot edit. A TextBlock can contain any other type of object, such as an image or shape. Use this control when you need to give instructions to your users, or otherwise to convey information that doesn't need to be edited. Note that while text within this type of control cannot be edited by users of your application, you can change the text via the code-behind file.|
|PasswordBox||Provides basic password functionality. Use this control to add privacy in your application, so that the text that a user enters within the text control will be displayed by using bullet point characters or another character that you specify in the PasswordChar property, instead of as the characters that the user types.|
|Label||Provides a block of static content that you can use for basic labeling of other controls or user interface (UI) elements. A Label can either contain text or content (such as an image or shape) but not both text and content at once. Additionally, this control provides mnemonic support, which offers functionality for keyboard accessibility and navigation through labeled controls that the user can access by pressing the ALT key in Windows-based applications.|
|FlowDocumentScrollViewer||Provides a block of static text that has a scrollbar so the user can navigate through the text, and can contain any other type of object, such as an image or shape. You can set properties for this control under Miscellaneous in the Properties panel, to hide or show the vertical and horizontal scrollbars.|
Many aspects of working with text controls are the same as working with any other objects or controls in Expression Blend. As with other objects, you can set the size and other layout properties of text control objects under Layout and Transform in the Properties panel. Likewise, you can set visual properties under Brushes and Appearance.
There are certain attributes that are unique to text control objects. You can modify these attributes in the following areas of the Properties panel, depending on the type of text control you are using:
- Text Change typographic properties such as font and paragraph alignment.
- Brushes and Appearance Change visual properties such as color and opacity.
- Layout and Transform Change size, layout, shape, and positioning.
- Common Properties and Miscellaneous Change functional properties such as whether a text box includes a scroll bar.
To edit the content of a text control at design time in Expression Blend, select the control and press F2, or double-click the control on the artboard. When in this editing mode, you can set the properties in the preceding list, or type text directly into the control. You can also copy from another source (such as a Web page or Microsoft Word document) and paste into the text control. If you copy rich text and other objects such as images, the formatting and objects will be preserved if you are pasting into the RichTextBox, TextBlock, or FlowDocumentScrollViewer controls. For more information, see Edit Text.
You can control whether users of your Expression Blend application can edit the text that is contained within certain types of text controls (TextBox, RichTextBox, PasswordBox) in the application. For example, you can control whether users can enter new values or change existing values, or whether the text in your application is read-only. You can also disable text boxes in your application, so that functionality such as selection or scrolling is unavailable. By default, text boxes that you add to your application are editable and enabled. For more information, see Make text editable or read-only.
You can use text controls in Expression Blend within layout containers, just as you can any other object, and you draw them in the same way. The text control will show more or less of its content depending on how you size the layout container. In addition, RichTextBox, TextBlock, Label, and FlowDocumentScrollViewer text control objects themselves can contain other objects or controls.
When you place a text control within a layout container, you can fix the edges of the text control to the edges of the container by using margins. When you set a margin and link alignment to that edge, the text control will resize to always keep that relationship intact. You can control the size of a text control even more by letting the text control either size to the container (auto-size) or size to the container with a minimum and maximum limit set, or by fixing the size of the control to absolute values.
You can transform text control objects in Expression Blend just as you can any other vector object. Text within a text object remains editable even after you transform the object. Additionally, any changes that you or the user of your application make to the content of a text control object, whether the changes are made during design time or during run time, will inherit the transformation that is applied to the parent control.