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.