First letter of menu underlined for shortcut - WPF

Asked

Viewed 369 times

3

I am trying to put a shortcut on my system menu in WPF. In Windows form, just change the text property by putting the "&" before, but in WPF does not use "text" but "content"

Somebody help me?

<Menu HorizontalAlignment="Left" Height="31" VerticalAlignment="Top" Width="80">
        <MenuItem Header="Cadastro" Height="31" Width="70" Name="ItemCadastro">
            <MenuItem Header="Empresa" HorizontalAlignment="Left" Width="150" Click="MenuItem_Click"/>
        </MenuItem>
</Menu>
  • tried to make the same change you would in . text, but no . content?

  • Yes, but of error! =/

  • put your menu code here, the xaml. The more complete your question the easier it is for us to help you

  • Editei la @Marciano.Andrade

1 answer

2


To put a keyboard shortcut to a menu, the WPF uses the symbol '_', unlike Windows Forms using the symbol '&' before the letter corresponding to the shortcut.

So your menu should look like this, taking into account that the shortcut to enter the item Register is the C, and to the subitem Company is the E:

<Menu HorizontalAlignment="Left" Height="31" VerticalAlignment="Top" Width="80">
   <MenuItem Header="_Cadastro" Height="31" Width="70" Name="ItemCadastro">
       <MenuItem Header="_Empresa" HorizontalAlignment="Left" Width="150" Click="MenuItem_Click"/>
   </MenuItem>
</Menu>

Source: MSDN Forum.

  • 1

    Thanks buddy, it worked! xD

Browser other questions tagged

You are not signed in. Login or sign up in order to post.