0

How to use resource image in WPF image source.I given like below,

<Image Source="pack://siteoforigin:,,,/Resources/008.jpg"/>.

But it displays in edit page.If i run the application it not displaying in the window.

Please help me to solve this.

Thanks.

Raj Kumar
  • 61
  • 1
  • 9

2 Answers2

0

you need to provide the correct URI to the resource, and the URI depends on the method you used to add the resource this post give the details you need

How to Embed resources

Community
  • 1
  • 1
MikeT
  • 5,398
  • 3
  • 27
  • 43
-1

You can add your image to your project Properties.Resources.Images and then use them like that:

<Image Source="{x:Static Properties:Resources.YourImageName}"/>

EDIT >>>>

I've forgotten to say that you have to add this line at the top:

<xmlns:Properties="clr-namespace:yournamespace.Properties"/>
Jose
  • 1,857
  • 1
  • 16
  • 34
  • Thanks for reply, i am new for this.How to define properties in xaml. help me please – Raj Kumar Sep 24 '15 at 11:50
  • Your project should have it by default, just edit them. – Jose Sep 24 '15 at 12:03
  • @RanjithKumar You shouldn't do it this way. It's not how image resources are typically used in a WPF application. – Clemens Sep 24 '15 at 12:29
  • Sorry @Clemens, Im just a new user of WPF and I use the images that way and it works fine. Why should I(or anyone else) use other way? and which is the other way? – Jose Sep 24 '15 at 12:33
  • @Kirenenko There are quite a lot of posts here on StackOverflow about WPF image resources. In short, add an image file to your project, set its Build Action to Resource, and access it by a [Pack URI](https://msdn.microsoft.com/en-us/library/aa970069(v=vs.100).aspx). – Clemens Sep 24 '15 at 13:40