We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Access and Accelerator keys

Thread ID:





145750 Jul 6,2019 12:51 PM UTC Jul 8,2019 02:56 PM UTC UWP 1
Tags: SfMenu
Asked On July 6, 2019 12:51 PM UTC

Two questions regarding access keys:
     How do I get the access key underlined in the menu text? Neither the underscore nor the ampersand work.
     I understand it is necessary to use a keyboard handler to implement the access keys, but how do I expand the top-level menu via code? In other words, if the user presses           ALT + E, the Edit menu should open. Additionally, if the user then presses the T key, the Cut Command should execute.

Thirupathi Bala Krishnan [Syncfusion]
Replied On July 8, 2019 02:56 PM UTC

Hi Chris,

Thanks for contacting Syncfusion support.

Please find our response as below,
How do I get the access key underlined in the menu text? Neither the underscore nor the ampersand work. 
For UWP controls, you can set the mnemonic text by focusing the specific string instead of underlining the string. While clicking the Alt button, the mnemonic text to be highlighted. Please refer the below screenshots for easy understanding. Here ‘F’ and ‘E’ are the mnemonics text. While clicking ‘F’ key, the submenu will be opened. 
For more details, please refer the below msdn link: 
You can achieve this requirement by setting the Accesskey for each menu item. After running your application, Pressing the Alt key initializes access key functionality and displays all currently available key combinations in Key Tips. And then invoke the AccessKeyInvoked event handler to handle the click operations of selected menu items.

Please refer the following code sample. 
        <menu:SfMenu  x:Name="menu" HorizontalAlignment="Left" VerticalAlignment="Top"> 
            <menu:SfMenuItem Header="File" AccessKey="F"> 
                <menu:SfMenuItem Header="New" AccessKey="N"/> 
                <menu:SfMenuItem Header="Open" AccessKey="O"/> 
                <menu:SfMenuItemSeparator /> 
                <menu:SfMenuItem Header="Save" AccessKey="S"/> 
                <menu:SfMenuItem Header="Save As" AccessKey="A"/> 
                <menu:SfMenuItemSeparator /> 
                <menu:SfMenuItem Header="Exit" AccessKey="x"/> 
            <menu:SfMenuItem Header="Edit" AccessKey="E"> 
                <menu:SfMenuItem Header="Cut" AccessKey="T" /> 
                <menu:SfMenuItem Header="Copy" AccessKey="C"/>                 
                <menu:SfMenuItem Header="Paste" AccessKey="P"/> 
                <menu:SfMenuItemSeparator /> 
                <menu:SfMenuItem Header="Undo" AccessKey="U"/> 

        public MainPage() 
            //Parent menu 
            SfMenuItem edit = (this.menu.Items[1] as SfMenuItem); 
            edit.AccessKeyInvoked += Edit_AccessKeyInvoked; 
            SfMenuItem cut = edit.Items[0] as SfMenuItem; 
            cut.AccessKeyInvoked += Cut_AccessKeyInvoked; 
        private void Cut_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEventArgs args) 
            //Write your own code here. 
        private void Edit_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEventArgs args) 
            //only one submenu should be displayed at a time  
            (this.menu.Items[0] as SfMenuItem).IsSubMenuOpen = false; 
            (this.menu.Items[1] as SfMenuItem).IsSubMenuOpen = true; 


Please refer the attached videos from the following location:

If the above solution does not meet your actual requirement could you please share the detailed description about your requirement, so that it could be helpful to provide the solution at the earliest.
 I understand it is necessary to use a keyboard handler to implement the access keys, but how do I expand the top-level menu via code?  
You can achieve this requirement by using the IsSubMenuOpen property of menu item. Here you can expand the top level of menu items by using specific index. 

Please refer the following code sample.
        public MainPage() 
            this.menu.Loaded += Menu_Loaded; 
        private void Menu_Loaded(object sender, RoutedEventArgs e) 
            (this.menu.Items[0] as SfMenuItem).IsSubMenuOpen = true;                   

Sample link: https://www.syncfusion.com/downloads/support/forum/145750/ze/SfMenuDemo-211551402

Please let us know if you need any further assistance.

Thirupathi B.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon