Dan*_*Dan 6 c# silverlight visual-studio-2010 windows-phone-7
好吧,我已经找到了几种方法来修复我的Windows Phone 7应用程序,但我似乎无法找到任何有效的方法.令我困惑的是,我之前做过这样的事情并没有问题,所以我不确定为什么它不起作用.导致我出现问题的代码如下:
if(appSettings.Contains("image"))myImage.Source =(string)appSettings ["image"]; 否则myImage.Source ="default.jpg";
我得到的错误就是这个
无法将类型'string'隐式转换为'System.Windows.Media.ImageSource.
这让我感到困惑的原因是因为我做了这个Twitter应用程序教程,其中你将图像源直接绑定到一个字符串.那么我该怎么做才能解决这个问题呢?
tho*_*sen 15
从代码执行操作时,您需要指定ImageSource而不是字符串:
Uri uri = new Uri("...", UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
myImage.Source = imgSource;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13604 次 |
最近记录: |