Tricks to add WPF Custom Control badge to Visual Studio 2008 toolbox

When developing WPF Custom Control it could be intricate to add your custom control image to Visual Studio 2008 WPF designer toolbox. I hadn’t found instructions how to do that in MSDN and only fragmentary indications in forums. Strange, I did that in the past but can’t store that experience in my memory so, again and again, I should go by trial-and-error way. That’s why I decided to fix the procedure here.

The first thing you have to do is to get your image and place it in your Custom Control project directory.

Next – important step – you must name image file according to the following pattern:

<your full namespace name>.<your custom control class name>.Icon.<extension>

e.g. "MyControls.MyControl.Icon.bmp". Extension must match your image type and could be bmp, png and, maybe, others.

Next you have to include the file into your Custom Control project, set its Build Action to "Embedded Resource" and rebuild the project.

Now you can go to the toolbox, click it by right mouse button and select "Choose Items…". You’ll see "Choose Toolbox Items" dialog box. Then (it’s important too) you have to select "WPF Components" tab (it isn’t selected by default!), click the "Browse…" button and select your assembly file.

That’s all. Your image should appears in the toolbox. You could create your own tab for your controls and drag the image there.

PS. If you change your image later then you probably should repeat the steps from "Choose Items…" to refresh it in the toolbox.

Advertisements

About ovpwp

I am engaged in programming, maintenance and supply of computing technique since 1970. Started with the computers M, BESM, Minsk series and received appropriate education in the least, in which it was then possible in THE USSR. Then he went the usual way - ES series, IBM 360/370, Sun Spark, Ibm Power & PS2, PC. Programming started in the code (machine commands), then were sorts of assemblers, Algol, FORTRAN, PL/1, C, C , VB, C#. It is only the ones that I used the production scale; but there were, of course, others like List, Modula, Pascal, Java, etc. Currently I prefer .NET platform for desktop development. I don't really like web-programming (probably because of the inability for quality design), but I have enough experience in site building in LAMP environment using PHP.
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Tricks to add WPF Custom Control badge to Visual Studio 2008 toolbox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s