Silverlight Windows Phone 7: Load Images From URL

前端 未结 4 1599
花落未央
花落未央 2021-02-05 17:40

I got the code below that is trying to load an image from the web into an Image control, when I run it I get an error on the given line that no network access is allowed:

<
4条回答
  •  一个人的身影
    2021-02-05 18:25

    Trying to download content with WebClient will require a client access policy file to be present on the source server. For images you can avoid this requirement by doing it like this:-

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        Uri uri = new Uri("http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/80000/5000/100/85108/85108.strip.print.gif", UriKind.Absolute)
        image1.Source = new BitmapImage(uri);
    }
    

提交回复
热议问题