@@ -46,7 +46,7 @@ public PopupPage(Popup popup, IPopupOptions popupOptions)
4646 {
4747 popupOptions . OnTappingOutsideOfPopup ? . Invoke ( ) ;
4848 await CloseAsync ( new PopupResult ( true ) ) ;
49- } , ( ) => popupOptions . CanBeDismissedByTappingOutsideOfPopup & popup . CanBeDismissedByTappingOutsideOfPopup ) ;
49+ } , ( ) => GetCanBeDismissedByTappingOutsideOfPopup ( popup , popupOptions ) ) ;
5050
5151 // Only set the content if the parent constructor hasn't set the content already; don't override content if it already exists
5252 base . Content = new PopupPageLayout ( popup , popupOptions , tapOutsideOfPopupCommand ) ;
@@ -107,8 +107,8 @@ public async Task CloseAsync(PopupResult result, CancellationToken token = defau
107107
108108 protected override bool OnBackButtonPressed ( )
109109 {
110- // Only close the Popup if PopupOptions. CanBeDismissedByTappingOutsideOfPopup is true
111- if ( popupOptions . CanBeDismissedByTappingOutsideOfPopup )
110+ // Only close the Popup if CanBeDismissedByTappingOutsideOfPopup is true
111+ if ( GetCanBeDismissedByTappingOutsideOfPopup ( popup , popupOptions ) )
112112 {
113113 CloseAsync ( new PopupResult ( true ) , CancellationToken . None ) . SafeFireAndForget ( ) ;
114114 }
@@ -153,6 +153,10 @@ protected override void OnNavigatedTo(NavigatedToEventArgs args)
153153 return popup ;
154154 }
155155
156+ // Only dismiss when a user taps outside Popup when **both** Popup.CanBeDismissedByTappingOutsideOfPopup and PopupOptions.CanBeDismissedByTappingOutsideOfPopup are true
157+ // If either value is false, do not dismiss Popup
158+ static bool GetCanBeDismissedByTappingOutsideOfPopup ( in Popup popup , in IPopupOptions popupOptions ) => popup . CanBeDismissedByTappingOutsideOfPopup & popupOptions . CanBeDismissedByTappingOutsideOfPopup ;
159+
156160 void HandlePopupOptionsPropertyChanged ( object ? sender , PropertyChangedEventArgs e )
157161 {
158162 if ( e . PropertyName == nameof ( IPopupOptions . CanBeDismissedByTappingOutsideOfPopup ) )
@@ -163,7 +167,7 @@ void HandlePopupOptionsPropertyChanged(object? sender, PropertyChangedEventArgs
163167
164168 void HandlePopupPropertyChanged ( object ? sender , PropertyChangedEventArgs e )
165169 {
166- if ( e . PropertyName == nameof ( Popup . CanBeDismissedByTappingOutsideOfPopup ) )
170+ if ( e . PropertyName == Popup . CanBeDismissedByTappingOutsideOfPopupProperty . PropertyName )
167171 {
168172 tapOutsideOfPopupCommand . ChangeCanExecute ( ) ;
169173 }
0 commit comments