Programmatically set the Source of an Image (XAML)

后端 未结 7 690
孤街浪徒
孤街浪徒 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 02:58

    I just tried

    Image.Source = new BitmapImage(
        new Uri("http://yourdomain.com/image.jpg", UriKind.Absolute));
    

    And it works without problems... I'm using System.Uri here. Maybe you have a malformed URI or you have to use an absolute URI and use UriKind.Absolute instead?

提交回复
热议问题