-
Notifications
You must be signed in to change notification settings - Fork 110
Feature/maui/sl popup v2 #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5099fdf
Initial changes based on the rework for Popup
bijington 9b22c64
Popup v2 rework
bijington 03f6e47
Update docs/maui/views/popup/popup-options.md
bijington dd88d83
PopupService improvements
bijington 4859773
Merge branch 'feature/maui/sl-popup-v2' of https://github.com/Microso…
bijington 0b8bb9e
Further improvements
bijington 5cfe8ed
Include new pages in the TOC
bijington 35dffbe
Move note to part of the main text
bijington dcb12b0
Improve the code examples
bijington 8d8ee4a
Add images to docs
bijington a87ce93
PopupService code corrections
bijington b979369
Improvements based on review
bijington eafdfa0
Correct close method name
bijington cb7f271
Remove unused image
bijington 9fc7158
Improve the code readibility
bijington 4dec735
Update docs/maui/views/popup/popup-result.md
bijington 44f1206
Rework based on review comments
bijington ddb7960
Fix validation issues
bijington d1e3fb0
Fix validation issues
bijington f01d65c
Correct path
bijington 49fd8ba
Apply suggestions from code review
bijington d60a4f8
Apply suggestions from code review
bijington 82cb535
Make close examples async
bijington 1f874a8
Merge branch 'main' into feature/maui/sl-popup-v2
jfversluis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
--- | ||
title: PopupOptions - .NET MAUI Community Toolkit | ||
author: bijington | ||
description: The PopupOptions class provides the ability to customize the appearance and behavior of the Popup. | ||
ms.date: 05/19/2025 | ||
--- | ||
|
||
# PopupOptions - Customizing the popup behavior and appearance | ||
|
||
The `PopupOptions` class provides the ability to customize the appearance and behavior of the `Popup`. | ||
|
||
All of the examples in this page make use of the `SimplePopup` example that is covered at [`Popup`](../popup.md). | ||
|
||
## Controlling whether the user can dismiss the Popup | ||
|
||
`PopupOptions` provides the `CanBeDismissedByTappingOutsideOfPopup` property which can control the whether the user can tap or click outside of the Popup bounds to dismiss the currently displayed Popup. This is `true` by default. The following example shows how to prevent a user from being able to dismiss the Popup. | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
CanBeDismissedByTappingOutsideOfPopup = false | ||
}); | ||
``` | ||
|
||
bijington marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> [!NOTE] | ||
> It is possible to cache `PopupOptions` to reuse on future navigation actions or with other popups that share the same configuration, that would prevent unnecessary allocations. | ||
|
||
## Customize the Overlay Color | ||
|
||
`PopupOptions` provides the `PageOverlayColor` property which can control the `Color` that overlays the current page. The following example shows how to set the `PageOverlayColor` to orange. | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
PageOverlayColor = Colors.Orange | ||
}); | ||
``` | ||
|
||
 | ||
|
||
The above `Popup` renders with an opaque background, to control the opacity modify the alpha property of a `Color`. The following example shows how to | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
PageOverlayColor = Colors.Orange.WithAlpha(0.5f) | ||
}); | ||
``` | ||
|
||
 | ||
|
||
## Customize the Popup Border | ||
|
||
`PopupOptions` provides the `Shape` property which can control the appearance of the border around the content displayed in the `Popup`. The following example shows how to set the border to be a rounded rectangle with a corner radius of 4 and a stroke of blue. | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
Shape = new RoundRectangle | ||
{ | ||
CornerRadius = new CornerRadius(4), | ||
Stroke = Colors.Blue, | ||
StrokeThickness = 4 | ||
} | ||
}); | ||
``` | ||
|
||
 | ||
|
||
For more details on how to customize the `Shape` property see [.NET MAUI Shapes](/dotnet/maui/user-interface/controls/shapes/). | ||
|
||
### Disable the Popup Border | ||
|
||
In order to disable the border on a Popup, simply set the `Shape` property to `null`. The following example shows how to achieve this | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
Shape = null | ||
}); | ||
``` | ||
|
||
 | ||
|
||
## Customize the Popup Shadow | ||
|
||
`PopupOptions` provides the `Shadow` property which can control the shadow which is applied to the `Popup`. The following example shows how to set the shadow to be green with an opacity of 80%. | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
Shadow = new Shadow | ||
{ | ||
Brush = Brush.Green, | ||
Opacity = 0.8f | ||
} | ||
}); | ||
``` | ||
|
||
 | ||
|
||
For more details on how to customize the `Shadow` property see [.NET MAUI Shadow](/dotnet/maui/user-interface/shadow). | ||
|
||
### Disable the Popup Shadow | ||
|
||
In order to disable the border on a Popup, simply set the `Shape` property to `null`. The following example shows how to achieve this | ||
|
||
```csharp | ||
await this.ShowPopupAsync(new SimplePopup(), new PopupOptions | ||
{ | ||
Shadow = null | ||
}); | ||
``` | ||
|
||
 | ||
|
||
## Properties | ||
|
||
|Property |Type |Description | | ||
|---------|---------|---------| | ||
| `CanBeDismissedByTappingOutsideOfPopup` | `bool` | Gets or sets a value indicating whether the popup can be dismissed by tapping outside of the Popup. On Android - when false the hardware back button is disabled. | | ||
| `OnTappingOutsideOfPopup` | `Action` | Gets or sets the `Action` to be executed when the user taps outside the `Popup`. | | ||
| `PageOverlayColor` | `Color` | Gets or sets the `Color` of the overlay behind the `Popup`. | | ||
| `Shape` | `Shape` | Gets or sets the border shape for the `Popup`. Set this to `null` to remove any border styling. | | ||
| `Shadow` | `Shadow` | Gets or sets the `Shadow` of the `Popup`. Set this to `null` to remove any shadow. | | ||
|
||
## Examples | ||
|
||
You can find an example of this feature in action in the [.NET MAUI Community Toolkit Sample Application](https://github.com/CommunityToolkit/Maui/blob/main/samples/CommunityToolkit.Maui.Sample/Pages/Views/Popups/ReturnResultPopup.xaml). | ||
|
||
## API | ||
|
||
You can find the source code for `PopupOptions` over on the [.NET MAUI Community Toolkit GitHub repository](https://github.com/CommunityToolkit/Maui/tree/main/src/CommunityToolkit.Maui/Views/Popup). | ||
|
||
## Additional Resources | ||
|
||
- [`Popup`](../popup.md) | ||
- [`IPopupService`](../popup-service.md) | ||
- [`Popup` - Returning a result](./popup-result.md) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.