[英]C# - Windows Universal app - Image Source doesn't work
I'm trying to define source for my image in Windows Universal app, but it givs me following error: 我正在尝试在Windows Universal应用程序中为我的图像定义源代码,但它给我提供了以下错误:
Invalid URI: The format of the URI could not be determined.
无效的URI:无法确定URI的格式。
imagePath = "Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;
I search through many forums and tryed a lot of things but nothing works. 我搜索了许多论坛并尝试了很多东西,但没有任何作用。 Thank you.
谢谢。
Change it to: 将其更改为:
imagePath = "ms-appx:///Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;
您必须使用本地,漫游或临时:
var uri = new System.Uri("ms-appdata:///local/Assets/logo.png");
Try this 试试这个
imagePath = "Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.