Share via


Drawing text (Blend for Visual Studio)

There are different types of text controls, for example, rendering text controls (TextBlock, RichTextBlock), text-entry or text input controls (TextBox, PasswordBox). The XAML framework for Windows Store apps provides several controls for rendering text, and a set of properties for formatting the text. Text input controls let users enter and edit a text or numeric value. Blend for Visual Studio 2012 allows you to easily add or modify some of these text properties on the designer surface.

Working with text controls

Many aspects of working with text controls are the same as working with any other objects or controls in 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 Brush and Appearance.

Certain attributes 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.

  • Brush 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.

Modifying the content of a text control

To modify the content of a text control at design time in 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 content from another source (such as a web page or Microsoft Word document) and paste it into the text control. If you copy rich text, the formatting will be preserved if you are pasting into a TextBlock control, and to some extent, if you’re pasting into a TextBox control. Images can also be added to these text controls by dragging the image from in the Projects panel, or from outside Blend. For more information, see Edit text (Blend for Visual Studio).

You can also set the content of a text control by binding the relevant property (for example, the Content property of a Button or the Text property of a TextBlock) to data.

Making text editable in your application

You can control whether users of your Blend application can change the text that is contained in certain types of text controls (TextBox, 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 (Blend for Visual Studio).

Laying out text

You can use text controls in Blend in layout containers, just as you can any other object, and you draw them the same way. The text control shows more or less of its content depending on how you size the layout container.

When you put a text control in a layout container, you can anchor 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 resizes to always keep that relationship intact. You can control the size of a text control even more by letting the text control expand or decrease either to the container (auto-size) or to the container with a minimum and maximum limit set, or by fixing the size of the control to absolute values.

Transforming text

You can transform text control objects in Blend just as you can any other vector object. Text in a text object remains editable even after you transform the object. Additionally, any changes that you or users 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.