Edmond_ _Dantes
Edmond_ _Dantes

Reputation: 123

What is the proper way to reference an image in winui

I am trying to display an image using the latest version of winui, without success. Due to my lack of progress I assume I must be doing something terribly wrong, however, I can't determine what that might be.

Here is my most recent attempt.

MainWindow.xaml:

<Image Source="AppIcon.png" Width="200" Height="200" ImageFailed="ImageFailed_Event"/>

Image

Upvotes: 1

Views: 3200

Answers (1)

Edmond_ _Dantes
Edmond_ _Dantes

Reputation: 123

Ok here is the solution that I have found with the help of the people in the comments:

  • Set the "Build Action" of the image file to "Content"
  • Set the "Copy to Output Directory" to "Copy if newer"

This is all that is necessary, no URI magic is needed.

Upvotes: 3

Related Questions