0

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:

design mode

But when I run the project only the first one is working:

Runtime

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.

Farzin Kanzi
  • 3,380
  • 2
  • 21
  • 23

1 Answers1

0

It seems that in a VSIX project, Some of the changes do not affect until the visual studio restart. I restarted the visual studio and now every things are OK with:

Build Action: Resource
Copy To Output Directory: Do Not Copy
Farzin Kanzi
  • 3,380
  • 2
  • 21
  • 23