共用方式為


Import a custom control by adding a reference [BlendforVS_Blend4] [BlendforVS_Blend4]

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.

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

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

    JJ169817.e0f2bcd0-ae8c-434a-8ef0-275828c8eb8c(zh-tw,VS.110).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.

    JJ169817.d89262c0-c8e7-4ebe-83d0-244c1cd5dbcc(zh-tw,VS.110).png

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

    秘訣秘訣

    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.

JJ169817.collapse_all(zh-tw,VS.110).gifTroubleshooting

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

請參閱

其他資源

Add a new or existing project to a solution