How to make a non-modal sheet using BottomSheetDialog in .NET MAUI?

97 Views Asked by At

I have a method that creates a bottom sheet using BottomSheetDialog in a .NET MAUI app. The code looks something like this:

public static BottomSheetDialog ShowBottomSheet(this Page page, IView bottomSheetContent) { var bottomSheetDialog = new BottomSheetDialog(Platform.CurrentActivity?.Window?.DecorView.FindViewById(Android.Resource.Id.Content)?.Context ?? throw new InvalidOperationException("Context is null")); bottomSheetDialog.SetContentView(bottomSheetContent.ToPlatform(page.Handler?.MauiContext ?? throw new Exception("MauiContext is null"))); bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.NotTouchable); bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.DimBehind); bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.NotFocusable); bottomSheetDialog.Window?.AddFlags(WindowManagerFlags.SplitTouch); bottomSheetDialog.Behavior.FitToContents = true; bottomSheetDialog.Behavior.Draggable = true; bottomSheetDialog.Behavior.SkipCollapsed = true; bottomSheetDialog.SetCanceledOnTouchOutside(false); bottomSheetDialog.Show(); return bottomSheetDialog; }

This method creates a modal bottom sheet. I want to modify it to create a non-modal bottom sheet, i.e., a sheet that doesn't block interaction with the underlying UI. How can I achieve this? I've tried adjusting the Behavior properties such as FitToContents, Draggable, and SkipCollapsed etc, but I haven't been able to make it non-modal.

Any help or guidance on how to modify this code to create a non-modal bottom sheet would be greatly appreciated.

Thanks in advance!

0

There are 0 best solutions below