0

I need to give a value to the property Image of a RibbonButton from BricsCad/Autocad. But I do not know how to cast an image to the correct type.

var bitMapImage = new Bitmap(Properties.Resources.image);

RibbonButton rb1 = new RibbonButton();
rb1.ShowImage = true;
rb1.Image = bitMapImage; //error line
//Error: the type of rb1.Image is System.Windows.Media.ImageSource

How can I convert the type Bitmap, or other type from Resources, to System.Windows.Media.ImageSource?

I tried the following: https://forums.autodesk.com/t5/net/how-to-display-image-of-ribbon-button-c/td-p/10333159 (Convert Bitmap to BitmapImage)

But I encounter the same error of this: Create a System.Windows.Media.ImageSource From an Icon File in c#?

(And I do not know how to make it work).

0 Answers0