VSIX项目上下文菜单 [英] VSIX Project Context Menu
问题描述
我正试图创建一个Visual Studio 2017扩展,只是为了娱乐并了解VS可扩展性的工作原理.
I'm trying to create a Visual Studio 2017 extension, just for fun and to learn how VS extensibility works.
我的扩展程序必须可以从解决方案资源管理器"选项卡中用作上下文菜单按钮,但我想将其包含在非root用户的菜单级别.
My extension must be usable from the Solution Explorer tab as a context menu button, but I would like to include it at a menu level that isn't root.
我的目标是将其放在添加"子菜单中,但目前我只能将其放在根级别(当您右键单击项目"项目时,菜单项显示为上下文菜单控件的最后一个).
My goal is to put it in the "Add" sub-menu, but at the moment I'm only able to put it at root level (when you right-click the Project item, the menu entry is shown as the last of the context menu control).
如何将其移动到添加"节点下?
可以通过在.vsct文件中配置的CommandPlacement标签完成此操作吗?
How can I move it under the "Add" node?
Can it be done from the CommandPlacement tags I have configured in my .vsct file?
推荐答案
将IDG_VS_CTXT_PROJECT_ADD_ITEMS组ID用作命令的父级.如果您使用CommandPlacement,它将是:
Use as parent of your command the IDG_VS_CTXT_PROJECT_ADD_ITEMS group id. If you are using CommandPlacement it would be:
<CommandPlacement guid="..." id="..." priority="0x0001" >
<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_ITEMS"/>
</CommandPlacement>
记住:
- 一个组的父级可以是另一个组,菜单,工具栏,上下文菜单等,它们可以由您的扩展程序创建,也可以是现有的VS(由前缀"IDM_"标识)创建.请参阅 Visual Studio工具栏的GUID和ID .
- 命令的父级是总是组,而不是菜单,上下文菜单或工具栏.该组可以是新的(由您的扩展名创建),也可以是现有的Visual Studio组,其前缀为"IDG_".您在上面的链接中有一些内置的Visual Studio组,但是要获取更详尽的列表,请安装 VsctBuiltInCache.cs文件.
- The parent of a group can be another group, a menu, a toolbar, a context menu, etc. either created by your extension or an existing one of VS, identified by prefix "IDM_". See GUIDs and IDs of Visual Studio menus and GUIDs and IDs of Visual Studio toolbars.
- The parent of a command is always a group, never a menu, context menu or toolbar. The group can be new (created by your extension) or an existing group of Visual Studio, identified by prefix "IDG_". You have some built-in Visual Studio groups in the links above, but for a more exhaustive list install the ExtensionTools extension (Mads Kristensen) that provides intellisense in the .vsct file or check the source code of its VsctBuiltInCache.cs file.
这篇关于VSIX项目上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!