8

Everyone uses "Properties" window during design mode. When we switch to code view, we dont need properties window.

Is it possible to auto hide properties window while entering code view from design view?

Raj
  • 22,346
  • 14
  • 99
  • 142
  • 2
    Have you seen http://stackoverflow.com/questions/1139710/hide-properties-toolbox-pane-when-not-in-resource-view ? – Andrew Morton Mar 30 '13 at 17:32
  • 1
    VS doesn't have a "design view", the fact that a designer window is opened doesn't put it in any particular operation mode. There are many designers and a lot of them use the Properties window. Having a code window opened at the same time as a designer window is also very possible. – Hans Passant Mar 30 '13 at 17:55
  • Possible duplicate of [Hide Properties/Toolbox Pane when not in Resource View?](https://stackoverflow.com/questions/1139710/hide-properties-toolbox-pane-when-not-in-resource-view) – Wiktor Stribiżew Jun 06 '17 at 19:54
  • I'm not sure about this, just curious. Can you perform a check to see if a control or form is visible and then close the properties window if not? – ThatGuy Aug 15 '17 at 04:30

1 Answers1

2

for vs2015: (also vs2017)

  1. Menu > Tools > Extensions and Updates
  2. install "Visual Commander". (Now you have New Menu called "VCmd")
  3. Menu > "VCmd" > Extensions ... (You will see an Extensions Pane At Right)
  4. Press Add Button at the Extensions Pane. (New tab Wİndow will open.)
  5. write a name for extention.
  6. select language as C#.
  7. paste the code below:
  8. Press Save. Then Press Compile. Then Press Install

edit2: code works on c# winforms + xamarin.android projects.

using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
using System;

public class E: VisualCommanderExt.IExtension {
   private EnvDTE80.DTE2 DTE;
   private EnvDTE.WindowEvents windowEvents;

   public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) {
      this.DTE = DTE;
      DTE.Events.WindowEvents.WindowActivated += OnWindowActivated;
   }

   public void Close() {
      // DTE.Events.WindowEvents.WindowActivated -= OnWindowActivated;
   }

   private void OnWindowActivated(Window gotFocus, Window lostFocus) {
      //project_details();
      HidePropertiesWindowInCodeOrTextView(gotFocus);

    }

   public void HidePropertiesWindowInCodeOrTextView(Window gotFocus) {
      //System.Windows.MessageBox.Show(  gotFocus.Document.Name +"" );

      if (gotFocus.Document == null) return;
      var pwin = DTE.Windows.Item(Constants.vsWindowKindProperties);

      if (isAndroidProject()) 
      {
        pwin.AutoHides = !gotFocus.Caption.EndsWith(".axml");
      }else
      {
        pwin.AutoHides = !gotFocus.Caption.EndsWith(" [Design]");
      }

      //pwin.AutoHides = true;  // pwin.Activate();
   }

   public bool isAndroidProject() {
      if (DTE == null || DTE.ActiveWindow == null) return false;
      var cp = DTE.ActiveWindow.Project;
      var AndroidApp = System.IO.File.ReadAllText(cp.FullName).Contains("AndroidApplication");
      return AndroidApp;
   }

   // for debug , window,document names
   public void project_details() {
      try {
         if (DTE == null || DTE.ActiveWindow == null) return;

         var cp = DTE.ActiveWindow.Project;
         var ad = DTE.ActiveDocument; //Name Kind
         var av = DTE.ActiveWindow; // Caption Kind
         if (cp == null) return;

         var msgp = "aProj:" + (cp != null ? cp.FullName: "[no project for Window]") + "\r\n" 
         + "aDoc: " + ad.Name + ", " + ad.Kind + "\r\n" 
         + "aWin: " + av.Caption + ", " + av.Kind;

         MessageBox.Show(msgp, "ert4 -anbdapp" + isAndroidProject() );

      } catch(Exception ex) {
         MessageBox.Show(ex + "");
      }

   }




}
bh_earth0
  • 2,537
  • 22
  • 24