Reputation: 1277
I try to show an Image
in my WPF application and added the following code:
<Image Height="20" Width="20" DockPanel.Dock="Left" Source="pack://application:/Testapp.Model/Resources/Icons/systemEnviromentActor.png"/>
However I get the error that blend does not support this type of Image. Microsofts page says that Image
does support .png
.
I created the Image with Paint.net
Upvotes: 1
Views: 1821
Reputation: 128062
The URI is invalid. A valid Resource File Pack URI would look like shown below, where Testapp.Model
is an assembly name.
pack://application:,,,/Testapp.Model;component/Resources/Icons/systemEnviromentActor.png
If the image file is in the same assembly, you could write it as
pack://application:,,,/Resources/Icons/systemEnviromentActor.png
In XAML, you could then even omit the prefix, and just write
Source="/Resources/Icons/systemEnviromentActor.png"
Also make sure that the Build Action of the image file is set to Resource
.
Upvotes: 4