Partilhar 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.

    JJ170757.5916d585-024e-45f7-a74b-4ef0c3b3c8cf(pt-br,VS.110).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 JJ170757.0d8b8d29-1af9-418f-8741-be3097d76eab(pt-br,VS.110).png in the Tools panel.

  6. In the Assets panel, click All under the Controls category, and then select your new control. Your new control appears underneath the Assets button in the Tools panel as the selected tool. 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.

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

    DicaDica

    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 Blend window. For more information, see Add a new or existing project to a solution.

    DicaDica

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

    DicaDica

    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.

Consulte também

Tarefas

Add a new or existing project to a solution