The bitmap image associated with the ToolboxBitmap property does not appear in the toolbox.
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
When creating a custom control, if you use the ToolboxBitmap property, the bitmap image associated with this attribute does not appear in the toolbox.
For the program test, the bitmap image is included in a folder.
I also tested with the image included in a resource file.
The problem remains the same.
The same test with a winforms project works perfectly.
Here is the code
'----------------------------------
Imports System.Drawing
Imports System.Windows.Controls.Primitives
****
Public Class CustomControl1
Inherits System.Windows.Controls.Control
Shared Sub New()
'Cet appel OverrideMetadata indique au système que cet élément souhaite apporter un style différent de celui de sa classe de base.
'Ce style est défini dans themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(GetType(CustomControl1), New FrameworkPropertyMetadata(GetType(CustomControl1)))
End Sub
End Class
'---------------------------
Here is the image of the ToolboxBitmap attribute.

You see the image not present in the toolbox.

With the same project in winforms, the image is visible.
`---------------------------------------
****
Public Class CustomControl1
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
'Ajoutez ici votre code de dessin personnalisé
End Sub
End Class
`--------------------------------------

### Reproduction Steps
Create a project with a custom control.
Added the ToolboxBitmap attribute whose value is a path to a bitmap file to the custom control.
Build the project.
### Expected behavior
View of the ToolboxBitmap attribute image in the toolbar.
### Actual behavior
No view of ToolboxBitmap attribute image in toolbar.
### Regression?
_No response_
### Known Workarounds
_No response_
### Impact
_No response_
### Configuration
Visual studio 2022 Version 17.12.1
.Net 9
Project in VB.
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.