Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010/2012 WPF designer extension

Tags:

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.

like image 768
Aleksandr Vishnyakov Avatar asked Nov 17 '12 22:11

Aleksandr Vishnyakov


People also ask

How do I enable XAML designer?

To open this page, choose the Tools menu and then choose Options. To access the XAML Designer property page, choose the XAML Designer node. Settings for the XAML Designer are applied when you open the document. So, if you make changes to the settings, you need to close and then reopen Visual Studio to see the changes.

Where is XAML designer?

To open the XAML Designer, right-click a XAML file in Solution Explorer and choose View Designer. to switch which window appears on top: either the artboard or the XAML editor.

How do I create an XAML file in Visual Studio?

To begin editing your first XAML file, use Visual Studio or Visual Studio for Mac to create a new Xamarin. Forms solution. (Select the tab below corresponding to your environment.) In the Configure your new project window, set the Project name to XamlSamples (or whatever your prefer), and click the Create button.


1 Answers

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.

like image 122
Hybos Avatar answered Oct 21 '22 03:10

Hybos