我正在尝试以编程方式在XAML Metro应用程序中加载BitmapImage。这是我的代码:
var uri = new Uri("/Images/800x600/BackgroundTile.bmp", UriKind.RelativeOrAbsolute);
var imageSource = new BitmapImage(uri);
第二行崩溃,出现System.ArgumentException:
The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details.
该链接仅转到MSDN主页,因此没有用。
我还尝试过删除开头的
/
,以防WinRT对相对URI有不同的期望,但是我仍然遇到相同的异常。为什么对于似乎完全有效的URI却收到此异常?
最佳答案
在使用者预览中,正确的URL格式显然已更改为ms-appx:/Images/800x600/BackgroundTile.bmp
关于windows-8 - 给定的System.Uri无法转换为Windows.Foundation.Uri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7569720/