@@ -455,6 +455,20 @@ public partial class SfBottomSheet : SfView, IParentThemeElement
455
455
BindingMode . Default ,
456
456
propertyChanged : OnGrabberCornerRadiusPropertyChanged ) ;
457
457
458
+ /// <summary>
459
+ /// Identifies the <see cref="CollapseOnOverlayTap"/> bindable property.
460
+ /// </summary>
461
+ /// <value>
462
+ /// The identifier for <see cref="CollapseOnOverlayTap"/> bindable property.
463
+ /// </value>
464
+ public static readonly BindableProperty CollapseOnOverlayTapProperty = BindableProperty . Create (
465
+ nameof ( CollapseOnOverlayTap ) ,
466
+ typeof ( bool ) ,
467
+ typeof ( SfBottomSheet ) ,
468
+ false ,
469
+ BindingMode . Default
470
+ ) ;
471
+
458
472
#endregion
459
473
460
474
#region Internal Bindable Properties
@@ -781,6 +795,18 @@ public CornerRadius GrabberCornerRadius
781
795
set => SetValue ( GrabberCornerRadiusProperty , value ) ;
782
796
}
783
797
798
+ /// <summary>
799
+ /// Gets or sets whether the bottom sheet should collapse to its minimum height instead of closing when tapping outside.
800
+ /// </summary>
801
+ /// <value>
802
+ /// It accepts Boolean values, and the default value is <c>false</c>.
803
+ /// </value>
804
+ public bool CollapseOnOverlayTap
805
+ {
806
+ get => ( bool ) GetValue ( CollapseOnOverlayTapProperty ) ;
807
+ set => SetValue ( CollapseOnOverlayTapProperty , value ) ;
808
+ }
809
+
784
810
#endregion
785
811
786
812
#region Internal Properties
@@ -1201,7 +1227,14 @@ void OnOverlayGridTapped(object? sender, EventArgs e)
1201
1227
{
1202
1228
if ( _isSheetOpen )
1203
1229
{
1204
- Close ( ) ;
1230
+ if ( CollapseOnOverlayTap )
1231
+ {
1232
+ State = BottomSheetState . Collapsed ;
1233
+ }
1234
+ else
1235
+ {
1236
+ Close ( ) ;
1237
+ }
1205
1238
}
1206
1239
}
1207
1240
@@ -1524,7 +1557,7 @@ void UpdateStateChanged(BottomSheetState oldState, BottomSheetState newState)
1524
1557
_overlayGrid . IsVisible = ( State is BottomSheetState . Collapsed ) ? false : IsModal ;
1525
1558
}
1526
1559
1527
- OnStateChanged ( _stateChangedEventArgs ) ;
1560
+ OnStateChanged ( _stateChangedEventArgs ) ;
1528
1561
}
1529
1562
}
1530
1563
@@ -1616,7 +1649,7 @@ double GetCollapsedPosition()
1616
1649
_overlayGrid . IsVisible = false ;
1617
1650
}
1618
1651
1619
- return targetPosition ;
1652
+ return targetPosition ;
1620
1653
}
1621
1654
1622
1655
/// <summary>
@@ -1767,7 +1800,7 @@ bool ShouldRestrictMovement(double newTranslationY, double diffY)
1767
1800
return false ;
1768
1801
}
1769
1802
1770
- bool isHalfExpandedAndRestricted = State is BottomSheetState . HalfExpanded &&
1803
+ bool isHalfExpandedAndRestricted = State is BottomSheetState . HalfExpanded &&
1771
1804
AllowedState is BottomSheetAllowedState . HalfExpanded &&
1772
1805
_bottomSheet . TranslationY > newTranslationY ;
1773
1806
0 commit comments