locked
Accessing an image from Xaml RRS feed

  • Question

  • Hi

    My Windows Store Xaml file looks like this ...

        <Image Source = "StaticResource PreviousNewsItem">

    The Resource Dictionary entry reads thus

        <ImageSource x:key="PreviousNewsItem">c:\App\Graphics\back.png</ImageSource>

    The back.png file properties are 

        Build action = Content

        Copy To Output Directory = Copy always

    The Xaml file and the Graphics directory are upon the same child line. Howvere when I run the app, no image gets displayed. Any assists very much appreciated.

    Thanks

    Friday, April 11, 2014 1:06 PM

Answers

  • You need to refer to the image relative to your app package, not to an explicit path on disk. The app won't have access to c:\app .  You can reference the bitmap in the properties editor to find the exact path to use, but its probably something like "Graphics\back.png".
    Friday, April 11, 2014 2:32 PM
    Moderator

All replies

  • You need to refer to the image relative to your app package, not to an explicit path on disk. The app won't have access to c:\app .  You can reference the bitmap in the properties editor to find the exact path to use, but its probably something like "Graphics\back.png".
    Friday, April 11, 2014 2:32 PM
    Moderator
  • <Image Source = "StaticResource PreviousNewsItem">

    The syntax is incorrect. Have you tried it this way?

    <Image Source = "{StaticResource PreviousNewsItem}">

    Friday, April 11, 2014 8:04 PM