visual-studiovisual-studio-2017keyboard-shortcutssolution-explorer

Visual Studio - Keyboard Shortcut to close Solution Explorer


CtrlAltL Opens Solution Explorer in Visual Sutdio.

But I'm unable to close it with the same keyboard shortcut.

As I need to do this often (to get more real estate on the screen), how do you close the Solution Explorer with a keyboard shortcut?


Solution

  • You can create the following command with Visual Commander (language: C#) and assign a shortcut to close Solution Explorer:

    public class C : VisualCommanderExt.ICommand
    {
        public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
        {
            var serviceProvider = package as System.IServiceProvider;
            var shell = (Microsoft.VisualStudio.Shell.Interop.IVsUIShell)serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsUIShell));
            var SolutionExplorer = new System.Guid(Microsoft.VisualStudio.Shell.Interop.ToolWindowGuids80.SolutionExplorer);
            Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame;
            shell.FindToolWindow(0, ref SolutionExplorer, out frame);
            frame.Hide();
        }
    }