Export (0) Print
Expand All

Import a custom control by adding a reference

This page applies to Silverlight 2 projects only

As a designer, you might receive an assembly file (DLL) that contains a custom control that you have to use in your project. Or, you might want to use the controls that are available in the Silverlight 2 Software Development Kit (SDK) in your project. To be able to draw these kinds of controls on the artboard, you must first add a reference to the assembly.

  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 Project panel, under References, the DLL file appears in the list of default project references.

    Dd185501.5916d585-024e-45f7-a74b-4ef0c3b3c8cf(en-us,Expression.10).png
    Dd185501.alert_tip(en-us,Expression.10).gifTip:

    To be able to use the controls that come with the Silverlight 2 SDL, add a reference to the correct assembly located in the C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client folder. For example, to draw a TabControl, add a reference to the System.Windows.Controls.dll assembly.

  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 Page.xaml) by double-clicking the name of the file in the Projects panel.

  5. Click the Asset Library Dd185501.0224cabd-5da1-4e01-bddd-4a647401a098(en-us,Expression.10).png button in the Toolbox.

  6. In the Asset Library, select the Custom Controls tab, and then select your new control.

    Dd185501.e0f2bcd0-ae8c-434a-8ef0-275828c8eb8c(en-us,Expression.10).png
    Dd185501.alert_tip(en-us,Expression.10).gifTip:

    The controls that come with the Silverlight 2 SDK are listed in the Controls tab.

    Your new control appears above the Asset Library button in the Toolbox as the selected tool.

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

    The control appears on the artboard and under Objects and Timeline.

    Dd185501.d89262c0-c8e7-4ebe-83d0-244c1cd5dbcc(en-us,Expression.10).png
  8. Test your project (F5) to see the new control.

    Dd185501.alert_tip(en-us,Expression.10).gifTip:

    You can add a reference to an uncompiled project by first adding the project to your solution and then adding 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 Custom Controls tab of the Asset Library, try to build the project before you open the Asset Library again.

  • 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 under Objects and Timeline, reset the Margin properties to 0 under Layout in the Properties panel, and then try to resize the control again.

Community Additions

ADD
Show:
© 2015 Microsoft