title: How can I toggle the main menu visibility using the Alt key in WPF?
body: <p>I'd like the main menu in my WPF app to behave like the main menu in IE8: </p>
  
  <ul>
  <li>it's not visible when the app starts</li>
  <li>pressing and releasing Alt makes it visible</li>
  <li>pressing and releasing Alt again makes it invisible again</li>
  <li>repeat until bored</li>
  </ul>
  
  <p>How can I do this?  Does it have to be code?</p>
  
  <p><em>Added in response to answers submitted, because I'm still having trouble:</em></p>
  
  <p>My Shell code-behind now looks like this:</p>
  
  <pre><code>public partial class Shell : Window
  {
      public static readonly DependencyProperty IsMainMenuVisibleProperty;
  
      static Shell()
      {
          FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata();
          metadata.DefaultValue = false;
  
          IsMainMenuVisibleProperty = DependencyProperty.Register(
              "IsMainMenuVisible", typeof(bool), typeof(Shell), metadata);
      }
  
      public Shell()
      {
          InitializeComponent();
  
          this.PreviewKeyUp += new KeyEventHandler(Shell_PreviewKeyUp);
      }
  
      void Shell_PreviewKeyUp(object sender, KeyEventArgs e)
      {
          if (e.SystemKey == Key.LeftAlt || e.SystemKey == Key.RightAlt)
          {
              if (IsMainMenuVisible == true)
                  IsMainMenuVisible = false;
              else
                  IsMainMenuVisible = true;
          }
      }
  
      public bool IsMainMenuVisible
      {
          get { return (bool)GetValue(IsMainMenuVisibleProperty); }
          set { SetValue(IsMainMenuVisibleProperty, value); }
      }
  }
  </code></pre>