How do I modify the "Add" sub menu items in solution explorer? - visual-studio-2013

How can I modify the items that appear in the solution explorer "Add" context sub menu? Currently there is New Item, Existing Item, New Folder, then Windows Form, User Control, then Component and Class. I especially want to get rid of the 2 WinForms items and replace them with their WPF counterparts. How do I do that in the easiest way?

You can modify the Add sub menu you get when you right click on a project item from the Tools->Customize... menu:
click on the Commands tab
pick the 'Context Menu' radio button
select Project and Solution Context Menus | Project | Add from the combo box
From here you can modify the context menu.
This is not, however, what you want to do in your particular case.
The WPF commands you want are already in that context menu; you'll see WPF commands like "Add Window" and "Add Page" already present in the Customize dialog if you go through the instructions above. The reason that you don't see them in the actual context menu is because Visual Studio is trying to be smart and it thinks that you're developing a WinForms app and not a WPF app. If it thought this was a WPF app, you wouldn't see the windows forms option (and the user control option would create a WPF user control).
In order to correct visual studio's incorrect assumption, you could make a new project - make sure you pick that you want a WPF app - and add all of your existing files, or you can edit your .csproj file: see my answer to this SO question.

Related

Windows 11 add custom buton on new context menu (right click menu)

On Windows 10, I had created a button in the menu that called a python script (see project). I had managed to do this by modifying values in the registry editor.
My button still appears on Windows 11 but only on the old menu and not the new one. You must now click on “More option” to display all the options.
I know it's possible to disable it on the new menu but I don't want to, I really want to add a button on the new. I think it is possible by modifying data in the register editor.
Microsoft changed Windows 11 on purpose to prevent people from easily adding entries to the context menu.
The only way to display your item in the new context menu is to implement a IExplorerCommand COM object and on top of that, your application needs to be packaged (app identity with a sparse manifest) and signed with a valid certificate.
This was announced on the Windows blog last year in this post.
A tool that allows you to add elements on new context menu
https://github.com/ikas-mc/ContextMenuForWindows11

VS2010, VSpackage, adding command for certain filetypes in the context menu?

I'm developing a vspackage for executing *.bat files in my vs2010 solutions.
Therefore I need a button when I right click my files to get a context-menu in solution explorer.
I would like the button only to be visible when right clicking *.bat files. Is that possible?
You can achieve this quite easily. First, you need to create menu item in solution explorer context menu. You can learn how to add menu items in general on MSDN.
To be more exact, you need set your menu group's parent to:
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/>
Both guid and id are predefined in Visual studio, the latter means that the menu item will be displayed whenever user clicks on standard project item. However, you need it only to appear when the name of the file ends with ".bat". This can be achived in BeforeQueryStatus method - see MSDN link above. To find out selected nodes in solution explorer, use
(UIHierarchy)ideObject.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Object
which has SelectedItems property.

Hide items in the right-click context menus in Visual Studio 2010 (08)?

The right-click context menus of the source editor, the project items and the solution item, is getting ridiculously long, and two of them even have scrolling now on my 1680x1050 screen.
Is there any way for me to hide items on these menus, even if I have to add an event to my Visual Studio macro-system and find and hide them manually?
Here's examples, many of these items I never use:
Edit1: The current answer + comments suggest I should use the Customize menu item in the toolbar context menus, go to the second tab, Commands, and use the Context Menus radio selection and find the relevant menus there.
Here are 3, which are suggested by comments:
As you can see, they're all empty.
Edit2: After clicking the "Reset All" button in that dialog, for the Solution and Project menus, I got items in the dialog, that I could edit, but the changes did not affect the actual context menu on either a project or the solution file. Also, after restarting Visual Studio, the dialog contents for those two were again empty.
In Visual Studio 2010 you can:
Goto Tools->Customize
Select the Commands tab
Select the Context menu radio button
Select the appropriate context menu from the dropdown list to the right, and delete away
I believe Visual Studio 2008 is similar.
You will need to choose the correct context menu in the Customise option.
Go to Tool > Customise,
Then choose the Context menu as you did in your Edit1 screenshots but choose "Editor Context Menus | Code Window" from the dropdown menu instead.
From there you should be able to delete whatever command you don't need from your context menu. Next, for the other commands that can't be found in Editor Context Menus | Code Window (mostly plug-ins or extensions related commands) you will have to go through other categories.
For example, I am using CodeMaid and when I right click a file in Solution Explorer the context menu below are shown
In order to remove the 'Cleanup Selected Code' command I will have to choose the Project and Solution Context Menus | Solution Folder dropdown option.
Added: Here is my sample reduced context menu (removed Copy, Cut, Paste, Outline Menu and Create Snippet...)
Hope this helps =)
Edit: In case you want to add back the commands you removed you can either add them back using New Command... or just press Reset All. Keep in mind the later will restore all the commands. Thus unless you are really having trouble finding the removed command use the first method.
I use 3 VS extensions and these 3 are responsible for polluting the context menu:
VSCommands
Power Commands
Power Toys
Using their own options dialogue, it's possible to subject showing those menus to pressing CTRL (in VS Commands) or completely disable them (the other 2 extensions)

Solution Explorer Context Menu Too Long

Ok, so I installed plenty of useful extensions from Extension Manager in Visual Studio 2010.
I really like them but now my context menu in solution explorer is way too long.
So long in fact that I have to scroll down/up using little arrows which is really annoying.
Any solution to that anyone?
The problem is that when you right-click on an entity within the Solution Explorer, the resulting context menu is so loaded down with options, extensions, menus, lists and levels that you have to start scrolling around to get anywhere.
The solution is to declutter that context menu by removing unneccessary items. This can be achieved through the Commands tab of the Tools -> Customize dialog. Specifically, click on the Commands tab, and select the Context Menu button to start customizing anything and (almost) everything to do with those context menus.
Many of the entities within the Solution Explorer have some sort of representation here; the biggest issue you have will be finding the right place to start customizing.
For example, I have a method of Source Control integrated within the Visual Studio environment which causes 7 new menu items to appear when I right-click on a project (Check In, Check Out, Get Latest Version, etc). I do all of my source controlling outside of Visual Studio, so these menu items are just clutter to me. I go to Project and Solution Context Menu | Project and delete anything and everything related to Source Control. Now, when I right-click on a project, none of those options appear in the menu.

Solution Explorer Project Context Menu

Is there a way of adding other options (specifically Add Interface) to the projects right click context menu (Right Click a project > Add > [Class, new Item, new form,...])?
I found one option in the customize dialog to place an 'Add Interface...' item in, but this is always disabled. I found that one under the Projects category of menu customization, so i assumed it would work...
Any ideas?
I'm currently trialing ReSharper, and that has it's own set of Create New context menu entries (which are key bindable), and these support everything I am after.
The ReSharper "Create New" dialogue is a lot faster to respond than the in built Visual Studio one too.

Resources