Category / Section
How to stop the RadialMenu from opening?
1 min read
When you click the navigation button, the SfRadialMenu opens automatically. This can be manually stopped by forcing the RadialMenu to remain closed. To achieve this,
- Retrieve the navigation button in the SfRadailMenu, and hook its MouseLeftButtonUp event.
- Handle the event by setting e.Handled=true.
This restricts the SfRadialMenu from opening.
The following code example demonstrates the same.
Xaml
<navigation:SfRadialMenu x:Name="radialMenu" Loaded="radialMenu_Loaded"> <navigation:SfRadialMenuItem Header="Cut"/> <navigation:SfRadialMenuItem Header="Copy"/> <navigation:SfRadialMenuItem Header="Paste"/> </navigation:SfRadialMenu>
C#
public partial class MainWindow : Window { bool CanOpen = false; public MainWindow() { InitializeComponent(); } private void radialMenu_Loaded(object sender, RoutedEventArgs e) { radialMenu.Loaded -= radialMenu_Loaded; Button navigationButton = radialMenu.Template.FindName("PART_NavigationButton", radialMenu) as Button; if(navigationButton!=null) { navigationButton.PreviewMouseLeftButtonDown += navigationButton_PreviewMouseLeftButtonDown; } } void navigationButton_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!CanOpen) { e.Handled = true; } } }