Export (0) Print
Expand All

Create a reusable template for a system control

This page applies to Silverlight 2 projects only

You can customize the appearance of system controls by modifying a copy of the control's template.

The following procedure uses a button, but you can create a template for any system control that is included with Microsoft Expression Blend 2 or any imported custom Silverlight 2 control that inherits from the Control class.

  1. Draw a system control on the artboard. For example, select the Button Dd185509.05df1779-a68f-436b-b834-a91b7995a3ec(en-us,Expression.10).png tool from the Toolbox, and then use your mouse to draw it on the artboard.

  2. Use the breadcrumb bar at the top of the artboard to create a copy of the button's template. Click [Button], click Edit Control Parts (Template), and then click Edit a Copy.

    Dd185509.40c4d9ae-bf61-4492-b0c8-b090a7b9acfb(en-us,Expression.10).png
    Dd185509.alert_tip(en-us,Expression.10).gifTip:

    You create a copy because you cannot modify the default template for a system control. Alternatively, you could create an empty template and design your button by importing art assets or drawing new objects.

  3. In the Create Style Resource dialog box, enter a name for the template, such as ButtonStyle1.

    Dd185509.4818ee6a-ce60-4b79-91c8-3b1871829eea(en-us,Expression.10).png
  4. Under Define in, select where you want the template to be defined:

    • To make the template available to a button object in any document in your application, select Application.

    • To make the template available only to button objects in the current document, select This document.

    • To make the template available only to this button in this document, select Button from the drop-down box beside This document.

  5. Click OK to exit the dialog box and open the template for editing.

    Dd185509.alert_tip(en-us,Expression.10).gifTip:

    The breadcrumb bar makes it easy to switch between editing the template that is applied to an object, and editing the object itself. For example, to exit template-editing mode, click [Button] in the breadcrumb bar.

    Dd185509.475cc7f7-f134-4a39-8ee7-4a5516a2b812(en-us,Expression.10).png

    To return to template-editing mode, make sure that the button object is selected (to display the breadcrumb bar for the button), and then click Template in the breadcrumb bar.

    Dd185509.5bb586ea-6adc-4672-b316-0fab8215ff8c(en-us,Expression.10).png

Troubleshooting

  • If you do not see the option to Edit Control Parts (Template) in the breadcrumb bar, you might have selected a control that does not support templates. For example, layout panels such as Grid Dd185509.c76bbf09-1922-4f45-8d92-9c8ae64ca4a4(en-us,Expression.10).png do not use templates. Only controls that inherit from the Control class use templates.

  • You cannot create a template for a user control (a control that inherits from the UserControl class), but you can customize a user control by designing it from scratch. For more information, see Create a new user control in your Silverlight 2 project.

Next steps

Community Additions

ADD
Show:
© 2014 Microsoft