C
C#10mo ago
MidnightChe

Images doesn't show up in C# wpf

hello, so i've got an assignment due next week, i've got to create a wpf which, when it launches, shows several images of different countries and when i press start one of the countries has to be written at the bottom and with my mouse i have to go to the image of the country which corresponds and if i've chosen the right answer, the image has to become blurred. Almost everything works except my images, but I don't understand why. I've coded them well and I've done it in the same way as my teacher asked us to do, but still it doesn't work. I coded them like this (because this is how our teacher gave us the example): imgArgentina.Source = new BitmapImage(new Uri("img/argentina.png", UriKind.RelativeOrAbsolute)); imgFinland.Source = new BitmapImage(new Uri("img/finland.png", UriKind.RelativeOrAbsolute)); imgJapan.Source = new BitmapImage(new Uri("img/japan.png", UriKind.RelativeOrAbsolute)); imgMarokko.Source = new BitmapImage(new Uri("img/marokko.png", UriKind.RelativeOrAbsolute)); imgNieuwzeeland.Source = new BitmapImage(new Uri("img/nieuwzeeland.png", UriKind.RelativeOrAbsolute));
5 Replies
lycian
lycian10mo ago
the first thing to check is that the images are dropped in the right location. It will be looking in an "img" folder next to where the binary is
MidnightChe
MidnightCheOP10mo ago
they're in the right place, aren't they?
No description
lycian
lycian10mo ago
that's next to the cs files, but remember c# is a compiled language. Likely you have a "bin" folder with the compiled application. Are the images dropped there
MidnightChe
MidnightCheOP10mo ago
i just checked and yes they are, but its like : bin > debug > net6.0-windows > img
lycian
lycian10mo ago
sorry, had meetings. I completely forgot wpf uses pack URIs so your images should be embedded as a resource then the URI will just be /img/finland.png for example
Want results from more Discord servers?
Add your server