|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Multi Drawer in .NET MAUI Navigation Drawer | Syncfusion® |
| 4 | +description: The navigation drawer allows users to open drawers on multiple sides with different toggle methods, offering customizable layouts and smooth transitions. |
| 5 | +platform: MAUI |
| 6 | +control: SfNavigationDrawer |
| 7 | +documentation: UG |
| 8 | +--- |
| 9 | + |
| 10 | +# Multi Drawer in MAUI Navigation Drawer (SfNavigationDrawer) |
| 11 | + |
| 12 | +The Navigation drawer allows users to open the drawer on multiple sides with different toggle methods. The [DrawerSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.html#Syncfusion_Maui_NavigationDrawer_SfNavigationDrawer_DrawerSettings) class and its properties need to be used when users need to provide multiple drawers. The multiple drawers can be implemented using the following drawer settings. |
| 13 | + |
| 14 | +* DrawerSettings |
| 15 | +* SecondaryDrawerSettings |
| 16 | + |
| 17 | +N> Users can open only one drawer at a time. |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +### DrawerSettings |
| 22 | + |
| 23 | +Implement the primary drawer using the [DrawerSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.html#Syncfusion_Maui_NavigationDrawer_SfNavigationDrawer_DrawerSettings) property in SfNavigationDrawer. The following code sample demonstrates how to customize the primary drawer. |
| 24 | + |
| 25 | +{% tabs %} |
| 26 | + |
| 27 | +{% highlight xaml %} |
| 28 | + |
| 29 | + <navigationDrawer:SfNavigationDrawer> |
| 30 | + <navigationDrawer:SfNavigationDrawer.DrawerSettings> |
| 31 | + <navigationDrawer:DrawerSettings DrawerWidth="250" |
| 32 | + Transition="SlideOnTop" |
| 33 | + ContentBackground="LightGray" |
| 34 | + Position="Left"> |
| 35 | + </navigationDrawer:DrawerSettings> |
| 36 | + </navigationDrawer:SfNavigationDrawer.DrawerSettings> |
| 37 | + </navigationDrawer:SfNavigationDrawer> |
| 38 | + |
| 39 | +{% endhighlight %} |
| 40 | + |
| 41 | +{% highlight c# %} |
| 42 | + |
| 43 | + |
| 44 | + SfNavigationDrawer navigationDrawer = new SfNavigationDrawer(); |
| 45 | + DrawerSettings drawerSettings = new DrawerSettings(); |
| 46 | + drawerSettings.DrawerWidth = 250; |
| 47 | + drawerSettings.Transition = Transition.SlideOnTop; |
| 48 | + drawerSettings.ContentBackground = Colors.LightGray; |
| 49 | + drawerSettings.Position = Position.Left; |
| 50 | + navigationDrawer.DrawerSettings = drawerSettings; |
| 51 | + this.Content = navigationDrawer; |
| 52 | + |
| 53 | + |
| 54 | +{% endhighlight %} |
| 55 | + |
| 56 | +{% endtabs %} |
| 57 | + |
| 58 | +### SecondaryDrawerSettings |
| 59 | + |
| 60 | +Implement the secondary drawer using the SecondaryDrawerSettings property in SfNavigationDrawer. Its properties and functionalities are same as the primary drawer. The secondary drawer can be set to different positions similar to the primary drawer. The following code demonstrates how to customize the secondary drawer. |
| 61 | + |
| 62 | +{% tabs %} |
| 63 | + |
| 64 | +{% highlight xaml %} |
| 65 | + |
| 66 | + <navigationDrawer:SfNavigationDrawer> |
| 67 | + <navigationDrawer:SfNavigationDrawer.SecondaryDrawerSettings> |
| 68 | + <navigationDrawer:DrawerSettings x:Name="secondaryDrawer" |
| 69 | + ContentBackground="Blue" |
| 70 | + DrawerWidth= "250" |
| 71 | + Position="Right" |
| 72 | + Transition="SlideOnTop"> |
| 73 | + </navigationDrawer:DrawerSettings> |
| 74 | + </navigationDrawer:SfNavigationDrawer.SecondaryDrawerSettings> |
| 75 | + </navigationDrawer:SfNavigationDrawer> |
| 76 | + |
| 77 | +{% endhighlight %} |
| 78 | + |
| 79 | +{% highlight c# %} |
| 80 | + |
| 81 | + SfNavigationDrawer navigationDrawer = new SfNavigationDrawer(); |
| 82 | + DrawerSettings secondaryDrawer = new DrawerSettings(); |
| 83 | + secondaryDrawer.Position = Position.Right; |
| 84 | + secondaryDrawer.Transition = Transition.SlideOnTop; |
| 85 | + secondaryDrawer.ContentBackground = Colors.Blue; |
| 86 | + secondaryDrawer.DrawerWidth = 250; |
| 87 | + navigationDrawer.SecondaryDrawerSettings = secondaryDrawer; |
| 88 | + this.Content = navigationDrawer; |
| 89 | + |
| 90 | +{% endhighlight %} |
| 91 | + |
| 92 | +{% endtabs %} |
| 93 | + |
| 94 | +N> When the primary drawer and the secondary drawer are set to the same position, the primary drawer will open on swiping. |
| 95 | + |
| 96 | +## Toggling method |
| 97 | + |
| 98 | +Users can toggle the secondary drawer using the `ToggleSecondaryDrawer` method. |
| 99 | + |
| 100 | +{% highlight c# %} |
| 101 | + |
| 102 | +SfNavigationDrawer navigationDrawer = new SfNavigationDrawer(); |
| 103 | +navigationDrawer.ToggleSecondaryDrawer(); |
| 104 | + |
| 105 | +{% endhighlight %} |
| 106 | + |
| 107 | +### Opening the drawer programmatically |
| 108 | + |
| 109 | +The `IsOpen` property in the [DrawerSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.html#Syncfusion_Maui_NavigationDrawer_SfNavigationDrawer_DrawerSettings) of `SecondaryDrawerSettings` used to open or close the secondary drawer programmatically. |
| 110 | + |
| 111 | +The following code sample demonstrates how to set `IsOpen` property in XAML and C#. |
| 112 | + |
| 113 | +{% tabs %} |
| 114 | + |
| 115 | +{% highlight xaml %} |
| 116 | + |
| 117 | + <navigationDrawer:SfNavigationDrawer> |
| 118 | + <navigationDrawer:SfNavigationDrawer.SecondaryDrawerSettings> |
| 119 | + <navigationDrawer:DrawerSettings IsOpen="True"> |
| 120 | + </navigationDrawer:DrawerSettings> |
| 121 | + </navigationDrawer:SfNavigationDrawer.SecondaryDrawerSettings> |
| 122 | + </navigationDrawer:SfNavigationDrawer> |
| 123 | + |
| 124 | +{% endhighlight %} |
| 125 | + |
| 126 | +{% highlight c# %} |
| 127 | + |
| 128 | + SfNavigationDrawer navigationDrawer = new SfNavigationDrawer(); |
| 129 | + DrawerSettings secondaryDrawer = new DrawerSettings(); |
| 130 | + secondaryDrawer.IsOpen = true; |
| 131 | + navigationDrawer.SecondaryDrawerSettings = secondaryDrawer; |
| 132 | + this.Content = navigationDrawer; |
| 133 | + |
| 134 | +{% endhighlight %} |
| 135 | + |
| 136 | +{% endtabs %} |
| 137 | + |
| 138 | + |
| 139 | + |
0 commit comments