Compartilhar via


Create a control from existing objects

This page applies to WPF and Silverlight 2

In Microsoft Expression Blend 2, you can select a container of objects and make them into a user control, which you can then reuse in your project, or in other projects.

To create a control from existing objects

  1. Under Objects and Timeline, hold the CTRL key when you select all the objects that you want to become the new user control. Alternatively, you can use the Selection tool Cc295376.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.10).png when you hold the CTRL key to select the objects on the artboard.

    Note

    Only objects that are contained in the same parent object can be grouped into a new user control.

  2. Do one of the following:

    • Right-click the selection and then click Make Control.

    • On the Tools menu, click Make Control (F8).

    The Make Control dialog box appears.

    Cc295376.2a301fcf-3ece-4254-a3d1-654ad98cb9a7(en-us,Expression.10).png

  3. In the Name field, enter a name for your new user control.

  4. If you want to create the new user control without replacing the original elements in your document, select the Leave original content as is and create duplicates as necessary box.

  5. Click OK.

    Expression Blend 2 creates a new user control document and opens it for additional editing.

  6. Switch back to your original document. If you allowed Expression Blend 2 to replace the selected controls with the new user control, you will have to build your project to see the new control. On the Project menu, click Build Solution (CTRL+SHIFT+B).

    Important

    When you use the Make Control command, the selected objects, their referenced resources, and referenced animations are refactored into the new user control. However, if the objects include event handler methods in the code-behind file of the original document, you will have to copy the event handler code to the code-behind file of the new user control document.