Disable left/right keyboard navigation in menu

Hi,

I have an WPF app where I would like to allow the user to go back/forward in a particular control using the Left/Right arrow keys. However, I don't want the menu to get selected at the same time (this happens) - similar to be working in Excel, when the user moves around with the arrow keys, it should not affect the menu to be selected.

Is there a way to disable keyboard navigation in the menuAdv menu?



1 Reply

DV Duraimurugan Vedagiri Syncfusion Team April 27, 2020 01:01 PM UTC

Hi Bergsteinn,

Thanks for using syncfusion products.

You can achieve your requirement by making MenuAdv ExpandMode property as ExpandOnClick.

<syncfusion:MenuAdv  x:Name="MenuAdv" ExpandMode="ExpandOnClick" /> 

Here is a video and sample that works as expected.

Video : https://www.syncfusion.com/downloads/support/forum/153619/ze/Menu-22714627.zip  

Sample : https://www.syncfusion.com/downloads/support/forum/153619/ze/Menu1367634919.zip  

Documentation: https://help.syncfusion.com/wpf/menu/orientation-support#expand-modes-support

Query : Is there a way to disable keyboard navigation in the menuAdv menu?

Yes, you can disable the keyboard navigation in menuadv control using MenuAdv.PreviewKeyDown event handler.

Code Snippet
MenuAdv.PreviewKeyDown += MenuAdv_PreviewKeyDown;

private
void MenuAdv_PreviewKeyDown(object sender, KeyEventArgs e) 
{ 
    switch (e.Key) 
    { 
        case Key.Left: 
            e.Handled = true; 
            break; 
        case Key.Right: 
            e.Handled = true; 
            break; 
        default: 
            break; 
    } 
} 

Note: When you disable the keyboard navigation key you cann’t select the menu item using the left/right key.

Regards,
Durai

Loader.
Up arrow icon