Assign template parts to objects
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.
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 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
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 Tip
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.
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
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 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
An icon , 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
To assign a part by creating a new object
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 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.
You can now modify the newly-created object.
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.
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 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 indicating that the part is now unassigned appears next to the part.
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.