Partager via


Add a behavior that was created by someone else

To add interactivity to your application without having to write code, you can drag a behavior from the Assets panel onto an object in your application and then set the properties of the behavior. You can also use behaviors that are created by people in the Blend for Visual Studio 2012 community. For example, you can download custom behaviors from the Microsoft Expression Gallery. If you want to use a behavior that was created by someone else, add a reference to the .dll file or project that contains the behavior. This will make the behavior available in the Assets panel.

[!REMARQUE]

Developers can use the new Blend Software Development Kit (SDK) to create custom behaviors. To view the SDK documentation, click Expression Blend SDK User Guide on the Help menu.

To add a behavior that was created by someone else

  1. Add a reference to the .dll file or project that contains the custom behavior.

    [!REMARQUE]

    The reference is added to the System.Windows.Interactivity and Microsoft.Expression.Interactions DLLs in the Libraries folder in the SDK. The location depends on whether the reference is added to a Microsoft Silverlight or Windows Presentation Foundation (WPF) project.

    For more information, see the following topics:

  2. Build your project (Ctrl+Shift+B or F5).

  3. Open the Assets panel to view the custom behavior in the Behaviors category.

    You can now drag the behavior onto objects in your application.

    For more information, see Add a behavior to an object.

Add a custom behavior to the Assets panel

If you download an assembly that contains multiple behaviors that you think you will use frequently, you can register the assembly to make the behaviors available to any project you create without having to add a reference.

To make a custom behavior always show up in the Assets panel

  1. Do one of the following:

    • For a behavior that is written for Silverlight, create a registry subkey in \HKEY_CURRENT_USER\Software\Microsoft\Expression\Blend\v4.0\Toolbox\Silverlight\v4.0 that is named the same as the assembly namespace.

    • For a behavior that is written for WPF, create a registry subkey in \HKEY_CURRENT_USER\Software\Microsoft\Expression\Blend\v4.0\Toolbox\WPF\v4.0 that is named the same as the assembly namespace.

  2. In the subkey, create a default string value and set it to the path of your assembly.

ConseilConseil

Alternatively, you could copy the assemblies to the corresponding subfolder for Silverlight or WPF:

  • Silverlight   C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries

  • WPF   C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries

Voir aussi

Tâches

Add a behavior to an object