protected override void OnPreCreate() { base.OnPreCreate(); Application.ClearCurrent(); var type = typeof(Window); // Use reflection to avoid breaking compatibility. ElmSharp.Window.CreateWindow() is has been added since API6. var methodInfo = type.GetMethod("CreateWindow", BindingFlags.NonPublic | BindingFlags.Static); Window window = null; if (methodInfo != null) { window = (Window)methodInfo.Invoke(null, new object[] { "FormsWindow" }); BaseLayout = (ELayout)window.GetType().GetProperty("BaseLayout")?.GetValue(window); BaseCircleSurface = (CircleSurface)window.GetType().GetProperty("BaseCircleSurface")?.GetValue(window); System.Maui.Maui.CircleSurface = BaseCircleSurface; } else // in case of Xamarin Preload { window = PreloadedWindow.GetInstance() ?? new Window("FormsWindow"); if (window is PreloadedWindow precreated) { BaseLayout = precreated.BaseLayout; } } MainWindow = window; }
public static PreloadedWindow GetInstance() { var instance = s_precreated; s_precreated = null; return(instance); }
public PreloadedWindow() : base("FormsWindow-pre") { s_precreated = this; Initialize(); }