I am creating a Visual Studio extension with a Custom Tool Window (wpf window).
I have a menu:
<MenuItem Header="_Function" Name="mn" >
<MenuItem Name="menuSearch" Click="MenuSearch_Click" Header="Search">
<MenuItem.Icon>
<Image Source="Resources/search.jpg" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Edit" Name="menuSave" Click="MenuSave_Click" >
<MenuItem.Icon>
<Image Source="Resources/pen.jpg" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
Both of the icons are good in design mode:
But when I run the project only the first one is working:
I have read this post: Image not visible in WPF 2015
and both of the images are Build Action: Resource
. And the last thing i must say is that the second image works if I set a static url:
<MenuItem.Icon>
<Image Source="J:\My_Programs\1397\MyKeywords\MyKeywords\Resources\pen.jpg" />
</MenuItem.Icon>
Do you know the solution? Thanks.
Update
And this post:
WPF - Import image as resource
will not help because one image is working and another not, in a same condition.