How to extend Expression Blend 4

Source: Internet
Author: User
Microsoft has not publicly promised to support extended Expression Blend, nor has it provided relevant documents. However, Expression Blend has already considered the scalability issue during design and exposed the extended interfaces. Therefore, we can use these interfaces to expand it. The easiest way is to use MEF.

This article describes how to write a plug-in for Expression Blend to extend Expression Blend.

1. Configure the Extension project because Expression Blend is based on. Net4.0, you must use Visual Studio
2010 create a. Net4.0 class library project. We recommend that you use the "WPF custom control" template to create this project. Because Blend only works in Microsoft
Find the Assembly ending with. Extension. dll in the Expression \ Blend 4 \ Extensions \ directory, so you must modify the name of your assembly to end with. Extension. During deployment or debugging, you must put the Extension assembly in the Microsoft Expression \ Blend 4 \ Extensions \ directory: Note:This operation will cause all output to be stored in this directory during debugging. Therefore, you need to set the copy local attribute to false for all the referenced assembly of this project. Finally, to debug your program, set Blend as the external Startup Program of the project: 2. Load the plug-in first, add Microsoft. expression. framework, Microsoft. expression. extensibility, which can be found in the installation directory of the Blend assembly, and set their copy local attribute to false. Then, add a Class and implement the IPackage interface:
using Microsoft.Expression.Extensibility;
namespace MyExtension
{
class MyExtension : IPackage
{
#region IPackage Members
public void Load(IServices services)
{
}
public void Unload()
{
}
#endregion
}
}
IPackage has only two methods: Load and Unload. The Load method is the entry to your entire plug-in. You can write your initialization logic here and use the passed IServices to obtain the services you need, for example, ICommandService commandService = services. getService <ICommandService> (). To enable Blend to automatically Load your Package, you only need to use MEF to Export it:
using System.ComponentModel.Composition;
namespace MyExtension
{
[Export(typeof(IPackage))]
class MyExtension : IPackage
Now, your plug-in can be loaded by Blend. You can add a breakpoint in the Load method and press F5 to run it. Of course, you can also directly use MEF to Import a Service (some services may not be able to Import, but only IServices can be used to obtain IDocumentTypeManager ):
[Import]
internal ISolutionService SolutionService { get; set; }
3. Complete the plug-in. Now you can write your own plug-in logic. You can add windows, add menus, or even your own file types for Blend. Of course, its scalability is far inferior to that of Visual Studio. The overall idea of extending Blend is to register your components through Service. For example, we can use IwindowService to register a window for it:
IWindowService service = services.GetService<IWindowService>();
UserControl uc = new UserControl();
service.RegisterPalette("MyExtension", uc, "My Extension");
Press F5 to open the Blend Window menu and you will be able to see the newly registered "My Extension" Window: Of course, there is only one UserControl in the Window and nothing can be done, you need to override UserControl and use other services to complete other functions.
4. Others:
If you are interested in extending Expression Blend, or you need to know how to extend other aspects of Expression Blend, such as how to add a template to Blend, how to add new file types to Blend? Please reply.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.