title: Use Text From WPF Menu Item
body: <p>I have a menu which lists the current available com ports on the computer. What I want is to get the text of the of the menu item. i.e. if I select <code>COM7</code> it will store <code>COM7</code> into a string. Here is the <code>XAML</code> code for the menu:</p>
  
  <pre><code>&lt;MenuItem x:Name="Menu_Port" Header="Port"&gt;
      &lt;MenuItem.ItemContainerStyle&gt;
          &lt;Style TargetType="{x:Type MenuItem}"&gt;
              &lt;Setter Property="IsCheckable" Value="True" /&gt;
              &lt;Setter Property="StaysOpenOnClick" Value="True" /&gt;
          &lt;/Style&gt;
      &lt;/MenuItem.ItemContainerStyle&gt;
  &lt;/MenuItem&gt;
  </code></pre>
  
  <p>Then the code to get the com ports:</p>
  
  <pre><code>string[] ports = SerialPort.GetPortNames();
  </code></pre>
  
  <p>and the code to add it to the menu:</p>
  
  <pre><code>Menu_Port.ItemsSource = ports;
  </code></pre>
  
  <p>It does the menu correctly, I just need to get the data. All I have managed to do is get the first item in the list.</p>