我試圖添加一個新元素到Visual Studio 2017上下文菜單。我設法元素用下面的代碼添加到工具菜單:Visual Studio擴展:向代碼編輯器添加元素ContextMenu
<Button guid="guidRandomCommandPackageCmdSet" id="RandomCommandId" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_TOOLS_EXT_TOOLS" />
<Icon guid="exclamationIcon" id="exclamationIcon1" />
<Strings>
<ButtonText>Random Text</ButtonText>
</Strings>
</Button>
這是在
<GuidSymbol name="guidRandomCommandPackageCmdSet" value="{47122772-c66f-48f3-b10b-dbbb66da120d}">
.
.
<IDSymbol name="RandomCommandId" value="0x0100" />
</GuidSymbol>
我試圖按照類似的方式註冊,所以我在Buttons
定義了一個新Button
:
<Button guid="guidRandomCommandPackageCmdSet" id="ToDoList" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
<Icon guid="exclamationIcon" id="exclamationIcon1" />
<Strings>
<ButtonText>Add TODO list</ButtonText>
</Strings>
</Button>with the ID symbol
在GuidSymbols的ID registerd
<IDSymbol name="ToDoList" value="0x106" />
但是,當我運行項目時,按鈕不會顯示在上下文菜單中。我試圖按照VSIX: Adding a Menu Item to the Visual Studio Editor Context Menu的建議,但沒有任何建議似乎對我有用。 我從來沒有嘗試過創建一個VS插件,所以我歡迎任何建議。該方法是否可能在VS 2017中更改?