Compartilhar via


Import a custom control by adding a reference

As a designer, you might receive an assembly file (DLL) that contains a custom control that you have to use in your project. To be able to draw these kinds of controls on the artboard, you must first add a reference to the assembly.

To draw a custom control on the artboard

  1. On the Project menu, click Add Reference (ALT+SHIFT+R).

  2. In the Add Reference dialog box, browse to the DLL file that contains the custom control, and then click Open.

    In the Projects panel, under References, the DLL file appears in the list of default project references.

    Dd185501.5916d585-024e-45f7-a74b-4ef0c3b3c8cf(en-us,Expression.30).png

  3. Build your project (CTRL+SHIFT+B) to incorporate the classes from the DLL into your project.

  4. Open a XAML file on the artboard (such as MainPage.xaml) by double-clicking the name of the file in the Projects panel.

  5. Click Assets Dd185501.0d8b8d29-1af9-418f-8741-be3097d76eab(en-us,Expression.30).png in the Tools panel.

  6. In the Assets panel, click All under the Controls category, and then select your new control.

    Dd185501.e0f2bcd0-ae8c-434a-8ef0-275828c8eb8c(en-us,Expression.30).png

    Your new control appears underneath the Assets button in the Tools panel as the selected tool.

  7. Using your mouse, draw the custom control on the artboard.

    The control appears on the artboard and in the Objects and Timeline panel.

    Dd185501.d89262c0-c8e7-4ebe-83d0-244c1cd5dbcc(en-us,Expression.30).png

  8. Test your project (F5) to see the new control.

    Tip

    As an alternative to adding a reference to a .dll file, you can add a reference to an uncompiled project. Add the project to your solution and then add the project reference to the first project. This is useful if you want to work on both projects at the same time in the same Expression Blend window. For more information, see Add a new or existing project to a solution.

Troubleshooting

  • If you cannot see the custom control displayed in the Project category of the Assets panel, try building the project.

  • After you draw your new control on the artboard, if it appears clipped, it might be because the control has default layout properties that are incompatible with the size of the control when you first drew it. With the new control selected in the Objects and Timeline panel, reset the Margin properties to 0 under Layout in the Properties panel, and then try to resize the control again.

See also

Tasks

Add a new or existing project to a solution