TheSwamp

Code Red => .NET => Topic started by: djee on January 23, 2017, 02:59:42 PM

Title: Image from resources (Embedded in .resx)
Post by: djee on January 23, 2017, 02:59:42 PM
I'm trying to use an image from my resources (Embedded in .resx) for one of my WPF button. Nothing is working... I can see the image in my designer but not when executing... The image resource is of type Bitmap.  I've tried lots of different scenario & can't get anything going. Anybody has experience using images from resources? :crazy2:

NOT working:
Code: [Select]
Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim myStream As Stream = myAssembly.GetManifestResourceStream("FreezeOn.png")
Dim image As New Bitmap(myStream)

my XAML
Code: [Select]
  <Button Name="ScanFile">
                <StackPanel>
                    <Image Name="myExitImage"  Source="pack://siteoforigin:,,,/Resources/FreezeOn.png"/>
                </StackPanel>
            </Button>
Title: Re: Image from resources (Embedded in .resx)
Post by: Bobby C. Jones on January 23, 2017, 03:20:49 PM
I don't have many images saved as resources, but I did find this one.

Title: Re: Image from resources (Embedded in .resx)
Post by: djee on January 23, 2017, 03:34:50 PM
Is the persistence setting of your image set to: Embedded in .resx? I`m guessing everything is fine on your side of thing (you can see the image)? If you copy your app to another directory, do you still see the resource image ?

Title: Re: Image from resources (Embedded in .resx)
Post by: Bobby C. Jones on January 23, 2017, 04:20:06 PM
Is the persistence setting of your image set to: Embedded in .resx? I`m guessing everything is fine on your side of thing (you can see the image)? If you copy your app to another directory, do you still see the resource image ?

It's not listed in the .resx file, just set as Resource for the build action.
Title: Re: Image from resources (Embedded in .resx)
Post by: Bobby C. Jones on January 23, 2017, 04:20:53 PM
I`m guessing everything is fine on your side of thing (you can see the image)? If you copy your app to another directory, do you still see the resource image ?

Sorry, yes and yes.
Title: Re: Image from resources (Embedded in .resx)
Post by: djee on January 23, 2017, 05:18:18 PM
Thanks to the image you've posted, I just saw the BUILD ACTION comboBox menu... As you've mention, I just changed the build action to ''Ressource'' & all is fine... I won't tell you how much time I lost trying to figure this one out...  :whistling:
Thanks a bunch!