I am trying to load an icon that is in my project directly in the main directory. In order to do that i do this:
Dim uriSrc As Uri = New Uri(\"pack://ELE100Walke
pack://ELE100WalkerWPF:...
is not a valid Pack URI.
You can also not set a BitmapImage's UriSource
property without calling BeginInit
and EndInit
. Use the BitmapImage constructor that takes an Uri argument.
Provided that ShowMCF.png
is located in the top level folder of your Visual Studio Project, and its Build Action is set to Resource
, this should work:
Dim uri As Uri = New Uri("pack://application:,,,/ShowMCF.png")
Dim bitmapImage As BitmapImage = New BitmapImage(uri)
If the image resource is in a referenced assembly (called ELE100WalkerWPF), you must included the assembly name like this:
Dim uri As Uri = New Uri("pack://application:,,,/ELE100WalkerWPF;component/ShowMCF.png")
Dim bitmapImage As BitmapImage = New BitmapImage(uri)