|
| 1 | +--- |
| 2 | +title: Configuration |
| 3 | +page_title: .NET MAUI BottomSheet Documentation - Configuration |
| 4 | +description: Learn more about how to configure the Telerik UI for .NET MAUI BottomSheet control. |
| 5 | +position: 3 |
| 6 | +slug: bottomsheet-configuration |
| 7 | +--- |
| 8 | + |
| 9 | +# .NET MAUI BottomSheet Configuration |
| 10 | + |
| 11 | +The Telerik UI for .NET MAUI BottomSheet control offers flexible configuration options for states, dimensions, and visual elements. You can define custom states with specific heights, control the sheet's dimensions using absolute or percentage values, and customize the draggable handle to match your application's design. |
| 12 | + |
| 13 | +## States |
| 14 | + |
| 15 | +The BottomSheet control provides a flexible state system that determines how much of the screen the component occupies. You can use predefined states or create custom ones to present content at different visibility levels. |
| 16 | + |
| 17 | +### Predefined States |
| 18 | + |
| 19 | +The control includes four built-in states with predefined heights: |
| 20 | + |
| 21 | +* `Hidden` (default)—Represents a completely hidden bottom sheet. |
| 22 | +* `Minimal`—Represents a minimal bottom sheet state with height `25%`. |
| 23 | +* `Partial`—Represents a partial bottom sheet state with height `50%`. |
| 24 | +* `Full`—Represents a full bottom sheet state with height `90%`. |
| 25 | + |
| 26 | +### Setting States |
| 27 | + |
| 28 | +You can specify the current state using the `State` property of type `BottomSheetState`: |
| 29 | + |
| 30 | +```xaml |
| 31 | +<telerik:RadBottomSheet x:Name="bottomSheet" |
| 32 | + State="Partial"> |
| 33 | + <!-- Content --> |
| 34 | +</telerik:RadBottomSheet> |
| 35 | +``` |
| 36 | + |
| 37 | +### Custom States |
| 38 | + |
| 39 | +You can control the generation of default states using the `AutoGenerateStates` (`bool`) property. The default value is `true`, which means the four predefined states are populated in the `States` collection. |
| 40 | + |
| 41 | +```xaml |
| 42 | +<telerik:RadBottomSheet AutoGenerateStates="False" /> |
| 43 | +``` |
| 44 | + |
| 45 | +Create custom states using the `BottomSheetState` class constructors: |
| 46 | + |
| 47 | +* Using `BottomSheetLength` |
| 48 | + |
| 49 | +```csharp |
| 50 | +public BottomSheetState(string name, BottomSheetLength height) |
| 51 | +``` |
| 52 | + |
| 53 | +* Using `double` value |
| 54 | + |
| 55 | +```csharp |
| 56 | +public BottomSheetState(string name, double size, bool isPercentage = false) |
| 57 | +``` |
| 58 | + |
| 59 | +Example of creating custom states: |
| 60 | + |
| 61 | +```csharp |
| 62 | +// Custom state with 30% height |
| 63 | +var customState = new BottomSheetState("Custom", 30, true); |
| 64 | + |
| 65 | +// Custom state with absolute height = 200 |
| 66 | +var fixedState = new BottomSheetState("Fixed", 200, false); |
| 67 | +``` |
| 68 | + |
| 69 | +### Programmatic State Changes |
| 70 | + |
| 71 | +Use the [`GoToBottomSheetState(string name)` method]({%slug bottomsheet-methods%}) to programmatically change states: |
| 72 | + |
| 73 | +Here is an example setting the predefined name of the state inside the `GoToBottomSheetState(string name)` method: |
| 74 | + |
| 75 | +<snippet id='open-bottomsheet-view' /> |
| 76 | + |
| 77 | +Here is an example setting a custom state: |
| 78 | + |
| 79 | +```csharp |
| 80 | +// Navigate to custom states |
| 81 | +var customState = new BottomSheetState("Custom", 30, true); |
| 82 | +bottomSheet.GoToBottomSheetState("Custom"); |
| 83 | +``` |
| 84 | + |
| 85 | +### States Collection |
| 86 | + |
| 87 | +The BottomSheet provides a read-only `States` collection of type `ObservableCollection<BottomSheetState>` that contains all available states for the bottom sheet, including both predefined and custom states. |
| 88 | + |
| 89 | +> For a runnable example with setting the BottomSheet States, see the [SDKBrowser Demo Application]({%slug sdkbrowser-app%}) and go to **BottomSheet > Features** category. |
| 90 | +
|
| 91 | +## Width |
| 92 | + |
| 93 | +You can specify the width for the bottom sheet content using the `BottomSheetContentWidth` property of type `BottomSheetLength`. The `BottomSheetLength` structure supports both absolute and percentage values: |
| 94 | + |
| 95 | +```xaml |
| 96 | +<!-- Percentage width --> |
| 97 | +<telerik:RadBottomSheet BottomSheetContentWidth="80%"> |
| 98 | + <!-- Content --> |
| 99 | +</telerik:RadBottomSheet> |
| 100 | + |
| 101 | +<!-- Absolute width --> |
| 102 | +<telerik:RadBottomSheet BottomSheetContentWidth="300"> |
| 103 | + <!-- Content --> |
| 104 | +</telerik:RadBottomSheet> |
| 105 | +``` |
| 106 | +```csharp |
| 107 | +// Using percentage |
| 108 | +bottomSheet.BottomSheetContentWidth = new BottomSheetLength(80, true); |
| 109 | + |
| 110 | +// Using absolute value |
| 111 | +bottomSheet.BottomSheetContentWidth = new BottomSheetLength(300, false); |
| 112 | +``` |
| 113 | + |
| 114 | +> For a runnable example with setting the BottomSheet Width, see the [SDKBrowser Demo Application]({%slug sdkbrowser-app%}) and go to **BottomSheet > Features** category. |
| 115 | +
|
| 116 | +## Handle |
| 117 | + |
| 118 | +The BottomSheet exposes a visual cue which indicates the control can be dragged. You can customize the handle by using the `HandleStyle` (`Style` with target type `BottomSheetHandle`) property. |
| 119 | + |
| 120 | +For more details, review the [BottomSheet Handle Styling]({%slug bottomsheet-styling%}#handle-styling) article. |
| 121 | + |
| 122 | +## See Also |
| 123 | + |
| 124 | +- [Animation when opening and closing the bottom sheet]({%slug bottomsheet-animation%}) |
| 125 | +- [Style the BottomSheet]({%slug bottomsheet-styling%}) |
| 126 | +- [Events]({%slug bottomsheet-events%}) |
| 127 | +- [Methods]({%slug bottomsheet-methods%}) |
0 commit comments