如果我有一个到在线图像的链接,我想将图像源设置为此uri,我应该如何最好地做到这一点?我正在尝试的代码如下所示。
<Image Name="Poster" Height="400" Width="250" VerticalAlignment="Top" Margin="0,10,8,0"/>
将图像源设置为URI
BitmapImage imgSource = new BitmapImage();
imgSource.UriSource = new Uri(movie.B_Poster, UriKind.Relative);
Poster.Source = imgSource;
另外,如果我想缓存此图片再次装入这是怎么完成的?
谢谢
当我运行此我得到一个异常说: 相对URI不能因为创建'uriString'参数表示绝对URI。 – Ameen
你传递了什么URI,抛出的异常究竟在哪里? –
这是我通过的Uri: 'http://www.foo-web.net/res2/Adele Blanc - Sec.foob' 而且这个声明发生异常: 'imgSource.UriSource = new Uri(movie.B_Poster,UriKind.Relative);' – Ameen