我正在尝试直接在主目录中加载项目中的图标。 为此,我这样做:
success: function(res) {
$('.confirm').hide()
swal("Deleted!", "Successfully deleted", "success")
setTimeout(function(){
window.location = res.redirect_url;
},700);
即使我以相同的方式引用它们的样式,这也根本不起作用:
Dim uriSrc As Uri = New Uri("pack://ELE100WalkerWPF:,,,/assemblyName;Component/ShowMCF.png")
Dim bitmapImage As BitmapImage = New BitmapImage With {.UriSource = uriSrc}
Dim image As System.Windows.Controls.Image = New System.Windows.Controls.Image() With {.Source = bitmapImage}
唯一的区别是我的样式是在application.xaml的MergeDictionary中定义的,
<ResourceDictionary Source="pack://application:,,,/ELE100WalkerWPF;component/Resources/Colors.xaml" />
有人可以解释为什么没有显示图像以及我该如何解决吗?预先感谢
答案 0 :(得分:5)
pack://ELE100WalkerWPF:...
不是有效的Pack URI。
如果不调用UriSource
和BeginInit
,也不能设置BitmapImage的EndInit
属性。使用带有Uri参数的BitmapImage构造函数。
假设ShowMCF.png
位于Visual Studio项目的顶级文件夹中,并且其“构建操作”设置为Resource
,则此方法应该起作用:
Dim uri As Uri = New Uri("pack://application:,,,/ShowMCF.png")
Dim bitmapImage As BitmapImage = New BitmapImage(uri)
如果图像资源在引用的程序集中(称为ELE100WalkerWPF),则必须包括如下程序集名称:
Dim uri As Uri = New Uri("pack://application:,,,/ELE100WalkerWPF;component/ShowMCF.png")
Dim bitmapImage As BitmapImage = New BitmapImage(uri)