views:

134

answers:

1

I was putting finishing touches on a new WPF/Silverlight custom control and decided that this time I would go with .NET 3.5 SP1 requirement (for WPF version). So, I decided to go with recommended new way of setting toolbox icon/image with ThumbnailAttribute. After spending some time on it I couldn't make it work and turned for help to Google.

Surprisingly a search for ThumbnailAttribute produces basically no results on Google. There's MSDN documentation of the class, a few irrelevant hits and 2 articles (one of which is mine) showing how to do it the old way and just mentioning that there's a new way with ThumbnailAttribute.

So, my question is this: does anybody use ThumbnailAttribute to set toolbox images for WPF/Silverlight controls? Does it work?

Update: Microsoft recommends using specifically named icon files rather than ThumbnailAttribute as per Michael S. Scherotter (see comment below).

+1  A: 

You want to create a design-time assembly for your class. You do this to assign design-time attributes to a class that don't take up space in the assembly. This is important for Silverlight apps which should have smaller assemblyies for faster downloading. See this article for an description of the design-time assembly.

For Icons, in the design-time assembly add 12x12 and 24x24 PNG icons as embedded resources with these names:

  • Namespace.ControlName.12x12.png
  • Namespace.ControlName.24x24.png
Michael S. Scherotter
Thanks. I know the general drill. I just couldn't make thumbnails to work as prescribed in the new documentation. The question was specifically about the use of ThumbnailAttribute, not about a way to add toolbox icons in general.
Alan Mendelevich
You should only use the ThumbnailAttribute in a design-time assembly.
Michael S. Scherotter
I agree with Alan, I couldnt make it work either, the link you posted is great, but for some reason, Microsoft has multiple design assemblies, for example same named "Microsoft.Windows.Design" dll has different contents which is under expression and vs, various attempts have gone wasted and no concrete solution is available.
Akash Kava
Why do you need to use the ThumbnailAttribute? The mechanism I described above works just fine to assign the toolbox icon?
Michael S. Scherotter
I don't need it but I assume that I was told by Microsoft to use it as the correct new way of doing this kind of thing.
Alan Mendelevich
Sorry for the confusion. As a Microsoft employee, I recommend that you use the embedded resource naming convention method described above in the design assembly.
Michael S. Scherotter