Make a control from existing objects

This page applies to WPF projects only

If you have an idea for the design of a control, and you cannot use one of the system controls that come with Microsoft Expression Blend 2, you can create your control on the artboard by drawing the components of your control, and then converting those components to a reusable user control (also named a UserControl).

To make a control from existing objects on the artboard

  1. Click the Selection Cc296387.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.10).png tool. Hold the SHIFT key when you select both of your rectangles.

  2. Right-click the selected objects, click Group into, and then select the Canvas panel from the pop-up menu. The rectangles become child objects of a new layout panel.


    You can select and right-click objects either on the artboard or under Objects and Timeline (as in the following image).


    There are many different types of layout panels, each with a different layout scheme. In a Canvas panel, the child objects will not resize with your application window. In a Grid panel, you can configure child objects to autosize and set the alignment and margin properties under Layout in the Properties panel to let the child objects resize with your application window.

  3. Right-click the new canvas object under Objects and Timeline, and then select Make Control from the pop-up menu.


    The Make Control dialog box appears.


    You can leave the fields as they are and click OK.

    A new user control is created, opened for editing, and visible in the Project tab.


  4. Build your application (CTRL+SHIFT+B). This will save your files, let the user control be displayed in the main document, and make it available from the Custom Controls tab of the Asset LibraryCc296387.0224cabd-5da1-4e01-bddd-4a647401a098(en-us,Expression.10).png so that you can use it again.


Next steps

  • You can also make a button from existing objects. This gives you a new button template instead of a new user control. For more information, see Make an object into a button.

  • As an alternative to a user control that inherits from the UserControl class, you can create a custom control that inherits from the Control class or from the system controls that come with Expression Blend 2 (because they also inherit from Control). Such custom controls are compiled into DLL files that you can reference in your project so that you can draw the custom controls on the artboard. Controls that inherit from the Control class can use templates, just like the system controls. For more information, see Try it: Create a custom WPF control and Create or edit a control template.

See also


Create a control from existing objects

Make an object into a button

Change the design-time size of a user control