Loading Metadata for Microsoft Controls

I have received several requests for information on loading metadata for WPF & Silverlight controls shipped by Microsoft.  For example, a developer wanted to add a design time context menu to a Button control but couldn’t figure out how to add the required metadata.

I covered the locating and loading of metadata for custom controls that you authored in this post.

In this post I’ll cover how to locate and load metadata for controls that you were not the author for.

Table of Contents

  1. Locating Metadata
  2. Beta2 Registry Entries
  3. Post Beta2 Registry Entries
  4. Loading Metadata
  5. Comments

Locating Metadata 

In my previous post I explained that metadata is loaded from assemblies and those assemblies had a specific naming convention and location relative to the control assembly it was providing a design-time for.

In this post we’ll learn how to use a registry entry to provide the location of the assembly that has metadata you want Visual Studio to load.

You will need a separate registry entry for your WPF & Silverlight design assemblies.

To add a twist, the registry entry used in Beta2 will be different for all post Beta2 builds.  I’m telling you that now so that you can be prepared and have the code ready for the next release of Visual Studio 2010.

FYI: The XAML Power Toys for Visual Studio 2010 Beta2 Cider Designer design-time I did uses these registry entries to provide design-time metadata for the WPF & Silverlight Grid control.

Beta2 Registry Entries 

registryone

registrytwo

The full path of the registry key is below:  (line breaks for readability only)

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\DesignerProfiles\
    Microsoft.Windows.Design.Metadata.DeveloperMetadata\
    XAMLPowerToys.VisualStudio.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Note:  For 64 bit operating systems, you must use below modified registry key path:

HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\VisualStudio

The last line is the assembly full name and serves as the unique subkey name under Microsoft.Windows.Design.Metadata.DeveloperMetadata.

The key has three values, Assembly, Class and CodeBase.

Assembly: Provide the full assembly name

Class: Provide the class name that implements IProvideAttributeTable

CodeBase: Provide the full path to the assembly

The above information provides Visual Studio the required information and it will load the metadata.

Post Beta2 Registry Entries 

Beginning with all versions of Visual Studio 2010 after Beta2, the registry keys have changed and the following will be used instead of the above.

registrythree

registrytwo

The full path of the registry key is below:  (line breaks for readability only)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\DesignerPlatforms\
  .NetFramework\Metadata\XamlDesigner\
  XAMLPowerToys.VisualStudio.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Note:  For 64 bit operating systems, you must use below modified registry key path:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio

The last line is the assembly full name and serves as the unique subkey name under XamlDesigner.

The key has three values, Assembly, Class and CodeBase.

Assembly: Provide the full assembly name

Class: Provide the class name that implements IProvideAttributeTable

CodeBase: Provide the full path to the assembly

The above information provides Visual Studio the required information and it will load the metadata.

Loading Metadata 

Once the metadata is located, Visual Studio will then load the metadata.

metadataloading

When Visual Studio locates an assembly that implements IProvideAttributeTable, Visual Studio can load metadata for any type.  This is how the XAML Power Toys for Cider is able to load design-time metadata for the Microsoft Grid control.

Comments 

Microsoft values your opinion about our products and documentation. In addition to your general feedback it is very helpful to understand:

  • How the above feature enables your workflow
  • What is missing from the above feature that would be helpful to you

Thank you for your feedback and have a great day,

Karl Shifflett
Visual Studio Cider Team