通过 "ms-appx:///" 引用图像在 Uri 中不起作用
Referring to image through "ms-appx:///" not working in Uri
我目前正在尝试在悬停时设置图像源,我有这个,但它说
System.NotSupportedException: 'The URI prefix is not recognized.'
我的代码行:
HoverBanner.Source = new BitmapImage(new Uri("ms-appx:///Assets/testimg.jpg"));
文件位置:
Image of File Location
文件属性:Image of File Properties
我已经尝试这样做一个多小时了,阅读了很多帖子,做了很多方法,失去了很多脑细胞,我真的快要放弃了。请帮帮我。
您可以尝试使用以下Uri 格式。
Uri 应该以 pack 开头。
我在我的整个应用程序中都使用了这段代码来显示来自资源的图像,并且工作正常。
var source = new BitmapImage();
source.BeginInit();
source.UriSource = new Uri(@"pack://application:,,,/YOUR_NAME_SPACE;component/Images/" + imgName, UriKind.Absolute);
source.EndInit();
我目前正在尝试在悬停时设置图像源,我有这个,但它说
System.NotSupportedException: 'The URI prefix is not recognized.'
我的代码行:
HoverBanner.Source = new BitmapImage(new Uri("ms-appx:///Assets/testimg.jpg"));
文件位置: Image of File Location
文件属性:Image of File Properties
我已经尝试这样做一个多小时了,阅读了很多帖子,做了很多方法,失去了很多脑细胞,我真的快要放弃了。请帮帮我。
您可以尝试使用以下Uri 格式。 Uri 应该以 pack 开头。
我在我的整个应用程序中都使用了这段代码来显示来自资源的图像,并且工作正常。
var source = new BitmapImage();
source.BeginInit();
source.UriSource = new Uri(@"pack://application:,,,/YOUR_NAME_SPACE;component/Images/" + imgName, UriKind.Absolute);
source.EndInit();