diff --git a/Source/Xamarin/Prism.Forms/Services/Dialogs/DialogService.cs b/Source/Xamarin/Prism.Forms/Services/Dialogs/DialogService.cs index 7a716b83f..a0d25d08c 100644 --- a/Source/Xamarin/Prism.Forms/Services/Dialogs/DialogService.cs +++ b/Source/Xamarin/Prism.Forms/Services/Dialogs/DialogService.cs @@ -70,8 +70,16 @@ void DialogAware_RequestClose(IDialogParameters outParameters) } } - parameters.TryGetValue(KnownDialogParameters.CloseOnBackgroundTapped, out var hideOnBackgroundTapped); - InsertPopupViewInCurrentPage(currentPage as ContentPage, view, hideOnBackgroundTapped, DialogAware_RequestClose); + if(!parameters.TryGetValue(KnownDialogParameters.CloseOnBackgroundTapped, out var closeOnBackgroundTapped)) + { + var dialogLayoutCloseOnBackgroundTapped = DialogLayout.GetCloseOnBackgroundTapped(view); + if(dialogLayoutCloseOnBackgroundTapped.HasValue) + { + closeOnBackgroundTapped = dialogLayoutCloseOnBackgroundTapped.Value; + } + } + + InsertPopupViewInCurrentPage(currentPage as ContentPage, view, closeOnBackgroundTapped, DialogAware_RequestClose); PageUtilities.InvokeViewAndViewModelAction(currentPage, aa => aa.IsActive = false); PageUtilities.InvokeViewAndViewModelAction(view, aa => aa.IsActive = true); diff --git a/Source/Xamarin/Prism.Forms/Services/Dialogs/Xaml/DialogLayout.cs b/Source/Xamarin/Prism.Forms/Services/Dialogs/Xaml/DialogLayout.cs index fe24a6054..6288effb0 100644 --- a/Source/Xamarin/Prism.Forms/Services/Dialogs/Xaml/DialogLayout.cs +++ b/Source/Xamarin/Prism.Forms/Services/Dialogs/Xaml/DialogLayout.cs @@ -52,5 +52,13 @@ public static class DialogLayout public static void SetMask(BindableObject bindable, View value) => bindable.SetValue(MaskProperty, value); + public static readonly BindableProperty CloseOnBackgroundTappedProperty = + BindableProperty.CreateAttached("CloseOnBackgroundTapped", typeof(bool?), typeof(DialogLayout), null); + + public static bool? GetCloseOnBackgroundTapped(BindableObject bindable) => + (bool?)bindable.GetValue(CloseOnBackgroundTappedProperty); + + public static void SetCloseOnBackgroundTapped(BindableObject bindable, bool? value) => + bindable.SetValue(CloseOnBackgroundTappedProperty, value); } }