WPF Cannot Find Image Resource

zequion 446 Reputation points
2024-08-25T05:33:03.7766667+00:00

In WPF I have added 2 images and I have included them in the solution explorer. It compiles well but when running, when it is initializing, a message appears saying that the images have not been found. I have cleaned, I have deleted .vs and .obj and it has not worked. If I assign CacheOption="None" the error does not appear but the image does not show.

<BitmapImage x:Key="estilos" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="images\cry\form\opciones\estilos.png"/>

imagen

Developer technologies Windows Presentation Foundation
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-08-26T02:08:47.0266667+00:00

    Hi,@zequion. Welcome to Microsoft Q&A. 

    Find the image in Visual Studio -> right click on the image -> Properties -> change Build Action to Resource


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.