Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to select File Menu Items using Keyboard in WPF and C#?

How to select File Menu Items using Keyboard in WPF and C#?

Scheduled Pinned Locked Moved WPF
csharptutorialquestionwpfdesign
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krishna Aditya
    wrote on last edited by
    #1

    Hi, I am developing a WPF UI application . I have a menu on top of the screen, which has File, Help menuitems. In file -> Backend features (shortcut key is ctrl + B), Exit (Ctrl + x) sub menu items. when clicked on any sub menu item, the corresponding window opens. So, with out using mouse, by pressing ctrl + B or Ctrl + x, how can the window be opened?? Also, how can I display a small line below the "F" in the File so that when user presses Alt + F, the File menu should be visible. I am working on WPF using C#. Please guide me. Thanks Ramm

    C A 2 Replies Last reply
    0
    • K Krishna Aditya

      Hi, I am developing a WPF UI application . I have a menu on top of the screen, which has File, Help menuitems. In file -> Backend features (shortcut key is ctrl + B), Exit (Ctrl + x) sub menu items. when clicked on any sub menu item, the corresponding window opens. So, with out using mouse, by pressing ctrl + B or Ctrl + x, how can the window be opened?? Also, how can I display a small line below the "F" in the File so that when user presses Alt + F, the File menu should be visible. I am working on WPF using C#. Please guide me. Thanks Ramm

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I would just handle the key press event, I'm not sure how to do shortcuts in WPF on the menu, if autocomplete and MSDN doesn't tell you, just handle the keypress directly

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • K Krishna Aditya

        Hi, I am developing a WPF UI application . I have a menu on top of the screen, which has File, Help menuitems. In file -> Backend features (shortcut key is ctrl + B), Exit (Ctrl + x) sub menu items. when clicked on any sub menu item, the corresponding window opens. So, with out using mouse, by pressing ctrl + B or Ctrl + x, how can the window be opened?? Also, how can I display a small line below the "F" in the File so that when user presses Alt + F, the File menu should be visible. I am working on WPF using C#. Please guide me. Thanks Ramm

        A Offline
        A Offline
        ABitSmart
        wrote on last edited by
        #3

        Try something like this,

        <Menu DockPanel.Dock="Top">
        <MenuItem Header="_File">
        <MenuItem Header="Exit" InputGestureText="Ctrl+X">
        </MenuItem>
        </MenuItem>
        </Menu>

        And look at this[^] and this[^] for the CommandBinding option

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups