Green Falcon
Green Falcon

Reputation: 836

folder missing in resources

I have the following code for showing an image:

Image im = new Image();
im.Source = new BitmapImage(new Uri("Icons.login.jpg", UriKind.RelativeOrAbsolute));
im.Height = 200;
im.Width = 200;
icons.Add(new IconImagesForDummies() { Name = str, Image = im });

The Image class belongs to System.Windows.Controls.Image. I have added a folder to store images separately from Resources folder (named Icons). But I have set the build action property of all images to Embed Resource and they have been set to Copy Always. I do not know why I can not see the images. I'm using WPF. During debugging I found out that the image path was fine and it founded that, but I do not know the reason, the image was not showed. I have read here but was useless.
Is there something wrong with the Uri?

Upvotes: 1

Views: 203

Answers (1)

Jurriaan Buitenweg
Jurriaan Buitenweg

Reputation: 422

EDIT: maybe its just this simple

im.Source = new BitmapImage(new Uri(@"Icons\login.jpg", UriKind.Relative));

Edit: changing build action to content works.

Upvotes: 1

Related Questions