当我使用Blend 4/5时,我可以像这样为Blend WPF设计器创建扩展:
using System.ComponentModel.Composition;
using Microsoft.Expression.DesignModel.Metadata;
using Microsoft.Expression.Extensibility;
using Microsoft.Expression.Platform;
using Microsoft.Expression.WpfPlatform;
namespace Elysium.Extension
{
[Export(typeof(IPackage))]
public class Package : IPackage
{
private IServices _services;
public void Load(IServices services)
{
_services = services;
var platformService = _services.GetService<IPlatformService>();
platformService.PlatformCreated += Register;
}
private void Register(object sender, PlatformEventArgs e)
{
var wpf = e.Platform as WpfPlatform;
if (wpf != null)
{
wpf.Metadata.AddAssemblyGroupMapping(AssemblyGroup.ExtendedControls, "Elysium.Extension");
wpf.InstanceBuilderFactory.Register(new CustomWindowInstanceBuilder());
}
}
public void Unload()
{
}
}
}
在这段代码中,我订阅了IPlatform服务,当它更新时,我通过WPFPlatform对象注册我的自定义WindowInstanceBuilder。
如何为Visual Studio 2010/2012设计器执行此操作?
谢谢。
答案 0 :(得分:1)
有关Visual Studio可扩展性的一些提示,请参阅"Visual Studio 2010 addin writing articles/tutorials?"。 Visual Studio SDK可能包含您需要的信息。
如果这对你有用,你可以将解决方案扩展到Visual Studio 2012.