From 83436fe1621b8bad834416d84b47166ed6b0b100 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com> Date: Thu, 3 Jul 2025 13:20:20 -0700 Subject: [PATCH] Update Popup.md --- docs/maui/views/Popup.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/maui/views/Popup.md b/docs/maui/views/Popup.md index b3b49a61..19835f45 100644 --- a/docs/maui/views/Popup.md +++ b/docs/maui/views/Popup.md @@ -179,6 +179,35 @@ By default a user can tap outside of the `Popup` to dismiss it. This can be cont The `PageOverlayColor`, `Shape`, `Shadow` can all be customized for Popup. See [PopupOptions](./popup/popup-options.md) for more details. +## Setting Popup Defaults + +To override the default values for every `Popup` in your app, you can call `.SetPopupDefaults()` and `.SetPopupOptionsDefaults()` when initializing .NET MAUI Community Toolkit. + +The `DefaultPopupSettings` provided will be applied as the default value for every `Popup` in your app, and the `DefaultPopupOptionsSettings` will be applied as the default value for `PopupOptions` every time `.ShowPopup()` is called. + +```cs +.UseMauiCommunityToolkit(static options => +{ + options.SetPopupDefaults(new DefaultPopupSettings + { + CanBeDismissedByTappingOutsideOfPopup = true, + BackgroundColor = Colors.Orange, + HorizontalOptions = LayoutOptions.End, + VerticalOptions = LayoutOptions.Start, + Margin = 72, + Padding = 4 + }); + options.SetPopupOptionsDefaults(new DefaultPopupOptionsSettings + { + CanBeDismissedByTappingOutsideOfPopup = true, + OnTappingOutsideOfPopup = async () => await Toast.Make("Popup Dismissed").Show(CancellationToken.None), + PageOverlayColor = Colors.Orange, + Shadow = null, + Shape = null + }); +}) +``` + ## Events The `Popup` class provides the following events that can be subscribed to.