title: Visual Studio Package: Settings the visibility of a custom Solution Explorer context menu item
body: <p>I am creating a Visual Studio Package (this is my first time) and my end goal is to create a context-menu item for the solution explorer that only works on certain file types. (I thought this would be a common thing, but didn't find any decent tutorials on it, so if you know any please let me know)</p>
  
  <p>I followed a simple MSDN guide to create an item in the toolbar first (I forget where is was to link it) and this worked fine.</p>
  
  <p>Then I found a way to move it to the Solution Explorer context menu. This was achieved by manipulating the <code>.vsct</code> file and having an element like this:</p>
  
  <pre><code>&lt;Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/&gt;
  </code></pre>
  
  <p>That probably doesn't matter, but I am trying to set the scene.</p>
  
  <p>Now, because I want to only show the item for certain file types, I need to find a way to check the file when the right-click button is pressed. Cutting a long search short, I <a href="http://msdn.microsoft.com/en-us/library/bb165468%28v=vs.90%29.aspx">found this</a> and ended up with the following code:</p>
  
  <pre><code>protected override void Initialize()
  {
      //stuff
      OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
      menuItem.BeforeQueryStatus += menuItem_BeforeQueryStatus;
      //more stuff
  }
  
  void menuItem_BeforeQueryStatus(object sender, EventArgs e)
  {
      var myCommand = sender as OleMenuCommand;
      myCommand.Text = "NEW NAME";
  }
  </code></pre>
  
  <p>In the above example I am just trying to set the text to try and prove it works, I know there is a <code>Visible</code> property but I want this step to work first. The <code>BeforeQueryStatus</code> event is fired, and debugging shows the code executing as expected. However, there is no change in the context menu item, it stays with the original text.</p>
  
  <p>What am I missing here? Why is it not updating?</p>