Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The bitmap image associated with the ToolboxBitmap property does not appear in the toolbox. #10178

Open
Perpete opened this issue Dec 15, 2024 · 5 comments
Labels
External Non-WPF Issue External issue, not caused by WPF

Comments

@Perpete
Copy link

Perpete commented Dec 15, 2024

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

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.

Image

You see the image not present in the toolbox.

Image

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
`--------------------------------------

Image

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

@miloush
Copy link
Contributor

miloush commented Dec 15, 2024

This sounds rather Visual Studio related rather than WPF. Please include the repro projects.

@Perpete
Copy link
Author

Perpete commented Dec 15, 2024

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.

WinFormsApp1.zip
WpfApp1.zip

@himgoyalmicro
Copy link
Contributor

Thanks @miloush
@Perpete Can you please raise this bug with the VS Feedback (https://developercommunity.visualstudio.com)?

@himgoyalmicro himgoyalmicro added the External Non-WPF Issue External issue, not caused by WPF label Dec 16, 2024
@Perpete
Copy link
Author

Perpete commented Dec 16, 2024

Thank you.
Problem transferred.

@miloush
Copy link
Contributor

miloush commented Dec 16, 2024

(What I was gonna check is whether the bitmap file has the same build action in both projects.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Non-WPF Issue External issue, not caused by WPF
Projects
None yet
Development

No branches or pull requests

3 participants