How to disable keyboard navigation in WPF MenuAdv?
You can disable the keyboard navigation in the WPF MenuAdv control by using the MenuAdv.PreviewKeyDown event. Refer to the below code snippet for your reference.
XAML
<syncfusion:MenuAdv Height="30" Width="150" PreviewKeyDown="MenuAdv_PreviewKeyDown"> <syncfusion:MenuItemAdv Header="File"> <syncfusion:MenuItemAdv Header="New" /> <syncfusion:MenuItemAdv Header="Open" /> </syncfusion:MenuItemAdv> <syncfusion:MenuItemAdv Header="View"> <syncfusion:MenuItemAdv Header="Zoom In" /> <syncfusion:MenuItemAdv Header="Zoom Out" /> <syncfusion:MenuItemAdv Header="Normal View" /> </syncfusion:MenuItemAdv> <syncfusion:MenuItemAdv/> </syncfusion:MenuAdv>
C#
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 can’t select the menu item using the left or right key.
Output:
