Windows Presentation Foundation Designer Extensibility for Visual Studio
ThumbnailAttribute Class

Updated: July 2008

Associates an icon with a custom Windows Presentation Foundation (WPF) or Silverlight control in the toolbox for Visual Studio or Expression Blend. 

Namespace:  Microsoft.Windows.Design
Assembly:  Microsoft.Windows.Design (in Microsoft.Windows.Design.dll)
Syntax

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True)> _
Public NotInheritable Class ThumbnailAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As ThumbnailAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)]
public sealed class ThumbnailAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true)]
public ref class ThumbnailAttribute sealed : public Attribute
JScript
public final class ThumbnailAttribute extends Attribute
Remarks

Apply the ThumbnailAttribute to assign a toolbox icon to a custom WPF or Silverlight control.

The following steps show how to add an icon representing your control to a type.

  1. Create a design-time metadata assembly for your custom control. For more information, see How to: Use the Metadata Store.

  2. Add an image at the same folder hierarchy as the type you pass to the ThumbnailAttribute. Supported extensions and file types are BMP, GIF, JPG, JPEG and PNG.

    Different designer hosts use different image sizes for the toolbox icon. You can specify a different image for the WPF Designer and Expression Blend by specifying the ThumbnailAttribute in the host-specific metadata assemblies, *.VisualStudio.Design.dll and *.Expression.Design.dll.

    Expression Blend uses 24x24 for the large icon size and 12x12 for the small icon size. The WPF Designer uses 16x16.

  3. In the Properties window, set the build action for the image to EmbeddedResource.

    NoteNote:

    The project sub-folders affect the namespace in which embedded resources are found.

  4. Use the metadata store to add the ThumbnailAttribute to your control’s class. You can reuse the same image across multiple types by applying the same ThumbnailAttribute to multiple controls.

    The ThumbnailAttribute is also used to find a default icon for types added to the Collection Editor or Sub-Properties Editor “new instance” functionality.

Examples

The following code example shows how to add the ThumbnailAttribute to a custom Silverlight control by using the MetadataStore.

C#
public class Metadata : IRegisterMetadata
{
    public void Register()
    {
        AttributeTableBuilder builder = new AttributeTableBuilder();
        builder.AddCustomAttributes(typeof(Proseware.Core.Controls.ProseControl), 
        new ThumbnailAttribute(typeof(Metadata), "SLControlLibrary.Design. logo.gif"));
        MetadataStore.AddAttributeTable(builder.CreateTable());
    }
} 
Inheritance Hierarchy

System..::.Object
  System..::.Attribute
    Microsoft.Windows.Design..::.ThumbnailAttribute
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Reference

Change History

Date

History

Reason

July 2008

Added topic for new class.

SP1 feature change.

Tags :


Page view tracker