Events in .NET MAUI Navigation Drawer (SfNavigationDrawer)

21 May 20253 minutes to read

There are five built-in events in the SfNavigationDrawer control, namely:

DrawerOpening event

The DrawerOpening event is triggered before the drawer pane opens. Restrict the drawer from opening by canceling this event by setting the Cancel property in the event argument to true. The event arguments are of type CancelEventArgs. It exposes the following property:

  • Cancel: Determines if the drawer opening should be canceled.
<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer" DrawerOpening="navigationDrawer_DrawerOpening"/>
public MainPage()
{
    InitializeComponent();
    navigationDrawer.DrawerOpening += navigationDrawer_DrawerOpening;
}

private void navigationDrawer_DrawerOpening(object sender, System.ComponentModel.CancelEventArgs e)
{
    e.Cancel = true;
}

DrawerOpened event

The DrawerOpened event triggered after a drawer is opened.

You can execute your own set of codes once the drawer is opened.

<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer" DrawerOpened="navigationDrawer_DrawerOpened"/>
public MainPage()
{
    InitializeComponent();
    navigationDrawer.DrawerOpened += navigationDrawer_DrawerOpened;
}

private void navigationDrawer_DrawerOpened(object sender, EventArgs e)
{
    // Codes that need to be executed once the drawer is opened.
}

DrawerClosing event

The DrawerClosing event is triggered before the drawer pane closes. Restrict the drawer from closing by canceling this event by setting the Cancel property in the event argument to true. The event arguments are of type CancelEventArgs. It exposes the following property:

  • Cancel: Determines if the drawer closing should be canceled.
<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer" DrawerClosing="navigationDrawer_DrawerClosing"/>
public MainPage()
{
    InitializeComponent();
    navigationDrawer.DrawerClosing += navigationDrawer_DrawerClosing;
}

private void navigationDrawer_DrawerClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
    e.Cancel = true;
}

DrawerClosed event

The DrawerClosed event triggered after a drawer is closed.

You can execute your own set of codes once the drawer is closed.

<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer" DrawerClosed="navigationDrawer_DrawerClosed"/>
public MainPage()
{
    InitializeComponent();
    navigationDrawer.DrawerClosed += navigationDrawer_DrawerClosed;
}

private void navigationDrawer_DrawerClosed(object sender, EventArgs e)
{
    // Codes that need to be executed once the drawer is closed.
}

DrawerToggled event

The DrawerToggled event is triggered after a drawer is opened or closed. The event arguments are of type ToggledEventArgs. It exposes the following property:

  • IsOpen: Indicates whether the drawer is opened or closed.
<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer" DrawerToggled="navigationDrawer_DrawerToggled"/>
public MainPage()
{
    InitializeComponent();
    navigationDrawer.DrawerToggled += navigationDrawer_DrawerToggled;
}

private void navigationDrawer_DrawerToggled(object sender, Syncfusion.Maui.NavigationDrawer.ToggledEventArgs e)
{
    var isOpen = e.IsOpen;
    // Codes that need to be executed once the drawer is toggled.
}