如何将按钮添加到自定义工具栏 [英] How to add a button to a custom toolbar
问题描述
我有EnableVSIPLogging,当我点击我的自定义工具栏的现有按钮时,我得到一个GUID / CmdId对,但是CmdID指的是我点击的命令而不是工具栏
根据我的理解,我无法将我的命令添加到工具栏,除非我有工具栏的CmdID所以我该怎么做?
我假设您知道按钮(命令)放在组上,而不是放在工具栏/命令栏上。组是放在工具栏/命令栏上的组:
CommandBar - >组(s) - >按钮
澄清:
A)如果工具栏是"自定义",您已创建它,因此您知道它的Guid / Id,它不包含任何组,因此您必须:
1)创建一个组并将其放在工具栏上
2)创建命令并将其放在组上
在此处查看我的示例CommandToolbar:
https://github.com/visualstudioextensibility/VSX-Samples
B)如果工具栏是"内置的",则创建Visual Studio它,包含带按钮的组。所以你有两个选择:
B1)要创建一个组,将它放在工具栏上(你必须猜测Guid / Id工具栏),创建一个按钮并将其放在组上
B2)创建一个按钮并将其放在工具栏的现有组上(你必须猜测它的Guid / Id组,而不是工具栏的Guid / Id。)
参见:
I have EnableVSIPLogging and when I click to an existing button of my custom toolbar i get a GUID/CmdId pair however the CmdID refers to the command I clicked and not to the toolbar
As I understand it I cannot add my commands to the toolbar unless I have the CmdID of the toolbar so how do I get that?
I assume that you know that buttons (commands) are placed on groups, not on toolbars/commandbars. Groups are the ones that are placed on toolbars/commandbars:
CommandBar -> Group(s) -> Buttons(s)
That clarified:
A) If the toolbar is "custom", you have created it, so you know its Guid/Id, and it contains no groups, so you have to:
1) Create a group and place it on the toolbar
2) Create a command and place it on the group
See my sample CommandToolbar here:
https://github.com/visualstudioextensibility/VSX-Samples
B) If the toolbar is "built-in", Visual Studio created it, and contains groups with buttons. So you have two options:
B1) To create a group, place it on the toolbar (and you must guess the Guid/Id of the toolbar), create a button and place it on the group
B2) To create a button and place it on an existing group of the toolbar (and you must guess the Guid/Id of the group, not the Guid/Id of the toolbar).
See:
这篇关于如何将按钮添加到自定义工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!