Bindable property for Popup#2991
Merged
TheCodeTraveler merged 10 commits intoCommunityToolkit:mainfrom Dec 11, 2025
Merged
Conversation
Replaced manual BindableProperty implementations with the BindableProperty attribute in the `Popup` and `PopupOptions` classes. This simplifies property definitions, reduces boilerplate, and improves code readability. Updated properties such as `Margin`, `Padding`, `HorizontalOptions`, and `VerticalOptions` in `Popup`, and `CanBeDismissedByTappingOutsideOfPopup`, `OnTappingOutsideOfPopup`, `PageOverlayColor`, `Shape`, and `Shadow` in `PopupOptions` to use the attribute with default value creators. Removed redundant manual property implementations as they are now handled by the BindableProperty attribute.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the Popup and PopupOptions classes to use the [BindableProperty] attribute for auto-generating bindable properties instead of manually declaring them. While the intent to modernize the code is good, there are several critical bugs that prevent this code from working correctly.
Key Changes:
- Replaced manual
BindablePropertydeclarations with[BindableProperty]attributes in bothPopupandPopupOptionsclasses - Improved XML documentation for better clarity
- Removed redundant property wrappers and backing fields
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs | Added using System.ComponentModel;, converted 5 properties to use [BindableProperty] attribute with default value creators, and removed manual property implementations |
| src/CommunityToolkit.Maui/Views/Popup/PopupOptions.shared.cs | Converted 5 properties to use [BindableProperty] attribute with default value creators and removed manual property implementations |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Updated the `CanBeDismissedByTappingOutsideOfPopup` property to use a `DefaultValueCreatorMethodName` for dynamic default value resolution. Added the `CreateCanBeDismissedByTappingOutsideOfPopup` method to provide the default value at runtime, improving flexibility and reducing reliance on hardcoded defaults.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
TheCodeTraveler
approved these changes
Dec 11, 2025
Collaborator
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Thanks James! FYI - I went ahead and updated the [BindableProperty]s to use partial property initializers
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description of Change
This pull request refactors how bindable properties are defined and used in the
PopupandPopupOptionsclasses. Instead of manually declaring backingBindablePropertyfields and property wrappers, it leverages the[BindableProperty]attribute to auto-generate these properties, resulting in cleaner and more maintainable code. Additionally, the XML documentation for properties has been improved for clarity.Refactoring of bindable properties:
BindablePropertydeclarations and property wrappers inPopup(Popup.shared.cs) with auto-generated properties using the[BindableProperty]attribute forMargin,Padding,HorizontalOptions,VerticalOptions, andCanBeDismissedByTappingOutsideOfPopup.PopupOptions(PopupOptions.shared.cs) to use[BindableProperty]forCanBeDismissedByTappingOutsideOfPopup,OnTappingOutsideOfPopup,PageOverlayColor,Shape, andShadow, removing manual property logic.Documentation improvements:
PopupandPopupOptionsto be more descriptive and consistent. [1] [2]Code cleanup:
General:
using System.ComponentModel;directive to support the[BindableProperty]attribute.PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Not sure if using a static object is best approach but it works. I am hoping for input on whether to use that or if anyone has any better ideas?