Side Pane Content in .NET MAUI Navigation Drawer (SfNavigationDrawer)
29 Jul 202616 minutes to read
The side pane of the .NET MAUI Navigation Drawer is only visible when the drawer is open. The side pane is composed of three regions that stack vertically from top to bottom:
- Header content - displayed at the top of the side pane.
- Drawer content - displayed in the middle; occupies the space left by the header and footer.
- Footer content - displayed at the bottom of the side pane.
NOTE
The header and footer are optional; the drawer content is required to allocate space for the side pane.
Prerequisites
Before using the SfNavigationDrawer, ensure the following NuGet package is installed in your .NET MAUI project:
Syncfusion.Maui.NavigationDrawer
For step-by-step setup, refer to the Getting Started documentation.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
| DrawerHeaderView | View |
null |
The view displayed at the top of the side pane. |
| DrawerHeaderHeight | double |
50 |
Height of the header area. Set to 0 to hide the header. |
| DrawerContentView | View |
null |
The view displayed in the middle of the side pane. Required to allocate space for the drawer. |
| DrawerFooterView | View |
null |
The view displayed at the bottom of the side pane. |
| DrawerFooterHeight | double |
50 |
Height of the footer area. Set to 0 to hide the footer. |
| ContentBackground | Color |
Color.FromArgb("F7F2FB") |
Background color of the side pane content area. |
Layout
The side pane uses a vertical layout with the following stacking order:
-
DrawerHeaderView(top) - height controlled byDrawerHeaderHeight. -
DrawerContentView(middle) - fills the remaining space. -
DrawerFooterView(bottom) - height controlled byDrawerFooterHeight.
If any region is null or its height is 0, that region is not rendered and the adjacent regions expand to fill the space.
Header content
The header is displayed at the top of the side pane. Use the DrawerHeaderView property to set the header content and DrawerHeaderHeight to control its height.
<navigationDrawer:SfNavigationDrawer x:Name="navigationDrawer">
<navigationDrawer:SfNavigationDrawer.DrawerSettings>
<navigationDrawer:DrawerSettings DrawerHeaderHeight="150"
DrawerWidth="250">
<navigationDrawer:DrawerSettings.DrawerHeaderView>
<Grid BackgroundColor="#6750A4">
<VerticalStackLayout VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Header View" TextColor="White" />
</VerticalStackLayout>
</Grid>
</navigationDrawer:DrawerSettings.DrawerHeaderView>
</navigationDrawer:DrawerSettings>
</navigationDrawer:SfNavigationDrawer.DrawerSettings>
</navigationDrawer:SfNavigationDrawer>SfNavigationDrawer navigationDrawer = new SfNavigationDrawer()
{
DrawerSettings = new DrawerSettings
{
DrawerWidth = 250,
DrawerHeaderHeight = 150,
DrawerHeaderView = new Grid
{
BackgroundColor = Color.FromArgb("#6750A4"),
Children =
{
new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new Label { Text = "Header View", TextColor = Colors.White }
}
}
}
},
},
};
Header height
Adjust the height of the drawer header content using the DrawerHeaderHeight property.
NOTE
The
DrawerHeaderViewcan be removed by setting theDrawerHeaderHeightto zero.
Footer content
The footer is displayed at the bottom of the side pane. Use the DrawerFooterView property to set the footer content and DrawerFooterHeight to control its height.
<navigationDrawer:SfNavigationDrawer x:Name="navigationDrawer">
<navigationDrawer:SfNavigationDrawer.DrawerSettings>
<navigationDrawer:DrawerSettings DrawerFooterHeight="150"
DrawerWidth="250">
<navigationDrawer:DrawerSettings.DrawerFooterView>
<Grid BackgroundColor="#6750A4">
<VerticalStackLayout VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Footer View" TextColor="White" />
</VerticalStackLayout>
</Grid>
</navigationDrawer:DrawerSettings.DrawerFooterView>
</navigationDrawer:DrawerSettings>
</navigationDrawer:SfNavigationDrawer.DrawerSettings>
</navigationDrawer:SfNavigationDrawer>SfNavigationDrawer navigationDrawer = new SfNavigationDrawer()
{
DrawerSettings = new DrawerSettings
{
DrawerWidth = 250,
DrawerFooterHeight = 150,
DrawerFooterView = new Grid
{
BackgroundColor = Color.FromArgb("#6750A4"),
Children =
{
new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new Label { Text = "Footer View", TextColor = Colors.White }
}
}
}
},
},
};
Footer height
Adjust the height of the drawer footer content using the DrawerFooterHeight property.
NOTE
The
DrawerFooterViewcan be removed by setting theDrawerFooterHeightto zero.
Drawer content
The drawer content is displayed between the header and footer. It is set using the DrawerContentView property and occupies the space left by the header and footer.
<navigationDrawer:SfNavigationDrawer x:Name="navigationDrawer">
<navigationDrawer:SfNavigationDrawer.DrawerSettings>
<navigationDrawer:DrawerSettings DrawerWidth="250">
<navigationDrawer:DrawerSettings.DrawerContentView>
<Grid BackgroundColor="#6750A4">
<VerticalStackLayout VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Drawer Content" TextColor="White" />
</VerticalStackLayout>
</Grid>
</navigationDrawer:DrawerSettings.DrawerContentView>
</navigationDrawer:DrawerSettings>
</navigationDrawer:SfNavigationDrawer.DrawerSettings>
</navigationDrawer:SfNavigationDrawer>SfNavigationDrawer navigationDrawer = new SfNavigationDrawer()
{
DrawerSettings = new DrawerSettings
{
DrawerWidth = 250,
DrawerContentView = new Grid
{
BackgroundColor = Color.FromArgb("#6750A4"),
Children =
{
new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new Label { Text = "Drawer Content", TextColor = Colors.White }
}
}
}
},
},
};
Drawer content background
Customize the background color of the side pane content area by setting the ContentBackground property in DrawerSettings.
<navigationDrawer:SfNavigationDrawer x:Name="navigationDrawer">
<navigationDrawer:SfNavigationDrawer.DrawerSettings>
<navigationDrawer:DrawerSettings ContentBackground="Red" DrawerWidth="250">
<navigationDrawer:DrawerSettings.DrawerContentView>
<Grid BackgroundColor="#6750A4">
<VerticalStackLayout VerticalOptions="Center"
HorizontalOptions="Center">
<Label Text="Drawer Content" TextColor="White" />
</VerticalStackLayout>
</Grid>
</navigationDrawer:DrawerSettings.DrawerContentView>
</navigationDrawer:DrawerSettings>
</navigationDrawer:SfNavigationDrawer.DrawerSettings>
</navigationDrawer:SfNavigationDrawer>SfNavigationDrawer navigationDrawer = new SfNavigationDrawer()
{
DrawerSettings = new DrawerSettings
{
DrawerWidth = 250,
ContentBackground = Colors.Red,
DrawerContentView = new Grid
{
BackgroundColor = Color.FromArgb("#6750A4"),
Children =
{
new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new Label { Text = "Drawer Content", TextColor = Colors.White }
}
}
}
}
}
};