Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
If I have customized the Flyout Header of my Shell (added Shell.FlyoutHeader to my Shell), then when opening a Popup inside a Modal on Windows, I get an exception. It works on Android. It works without the Modal. It works without the flyout header customization.
This seems very similar to an existing issue #2459 , however, I can toggle the error on and off by removing the flyout header from my shell.
Exception: System.Runtime.InteropServices.COMException
Message: : 'No installed components were detected.
'
Stack trace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.DelegateExtensions.DynamicInvokeAbi(Delegate del, Object[] invoke_params)
at ABI.System.Collections.Generic.IListMethods`2.AppendDynamic(IObjectReference obj, T value)
at ABI.System.Collections.Generic.IVectorMethods`1.Append(IObjectReference obj, T value)
at ABI.System.Collections.Generic.IListMethods`1.Add(IObjectReference obj, T item)
at Microsoft.UI.Xaml.Controls.UIElementCollection.Add(UIElement item)
at Microsoft.Maui.Controls.Platform.ViewToHandlerConverter.WrapperControl..ctor(View view)
at Microsoft.Maui.Controls.Platform.ShellHeaderView.UpdateHeader()
at Microsoft.Maui.Controls.Platform.ShellHeaderView.SetElement(Shell shell)
at Microsoft.Maui.Controls.Platform.ShellHeaderView..ctor(Shell element)
at Microsoft.Maui.Controls.Handlers.ShellHandler.MapFlyoutHeader(ShellHandler handler, Shell view)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Handlers.ViewHandler`2.SetVirtualView(IView view)
at Microsoft.Maui.Controls.Handlers.ShellHandler.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler`2.SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at CommunityToolkit.Maui.Core.Handlers.PopupHandler.MapOnOpened(PopupHandler handler, IPopup view, Object result)
at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0.<Add>b__0(IElementHandler h, IElement v, Object o)
at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args)
at Microsoft.Maui.CommandMapper.Invoke(IElementHandler viewHandler, IElement virtualView, String property, Object args)
at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args)
at CommunityToolkit.Maui.Views.PopupExtensions.PlatformShowPopup(Popup popup, IMauiContext mauiContext)
at CommunityToolkit.Maui.Views.PopupExtensions.CreateAndShowPopup[TPopup](Page page, TPopup popup)
at CommunityToolkit.Maui.Views.PopupExtensions.<>c__DisplayClass0_0`1.<ShowPopup>g__handler|0(Object sender, EventArgs args)
at Microsoft.Maui.Controls.VisualElement.SendLoaded(Boolean updateWiring)
at Microsoft.Maui.Controls.VisualElement.HandlePlatformUnloadedLoaded()
at Microsoft.Maui.Controls.VisualElement.UpdatePlatformUnloadedLoadedWiring(Window newWindow, Window oldWindow)
at Microsoft.Maui.Controls.VisualElement.add_Loaded(EventHandler value)
at CommunityToolkit.Maui.Views.PopupExtensions.ShowPopup[TPopup](Page page, TPopup popup)
at MauiApp742.AnotherModalPage.Button_Clicked(Object sender, EventArgs e) in D:\Devel\X\MauiApp742\MauiApp742\AnotherModalPage.xaml.cs:line 14
at Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked()
at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager)
at Microsoft.Maui.Controls.Button.SendClicked()
at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked()
at Microsoft.Maui.Handlers.ButtonHandler.OnClick(Object sender, RoutedEventArgs e)
at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, RoutedEventArgs e)
at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)
Expected Behavior
Popup would open without an Exception. 🤷🏻♂️
Steps To Reproduce
Repro steps:
- Add a new
ContentPagederived page (I used XAML+C#) to the project - Add a
ButtontoMainPagethat usesPushModalAsync()to move to this new page - Add an empty or simple
Popupto the project. - Add a
Buttonto the newContentPagethat usesShowPopup()to show the popup. - On opening the popup, it works.
- Add the following code to your
AppShell.xaml:
<Shell.FlyoutHeader>
<StackLayout Orientation="Vertical" HorizontalOptions="Center" Margin="10,10,10,20">
<Label Text="Some example data"/>
<Label Text="Some more data"/>
</StackLayout>
</Shell.FlyoutHeader>
- Now try to open the popup from the modal, it should throw the exception.
Link to public reproduction project repository
https://github.com/lenardg/maui-communitytoolkit-bugrepro-742
Environment
- .NET MAUI CommunityToolkit: 11.2.0
- OS: Windows 11 24H2 (26100.3775), but tested on multiple OS versions including Windows 10, fails every time
- .NET MAUI: 9.0.50Anything else?
My example uses Locked Shell.FlyoutBehavior for the Shell Flyout, but the bug happens also with the Flyout behavior. I used Locked because in our app that is how it was used, but that does not seem to have any effect on this issue.
Activity
lenardg commentedon Apr 11, 2025
@TheCodeTraveler any idea when Popup V2 will land in the released version? This issue kind of blocks our entire .NET 9 migration (from .NET 8) at the moment. 😅
cat0363 commentedon Apr 16, 2025
I got it to work by modifying the code as follows:
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopUpHandler.windows.cs]
The commented out parts are the code before the modification.
MAUI.App.742.2025-04-16.16-35-22.mp4
I'm looking forward to the release of Popup V2.