我正在尝试在Windows Universal应用中为我的图片定义源代码,但它会让我误以为:
无效的URI:无法确定URI的格式。
imagePath = "Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;
我搜索了许多论坛并尝试了很多东西,但没有任何作用。谢谢。
答案 0 :(得分:7)
将其更改为:
imagePath = "ms-appx:///Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;
答案 1 :(得分:0)
您必须使用本地,漫游或临时:
var uri = new System.Uri("ms-appdata:///local/Assets/logo.png");
答案 2 :(得分:-1)
试试这个
imagePath = "Assets/Category-other-dark.png";
Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute);
ImageSource imgSource = new BitmapImage(uri);
imgCategory.Source = imgSource;