Skip to content

Commit 1b40007

Browse files
Add DefaultPopupSettings and DefaultPopupOptionsSettings (#574)
Update Popup.md
1 parent e33aa6a commit 1b40007

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/maui/views/Popup.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,35 @@ By default a user can tap outside of the `Popup` to dismiss it. This can be cont
179179

180180
The `PageOverlayColor`, `Shape`, `Shadow` can all be customized for Popup. See [PopupOptions](./popup/popup-options.md) for more details.
181181

182+
## Setting Popup Defaults
183+
184+
To override the default values for every `Popup` in your app, you can call `.SetPopupDefaults()` and `.SetPopupOptionsDefaults()` when initializing .NET MAUI Community Toolkit.
185+
186+
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.
187+
188+
```cs
189+
.UseMauiCommunityToolkit(static options =>
190+
{
191+
options.SetPopupDefaults(new DefaultPopupSettings
192+
{
193+
CanBeDismissedByTappingOutsideOfPopup = true,
194+
BackgroundColor = Colors.Orange,
195+
HorizontalOptions = LayoutOptions.End,
196+
VerticalOptions = LayoutOptions.Start,
197+
Margin = 72,
198+
Padding = 4
199+
});
200+
options.SetPopupOptionsDefaults(new DefaultPopupOptionsSettings
201+
{
202+
CanBeDismissedByTappingOutsideOfPopup = true,
203+
OnTappingOutsideOfPopup = async () => await Toast.Make("Popup Dismissed").Show(CancellationToken.None),
204+
PageOverlayColor = Colors.Orange,
205+
Shadow = null,
206+
Shape = null
207+
});
208+
})
209+
```
210+
182211
## Events
183212

184213
The `Popup` class provides the following events that can be subscribed to.

0 commit comments

Comments
 (0)