Quantcast
Channel: Karl On WPF - .Net » Silverlight Controls
Viewing all articles
Browse latest Browse all 5

Extensibility Series – Loading Metadata for Microsoft Controls

$
0
0

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.

In my previous post I covered the locating and loading of metadata for custom controls that you authored. 

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

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 I’ll show you 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 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, that assembly can load metadata for any types.  This is how the XAML Power Toys for Cider is able to load design-time metadata for the Microsoft Grid control.

Close

Have a great day,

Just a grain of sand on the worlds beaches.


Posted in Extensibility, Extensibility Series, Silverlight Controls, VB.NET, Visual Studio 2010, WPF Controls, WPF General

Viewing all articles
Browse latest Browse all 5

Trending Articles