我正在尝试直接在主目录中加载项目中的图标.为了做到这一点,我这样做:
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}
Run Code Online (Sandbox Code Playgroud)
即使我的样式我以同样的方式引用它们,这根本不起作用:
<ResourceDictionary Source="pack://application:,,,/ELE100WalkerWPF;component/Resources/Colors.xaml" />
Run Code Online (Sandbox Code Playgroud)
唯一的区别是我的样式在application.xaml中的MergeDictionary中定义,就像这样
<ResourceDictionary Source="Resources/Colors.xaml" />
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么图像没有显示以及我如何解决这个问题?提前致谢