MAUI: How to close Communitytoolkit.Maui.Views PopUp page from Content View page

Aleena George 30 Reputation points
2024-01-18T07:02:44.1533333+00:00

I am using the .NET Community toolkit for the Popup page. The opening and closing are working fine for the popup page from the Content page. But I am unable to close the popup page from the Content View page.

I used the Close(); to close the popup page from the Content View page, but I got an error.

Below is the error:

Severity Code Description Project File Line Suppression State Error CS0103 The name 'Close' does not exist in the current context

I have tried different solutions to fix this issue, but they didn't help. Can you please provide me with a solution to resolve this issue?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,814 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 46,981 Reputation points Microsoft Vendor
    2024-01-19T02:47:38.0766667+00:00

    Hello,

    I used the Close(); to close the popup page from the Content View page, but I got an error.

    The error says that Close was called on the wrong object. It needs to be called directly on the Popup. See

    In order to close a Popup a developer must call Close or CloseAsync on the Popup itself. This is typically performed by responding to a button press from a user.

    Quated from Closing a Popup.

    Tested following the official documentation, displaying Popup and closing in the ContentView works as expected.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Nick Kovalsky 0 Reputation points
    2025-01-14T13:45:13.9433333+00:00

    Basically to use messaging. Send message to the subscribed popup so it will close itself upon receiving it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.