Visual Studio Add-In - adding a context menu item to solution-explorer

纵饮孤独 提交于 2019-12-29 07:36:13

问题


I'm developing my first add-in for Visual studio and we need to add a context menu item to the solution explorer, that shows up for particular file types only (in our case - ".resx").

I've been googling for 2 days now, unable to find any tutorials or code-samples... Only very basic things like adding a menu-item to the VS "tools" menu etc.


回答1:


Well, you need to create a dynamically visible command that you will make visible only when the selected node in the Solution Explorer is .resx file and then add the command as a child of the Solution Explorer context menu (you would need GUID:ID pair of the latter).

Here is a good article showing how to do that: http://blogs.rev-net.com/ddewinter/2008/03/22/dynamic-menu-commands-in-visual-studio-packages-part-2/




回答2:


Take a look at this video. It describes how to append and control visibility of a new menu item by IDTCommandTarget interface.



来源:https://stackoverflow.com/questions/2486818/visual-studio-add-in-adding-a-context-menu-item-to-solution-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!