Export (0) Print
Expand All

Assign template parts to objects

Ee341414.0b2c798e-86c6-4ea2-a8a6-5cf1f12be1e2(en-us,Expression.40).png

Microsoft Expression Blend makes it easy to design control templates by providing the list of parts for the template in the Parts panel. You can assign those parts to objects in your template in several ways.

For detailed examples of converting objects into the parts of control templates, see the topics under Styling tips for common Silverlight controls.

tip noteTip

If an object in the Objects and Timeline panel is assigned to a part, but the object is a child of a collapsed parent object, the Is a control part icon Ee341414.6cf58c39-edba-4a0e-acbc-1da272f9a387(en-us,Expression.40).png will appear next to the parent object to let you know that the part is contained underneath.

To assign a part to an existing object

  1. In the Objects and Timeline panel, right-click the object that you want to assign to a part, point to Make Into Part of [control name], and then select the part name from the list that appears.

    Converting a Grid of objects into the HorizontalThumb part of a Slider control

    Ee341414.8a982f33-c0ec-4bf5-b892-37f09ede286a(en-us,Expression.40).png
    tip noteTip

    If the Make Into Part of [control name] command is not enabled, you might have more than one object selected. If you want to convert multiple objects into a control, you first have to group them into a layout panel such as a Grid layout panel.

    For more information, see Group or ungroup objects.

  2. If the object that you selected does not match the type of the part, the Make Into Part of [control name] command will attempt to convert the object. If the type of the part is a control that supports templates (such as a Thumb control), your object will be converted into a template for that control. A Make Into Part dialog box will appear. Type a name for your template, select a location where the template will be stored, and then click OK.

    For information about locations, see Create a resource.

    Creating a template for a Thumb control that will be applied to the HorizontalThumb object

    Ee341414.72f2820d-03ea-43e8-a26d-d0bc0ea97c83(en-us,Expression.40).png

    After you click OK, you will be in template-editing mode for the new object. To go back to template-editing mode for the template you started working on, click Return scope to Ee341414.55844eb3-ed98-4f20-aa66-a6f5b23eeb2b(en-us,Expression.40).png in the Objects and Timeline panel, or click the third button in the breadcrumb bar at the top of the artboard.

    Returning to the template that you started with

    Ee341414.6427bc3d-1cf4-44bf-934c-65b82c4c5ee0(en-us,Expression.40).png
  3. An icon Ee341414.6cf58c39-edba-4a0e-acbc-1da272f9a387(en-us,Expression.40).png, indicating that the part has been assigned, appears next to the object in the Objects and Timeline panel, and next to the part in the Parts panel.

    The Grid object converted to a Thumb object and assigned to the HorizontalThumb part

    Ee341414.8dc57bca-b2fb-4ff6-aee2-37f22172bc8e(en-us,Expression.40).png

To assign a part by creating a new object

  1. In the Parts panel, double-click the name of the part that you want to create in your template.

    An object is created in your template and assigned to the part. An icon Ee341414.6cf58c39-edba-4a0e-acbc-1da272f9a387(en-us,Expression.40).png indicating that the part has been assigned appears next to the object in the Objects and Timeline panel, and next to the part in the Parts panel.

  2. You can now modify the newly-created object.

    tip noteTip

    When you create an object by double-clicking a part in the Parts panel, only the root object is created, so that you can fully customize the object. For example, when you double-click the ScrollViewer part while modifying the template of a ListBox control, a ScrollViewer object is created in the template, but it does not contain a child ItemsPresenter object, as the default ListBox template does. This allows you to choose the items control that you want to use. Content will not appear in your customized ListBox object until you add an ItemsPresenter or other items control as the child object of the ScrollViewer object in the template.

    For more information about individual control templates, see the topics under Styling tips for common Silverlight controls.

To fix a broken part assignment

If you converted objects into a control using the Make Into Control command, and an object had the same name as one of the control parts but not the correct type, the part assignment will not work. You can clear the incorrect part assignment and then convert the object into the part.

  1. In the Objects and Timeline panel, right-click the object that is incorrectly assigned to a part, and then click Clear Part Assignment.

    The icon Ee341414.01c42440-bc71-4448-bc6a-1f6c790e6021(en-us,Expression.40).png that indicated that the part was incorrectly assigned is removed from next to the object in the Objects and Timeline panel. In the Parts panel, an icon Ee341414.64d085f2-3d49-4b74-8070-4d7dae18dc28(en-us,Expression.40).png indicating that the part is now unassigned appears next to the part.

  2. If the part was incorrectly assigned because the object is not the correct type, you might be able to convert the object into the correct type. Right-click the object, click Make Into Part of [control name], and then click the name of the part from the list that appears.

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft