You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
<ToolboxBitmap("D:\Documents\Visual Studio 2022\Projects\WpfApp1\Images\ToggleButton.bmp")>
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.
`--------------------------------------- <ToolboxBitmap("D:\Documents\Visual Studio 2022\Projects\WinFormsApp1\Images\ToggleButton.bmp")>
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
The text was updated successfully, but these errors were encountered:
Here is the project in WPF and winforms.
You have to adapt the image file path for the toolboxBitmap attribute depending on where the Images folder of the project is located.
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
<ToolboxBitmap("D:\Documents\Visual Studio 2022\Projects\WpfApp1\Images\ToggleButton.bmp")>
Public Class CustomControl1
Inherits System.Windows.Controls.Control
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.
`---------------------------------------
<ToolboxBitmap("D:\Documents\Visual Studio 2022\Projects\WinFormsApp1\Images\ToggleButton.bmp")>
Public Class CustomControl1
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
The text was updated successfully, but these errors were encountered: