我已经使用VSCT文件中的此设置为Visual Studio 2015的VSIX包中的工具栏定义了动态组合:
<Combo guid="cmdExplorerToolbarSearchGUID" id="cmdExplorerToolbarSearchID" priority="0x0" type="DynamicCombo"
defaultWidth="50" idCommandList="cmdExplorerToolbarSearchGetListID">
<Parent guid="grpExplorerToolbar3GUID" id="grpExplorerToolbar3ID" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>StretchHorizontally</CommandFlag>
<Strings>
<CanonicalName>cmdExplorerToolbarSearch</CanonicalName>
<ButtonText>Search</ButtonText>
<ToolTipText>Search elements in the model explorer</ToolTipText>
</Strings>
</Combo>
</Combos>
Run Code Online (Sandbox Code Playgroud)
相应的DynamicStatusMenuCommand实例定义如下:
command = new DynamicStatusMenuCommand(
new EventHandler(this.OnPopUpMenuDisplayAction),
new EventHandler(this.OnCmdExplorerToolbarSearchSelected),
new CommandID(CmdExplorerToolbarSearchGUID, CmdExplorerToolbarSearchID));
commands.Add(command);
command = new DynamicStatusMenuCommand(
new EventHandler(this.OnPopUpMenuDisplayAction),
new EventHandler(this.OnCmdExplorerToolbarSearchGetList),
new CommandID(CmdExplorerToolbarSearchGUID, CmdExplorerToolbarSearchGetListID));
commands.Add(command);
Run Code Online (Sandbox Code Playgroud)
最后OnCmdExplorerToolbarSearchSelected像这样的事件处理程序:
private void OnCmdExplorerToolbarSearchSelected(object sender, EventArgs e)
{
// Process the event arguments
OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs;
if (args != …Run Code Online (Sandbox Code Playgroud) 我已经为我正在进行的扩展创建了一个菜单项; 但是,它在"工具"菜单中显示4次而不是仅显示一次.以下是我所拥有的,但我一直无法弄清楚为什么菜单项不止一次出现.
VSCT文件
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="guidTemplatePackPkg">
<Groups>
<Group guid="guidTemplatePackCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
</Group>
</Groups>
<Buttons>
<Button guid="guidTemplatePackCmdSet" id="cmdidMyCommand" priority="0x2000" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_REFERENCES" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<CommandName>AddSideWaffleProject</CommandName>
<ButtonText>Add Template Reference (SideWaffle project)</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
<!-- SideWaffle Menu Options -->
<Commands package="guidMenuOptionsPkg">
<Groups>
<Group guid="guidMenuOptionsCmdSet" id="SWMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
</Group>
</Groups>
<Buttons>
<Button guid="guidMenuOptionsCmdSet" id="cmdidOpenSWMenu" priority="0x0100" type="Button">
<Parent guid="guidMenuOptionsCmdSet" id="SWMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings> …Run Code Online (Sandbox Code Playgroud) 右键单击visual studio解决方案资源管理器时,如何为"添加"菜单项添加子菜单?
我必须添加一个子菜单项,右键单击visual studio解决方案并移动到该菜单中的Add选项.
我正在尝试使用.vsct(vs package).请帮我提出宝贵的建议