Skip to content

[BUG] Remove Windows OnLoaded Popup Workaround #1490

Closed

Description

@TheCodeTraveler

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

In PR #1470, we added the below work-arounds for Popup on Windows to fix a .NET MAUI bug affecting Popup.

Once the .NET MAUI team has resolved dotnet/maui#12970, we will remove our work-around.

#if WINDOWS
// TODO: This is a workaround for https://github.com/dotnet/maui/issues/12970. Remove this `#if Windows` block when the issue is closed
void handler(object? sender, EventArgs args)
{
page.GetCurrentPage().Loaded -= handler;
CreateAndShowPopup(page, popup);
}
page.GetCurrentPage().Loaded += handler;
#else
if (page.IsPlatformEnabled)
{
CreateAndShowPopup(page, popup);
}
else
{
void handler(object? sender, EventArgs args)
{
page.Loaded -= handler;
CreateAndShowPopup(page, popup);
}
page.Loaded += handler;
}
#endif

#if WINDOWS
// TODO: This is a workaround for https://github.com/dotnet/maui/issues/12970. Remove this `#if Windows` block when the issue is closed
var taskCompletionSource = new TaskCompletionSource<object?>();
async void handler(object? sender, EventArgs args)
{
page.GetCurrentPage().Loaded -= handler;
try
{
var result = await CreateAndShowPopupAsync(page, popup);
taskCompletionSource.TrySetResult(result);
}
catch (Exception ex)
{
taskCompletionSource.TrySetException(ex);
}
}
page.GetCurrentPage().Loaded += handler;
return taskCompletionSource.Task;
#else
if (page.IsPlatformEnabled)
{
return CreateAndShowPopupAsync(page, popup);
}
else
{
var taskCompletionSource = new TaskCompletionSource<object?>();
async void handler(object? sender, EventArgs args)
{
page.Loaded -= handler;
try
{
var result = await CreateAndShowPopupAsync(page, popup);
taskCompletionSource.TrySetResult(result);
}
catch (Exception ex)
{
taskCompletionSource.TrySetException(ex);
}
}
page.Loaded += handler;
return taskCompletionSource.Task;
}
#endif

Expected Behavior

The .NET MAUI team have an open Issue to address this

Steps To Reproduce

N / A

Link to public reproduction project repository

https://github.com/CommunityToolkit/Maui

Environment

- .NET MAUI CommunityToolkit: v6.1.0
- OS: Windows

Anything else?

Adding the blocked label until .NET MAUI Issue dotnet/maui#12970 is resolved

Activity

  1. locked and limited conversation to collaborators on May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/viewsIssue/Discussion/PR that has to do with ViewsblockedbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions