locked
Setting an Images Source

    Question

  • Hi guys does anyone know how to set the source of an image to an image that has been added to my assets folder?

    Thanks

    Wednesday, June 13, 2012 5:29 PM

Answers

  • BitmapImage^ defaultCover = ref new BitmapImage( ref new Uri( "ms-appx:///Res//MusicCover.png"));
    Image->Source = defaultCover;

    But be sure you're doing that in UI thread.
    Wednesday, June 13, 2012 6:19 PM

All replies

  • You meant something like this ?

    BitmapImage^ defaultCover = ref new BitmapImage( ref new Uri( "ms-appx:///Res//MusicCover.png"));

    Wednesday, June 13, 2012 6:01 PM
  • Yes and then setting that Bitmap as the source of an Image object?
    Wednesday, June 13, 2012 6:07 PM
  • BitmapImage^ defaultCover = ref new BitmapImage( ref new Uri( "ms-appx:///Res//MusicCover.png"));
    Image->Source = defaultCover;

    But be sure you're doing that in UI thread.
    Wednesday, June 13, 2012 6:19 PM
  • Thanks works!
    Wednesday, June 13, 2012 6:39 PM