Skip to content

Feature(1002889): NET Native embedding support for SfPopup Android IOS #358

Merged
PaulAndersonS merged 2 commits into
syncfusion:mainfrom
SowntharyaJ:main
May 19, 2026
Merged

Feature(1002889): NET Native embedding support for SfPopup Android IOS #358
PaulAndersonS merged 2 commits into
syncfusion:mainfrom
SowntharyaJ:main

Conversation

@SowntharyaJ
Copy link
Copy Markdown
Contributor

 Feature Description
.NET Native embedding support for SfPopup Android & iOS.

AI Usage:
Code Studio used in this PR: Yes

Primary use
Generate new code
Bug fix

Outcome: Neutral

Require one label on every PR: (single-select, easy to report): cs:used

PR
Core: https://gitea.syncfusion.com/essential-studio/maui-core/pulls/3587

Task
Task 1002889: .NET Native embedding support for SfPopup Android

Purpose / Benefits:
Enable SfPopup in native Android Activities that host MAUI views (no MAUI Window).

Solution description
Overlay host (Android): AddToOverlay enhanced to support Native embedding: Native embedding path( Window is null): use WindowOverlayHelper.HostActivity and HostMauiContext to create 

 
Native embedding path: no MAUI Window, use host Activity and IMauiContext set by the embedding app.

Else // Window is
null
{
   
    var activity =
WindowOverlayHelper.HostActivity;
    density = WindowOverlayHelper.density;
    rootView =
WindowOverlayHelper.PlatformRootView;
    if (rootView != null && activity !=
null)
    {
        overlayStack = CreateStack(activity);
        windowManager = activity.WindowManager;
        if (overlayStack != null)
        {
            overlayStack.LayoutChange +=
OnOverlayStackLayoutChange;
            if (this.WindowManagerLayoutParams
== null)
            {
               
this.GetWindowManagerLayoutParams();
            }
 
            // Prefer an existing native view
if handler already realized.
            if
(WindowOverlayHelper.HostMauiContext != null)
            {
                overlayContent =
childView.ToPlatform(WindowOverlayHelper.HostMauiContext);
                return true;
            }
        }
    }
}

WindowOverlayStack and resolve WindowManager. Multi-window: PositionOverlayContent refreshes WindowManager from the active PlatformWindow
before Add/Update.

In WindowOverlayHelper.cs: Returned RootView based on the CurrentActivityparamer passed via SfPopup instance.

Created Internal Static methods to get the Current activity and MauiContexts 

**Sets the host Activity for embedding scenarios where there is no MAUI Window.**
internal static void **SetHostActivity**(Activity activity)
{
    HostActivity = activity;
}

Sets the host IMauiContext for embedding scenarios where there is no MAUI Window.
internal static void SetHostMauiContext(IMauiContext context)
{
    HostMauiContext = context;
}
 

And implemented code by referring previous code in AddToOverlay.
 
In WindowOverlay.Android - CreateStack method - Returned overlay based on the MauiContext passed via Popup instance.

 
**Fallback to HostMauiContext for native embedding (no MAUI Window).**

if (windowOverlayStack == null && WindowOverlayHelper.HostMauiContext
!= null)
{
    windowOverlayStack = overlayStackView !=
null ?
(WindowOverlayStack?)overlayStackView.ToPlatform(WindowOverlayHelper.HostMauiContext)
: null;
}


In SfPopup.Android.cs

In WirePlatformSpecificEvents method, the mainpage is null, the OnViewTreeObserverGlobalLayout event wiring is missed, I have added wired by using HostActivity & HostMauiContext

internal void WirePlatformSpecificEvents()
{
 .........
 else // mainPage is null
 {
     // Native Embedding: MainPage is null. Use the platform root or decor view to wire GlobalLayout
     // WindowOverlayHelper is initialized via SfPopup(Activity, IMauiContext) constructor in embedding scenarios
     var nativeView = WindowOverlayHelper.PlatformRootView as PlatformView
                       ?? WindowOverlayHelper.decorViewContent as PlatformView;

     if (nativeView != null && nativeView.ViewTreeObserver != null)
     {
         nativeView.ViewTreeObserver.GlobalLayout += this.OnViewTreeObserverGlobalLayout;
     }
 }
 }

Sample usage: new SfPopup(this, mauiContext) // Created SfPopup instance to get the CurrentActivity and MauiContext.

Areas affected and ensured
Popup lifecycle: open/close, animations, event wiring.
Keyboard Resize, Orientation, WindowManager Flags, PopupSize, LoadTime & Runtime cases.

Behavioral Changes
No

Does it have any known
issues?
No known issues.

Test Cases
NativeEmbedding_Android_Testcases.docx

MR CheckList

  • Have you ensured in iOS, Android, WinUI, and macOS(if supported)? Android, iOS
  • If there is any API change, did you get approval from PLO through JIRA Tasks? NA
  • Is there any existing behavior change of other features due to this code change? NA
  • Have you enabled the necessary settings in your project, if you have created any new project? No
  • Have you suppressed any warning or binding errors? No
  • Did you add a sample in the testbed for your feature? Yes
  • Did you record this case in the unit test or UI test? No
  • Whether the new APIs and its comments are added as per standard? NA
  • Does it contain code that reflects any internal framework API? No
  • Have you included license for your control(If it is stable)? NA
  • Did you ensure the cases mentioned in this link? NA
  • Did you test the memory leak with your feature? No
  • Did you ensure the performance? Check this link to know more about performance optimization and how to automate? NA
  • Does it need localization? If so, did you ensure the cases mentioned in this link? NA
  • Does it follow the design system guidelines and support light and dark themes? No
  • Did you ensure the new control / feature met accessibility requirements? NA
  • Did you ensure RTL? Yes
  • If you added any interaction related code, have you used touch and gesture APIs from core project? NA
  • If you use a third-party package, did you get approval to use it? If not, please get approval before merging. NA

@PaulAndersonS PaulAndersonS added this to the v1.0.10 milestone May 19, 2026
@PaulAndersonS PaulAndersonS merged commit 6f19c19 into syncfusion:main May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SfPopup (and all controls that internally use a SfPopup) does not support MAUI embedding

3 participants