Programmatically set the Source of an Image (XAML)

后端 未结 7 686
孤街浪徒
孤街浪徒 2020-12-09 02:15

I am working on a Windows 8 app. I need to know how to programmatically set the Source of an Image. I assumed that the Silverlight approach would work. However, it doesn\'t.

7条回答
  •  一整个雨季
    2020-12-09 03:02

    check your pictureUrl since it was what resulted in the exception.

    but this should work as well

    img.Source = new BitmapImage(new Uri(pictureUrl, UriKind.Absolute));
    

    it should have nothing to do with Windows.Foundation.Uri. since winrt will handle it for you.

提交回复
热议问题