Skip to content

[BUG] PopupService.ShowPopup causes Behavior.OnAttached to execute more than once #1912

@bengavin

Description

@bengavin

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When a behavior is added to the view's Behaviors collection, and the PopupService ShowPopup [or ShowPopupAsync] method is called, the behavior is re-attached even though it was already in the behaviors collection.

Expected Behavior

The behavior is only attached once, even if ShowPopup is called.

Steps To Reproduce

  1. Open the Issue.PlatformBehaviorPopupService solution and run the application
  2. Notice the Debug 'Output' window and see the 'attached' events
  3. Click the 'Click me!' button
  4. Monitor the Debug 'Output' window and notice that a new 'attached' event logged each time the button is clicked

Link to public reproduction project repository

https://github.com/bengavin/maui-issue-repros/tree/main/Issue.PlatformBehaviorPopupService

Environment

- .NET MAUI CommunityToolkit: 9
- OS: Windows
- .NET MAUI: 8.0.40

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/viewsIssue/Discussion/PR that has to do with ViewsbugSomething isn't workingunverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions