Create a user control from existing objects
In Blend for Visual Studio 2012, 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
In the Objects and Timeline panel, hold down 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 when you hold down the Ctrl key to select the objects on the artboard.
注意事項 Only objects that are contained in the same parent object can be grouped into a new user control.
Do one of the following:
Right-click the selection and then click Make Into UserControl.
On the Tools menu, click Make Into UserControl (F8).
The Make Into UserControl dialog box appears.
In the Name field, enter a name for your new user control.
Click OK.
Blend creates a new user control document and opens it for additional editing.
Switch back to your original document. If you allowed Blend 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 Project (Ctrl+Shift+B).
重要
When you use the Make Into UserControl 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.