diff --git a/src/Core/src/Platform/Linux/HandlerExtensions.cs b/src/Core/src/Platform/Linux/HandlerExtensions.cs index 0b2dc8127..442b6b900 100644 --- a/src/Core/src/Platform/Linux/HandlerExtensions.cs +++ b/src/Core/src/Platform/Linux/HandlerExtensions.cs @@ -40,6 +40,5 @@ namespace Microsoft.Maui Height = (int)size.Height, Width = (int)size.Width }; - } } \ No newline at end of file diff --git a/src/Core/src/Platform/Linux/MauiWindow.cs b/src/Core/src/Platform/Linux/MauiWindow.cs new file mode 100644 index 000000000..9c335b0ad --- /dev/null +++ b/src/Core/src/Platform/Linux/MauiWindow.cs @@ -0,0 +1,47 @@ +using System; +using Gtk; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Maui.Hosting; +using Microsoft.Maui.LifecycleEvents; + +namespace Microsoft.Maui +{ + public class MauiWindow : Window + where TStartup : IStartup, new() + { + public MauiWindow() : base(WindowType.Toplevel) + { + var startup = new TStartup(); + + var host = startup + .CreateAppHostBuilder() + .ConfigureServices(ConfigureNativeServices) + .ConfigureUsing(startup) + .Build(); + + Services = host.Services; + Application = Services.GetRequiredService(); + + var mauiContext = new MauiContext(Services); + + var activationState = new ActivationState(mauiContext); + var window = Application.CreateWindow(activationState); + window.MauiContext = mauiContext; + + var content = (window.Page as IView) ?? window.Page.View; + + Add(content.ToNative(window.MauiContext)); + Child.ShowAll(); + } + + public new IApplication Application { get; protected set; } = null!; + + public IServiceProvider Services { get; protected set; } = null!; + + // Configure native services like HandlersContext, ImageSourceHandlers etc.. + void ConfigureNativeServices(HostBuilderContext ctx, IServiceCollection services) + { + } + } +} \ No newline at end of file