0

I am new to WPF and am confused as to how to load an image dynamically from a folder in the project rather than from OpenFileDialog.

I have a regular grid view in XAML where I've declared an image

<Image Name="imgFlight" Margin="20, 20, 0, 0" Stretch="Uniform" Height="200" HorizontalAlignment="Left" VerticalAlignment="Top" Width="360"/>

Then I have a folder called Resources in the project where I have added a bunch of images of logos from airplane companies. Depending on what company they select, the appropriate image should be displayed. However, I cannot seem to get any picture whatsoever to show. The rest of the program works as it should though.

Did find this line of code that I tried implementing in different ways, but to no avail.

imgFlight.Source = new BitmapImage(new Uri("QatarAirways.png", UriKind.Relative));

How should I go about it?

0 Answers0