[英]How can I add Context Menu Items to C# Editor of Visual Studio?
I found some example where we can add context menu items to C# code editor at compile time but not at runtime. 我找到了一些示例,可以在编译时但不在运行时将上下文菜单项添加到C#代码编辑器中。 How can we do this at run-time.
我们如何在运行时执行此操作。
Buttons belonging to commands are always added to commandbars (menus, toolbars, context menus) when the extension is registered within Visual Studio (a one-time event). 在Visual Studio中注册扩展时(一次事件),属于命令的按钮总是添加到命令栏(菜单,工具栏,上下文菜单)中。
What can be customized is whether the command is enabled/disabled and whether buttons created from it are visible/invisible. 可以自定义的是该命令是否已启用/禁用以及由此命令创建的按钮是否可见/不可见。 This can be customized:
可以自定义:
1) When the extension is not loaded yet, it is done in the .vsct file through command flags such as DefaultDisabled, DefaultInvisible, etc or VisibilityConstraints . 1)扩展名尚未加载时,可通过命令标志(例如DefaultDisabled,DefaultInvisible等或VisibilityConstraints)在.vsct文件中完成。
2) When the extension is loaded, it is done using the DynamicVisibility command flag in .vsct file and OleMenuCommand.BeforeQueryStatus Event . 2)加载扩展名时,使用.vsct文件中的DynamicVisibility命令标志和OleMenuCommand.BeforeQueryStatus Event来完成 。 See for example: Dynamic Menu Commands in Visual Studio Packages – Part 2
例如,请参阅: Visual Studio软件包中的动态菜单命令–第2部分
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.