Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3678496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:20:54+00:00 2026-05-19T03:20:54+00:00

I need a simple way to set a shortcut for menu items. But this

  • 0

I need a simple way to set a shortcut for menu items.

But this don´t work with shortcut, just with click:

<MenuItem Header="Editar">
    <MenuItem Header="Procurar" Name="MenuProcurar"
              InputGestureText="Ctrl+F"
              Click="MenuProcurar_Click">
        <MenuItem.ToolTip>
            <ToolTip>
                Procurar
            </ToolTip>
        </MenuItem.ToolTip>
    </MenuItem>
</MenuItem>

I am using WPF 4.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:20:55+00:00Added an answer on May 19, 2026 at 3:20 am

    You need to use KeyBindings (and CommandBindings if you (re)use RoutedCommands such as those found in the ApplicationCommands class) for that in the controls where the shortcuts should work.

    e.g.

    <Window.CommandBindings>
            <CommandBinding Command="New" Executed="CommandBinding_Executed" />
    </Window.CommandBindings>
    <Window.InputBindings>
            <KeyBinding Key="N" Modifiers="Control" Command="New"/>
    </Window.InputBindings>
    

    For custom RoutedCommands:

    static class CustomCommands
    {
        public static RoutedCommand DoStuff = new RoutedCommand();
    }
    

    usage:

    <Window
        ...
        xmlns:local="clr-namespace:MyNamespace">
            <Window.CommandBindings>
                    <CommandBinding Command="local:CustomCommands.DoStuff" Executed="DoStuff_Executed" />
            </Window.CommandBindings>
            <Window.InputBindings>
                    <KeyBinding Key="D" Modifiers="Control" Command="local:CustomCommands.DoStuff"/>
            </Window.InputBindings>
        ...
    </Window>
    

    (It is often more convenient to implement the ICommand interface rather than using RoutedCommands. You can have a constructor which takes delegates for Execute and CanExecute to easily create commands which do different things, such implementations are often called DelegateCommand or RelayCommand. This way you do not need CommandBindings.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure there must be a simple way to do this, but I've been
I need a simple and fast way to compare two images for similarity. I.e.
Is there a simple way in factory girl to create a new factory only
So, I have this new project. My company uses the SalesForce.com cloud to store
I need to display a full screen DirectX window from a Qt app. Although
I have an MPI implementation basically for IDW2 based gridding on a set of
I am doing a brute force search for gradient extremals on the following example
I am trying to setup an hierarchial structure for company. I was using SQL
I have a table with two fields, date_start & date_end, both are date fields.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.