WPF application. How to reference the image in the XAML code, so that another user can view it when running . exe project file?

Asked

Viewed 1,332 times

0

I’m having a problem with my WPF application. I have two images in XAML code, and when I run the application on my computer, they appear normal, but when I ask someone to run the file. exe , it runs normally, only the images do not appear. How can I do to set the source images so that when another user runs the file . exe , the images appear on the screen?

The image code in XAML:

<Image Source="\MULINFSV0005\User$\mathias.deitos\Meus Documentos\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\clock.png" HorizontalAlignment="Left" Height="52" Margin="41,27,0,0" VerticalAlignment="Top" Width="68"/>
  • 2

    Does that help you? http://stackoverflow.com/questions/15636047/image-in-wpf-button-not-visible-at-runtime

  • Managed to solve?

  • not yet, I tried to follow the link steps but my problem is a little different, when I run the application the images appear, but when I pass the executable to someone else test, the images do not appear

  • Your problem is exactly that. Because the image is not being posed as Resource. It is full of references teaching to do so: http://stackoverflow.com/a/2416464/221800

  • 1

    That’s cool, you said that answer didn’t help you. When someone posted exactly it, you accepted the answer.

  • is that in actual fact, I tried to do exactly as in the example that the guy answered, I took all the way and left only the name of the image. He was very direct in the reply. But thanks bigown, I only understood better in his reply.

Show 1 more comment

1 answer

0


You can do it like this:

If you have a folder with the images inside use like this:

<Image Source="Imagens\start.png" />

If your image is marked as resource use this way:

<Image Source="Logo.png" />

The two examples above are shortcuts to:

<Image Source="pack://application:,,,/Logo.png" />
<Image Source="pack://application:,,,/Imagens\start.png" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.