Aleksandr Vishnyakov
Aleksandr Vishnyakov

Reputation: 1893

Visual Studio 2010/2012 WPF designer extension

When I use Blend 4/5, I can create extension for Blend WPF designer like this:

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()
        {
        }
    }
}

In this code I subscribe to IPlatform service and when it's updated I register my custom WindowInstanceBuilder via WPFPlatform object.

How I can do this for Visual Studio 2010/2012 designer?

Thank you.

Upvotes: 20

Views: 3239

Answers (1)

Hybos
Hybos

Reputation: 156

For some hints on Visual Studio Extensibility, see "Visual Studio 2010 addin writing articles/tutorials?" . The Visual Studio SDK may have the information you need.

If this works for you, you can extend the solution to Visual Studio 2012.

Upvotes: 1

Related Questions