AnsweredAssumed Answered

How to set images for GalleryItems in Pro SDK

Question asked by twhiteaker on Apr 30, 2019
Latest reply on Aug 19, 2019 by lgxdw

I have my own images I created for use as a gallery item icons within my gallery.  In the Initialize() method of my Gallery, I want to do this in C#:

 

// I already added my image to Properties.Resources
var img = new Bitmap(Properties.Resources.my_png_image);
Add(new GalleryItem("Item Text", img));

However, when I click the Gallery in the ribbon, I see the text but no image.

 

What's the proper way to include an image in your project and use it as the icon for a gallery item?  I don't have to use Properties.Resources; that's just one thing I tried.

 

I also tried using images as embedded resources, using an image I added to my Thumbnails folder with Build Action set to Resource, but the resource stream (the stm variable) came back null.

 

I also tried using images as resources, but I got a "Could not load file or assembly" error on this line:

 

BitmapImage fromResource = new BitmapImage(new Uri("pack://application:,,,/Module1;component/Thumbnails/my_png_image.png", UriKind.Absolute));

Outcomes