Skip to main content
net10.0

Project templates for .NET MAUI apps running on Linux with GTK4.

Published
Feb 17, 2026
8mo ago
Total Downloads
593
593

Install

dotnet add package Platform.Maui.Linux.Gtk4.Templates --version 0.1.0-preview.1
ProductVersions
.NET
net10.0

README

Platform.Maui.Linux.Gtk4

A community-driven .NET MAUI backend for Linux, powered by GTK4. Run your .NET MAUI applications natively on Linux desktops with GTK4 rendering via GirCore bindings.

Status: Early / experimental β€” contributions and feedback are welcome!

https://github.com/user-attachments/assets/039f1695-3cd0-4b0b-ad11-dce304d0cdce

Features

  • Native GTK4 rendering β€” MAUI controls map to real GTK4 widgets.
  • Blazor Hybrid support β€” Host Blazor components inside a native GTK window using WebKitGTK.
  • Broad control coverage β€” Label, Button, Entry, Editor, CheckBox, Switch, Slider, ProgressBar, ActivityIndicator, Image, Picker, DatePicker, TimePicker, Stepper, RadioButton, SearchBar, ScrollView, Border, Frame, ImageButton, WebView, CollectionView, GraphicsView, Shapes, and more.
  • Layout support β€” StackLayout, Grid, FlexLayout, AbsoluteLayout via a custom GtkLayoutPanel.
  • Navigation β€” NavigationPage, TabbedPage, and FlyoutPage handlers.
  • Alerts & Dialogs β€” DisplayAlert, DisplayActionSheet, and DisplayPromptAsync via native GTK4 windows.
  • Essentials β€” Clipboard, Preferences, DeviceInfo, AppInfo, Connectivity, and more.
  • Cairo-based graphics β€” GraphicsView draws via the Microsoft.Maui.Graphics Cairo backend.
  • Theming β€” Automatic light/dark theme detection through GtkThemeManager.

Prerequisites

Requirement Version
.NET SDK 10.0+
GTK 4 libraries 4.x (system package)
WebKitGTK (Blazor only) 6.x (system package)

Install GTK4 & WebKitGTK (Debian / Ubuntu)

sudo apt install libgtk-4-dev libwebkitgtk-6.0-dev

Install GTK4 & WebKitGTK (Fedora)

sudo dnf install gtk4-devel webkitgtk6.0-devel

Quick Start

Option 1: Use the template (recommended)

# Install the template
dotnet new install Platform.Maui.Linux.Gtk4.Templates

# Create a new Linux MAUI app
dotnet new maui-linux-gtk4 -n MyApp.Linux
cd MyApp.Linux
dotnet run

Option 2: Add to an existing project manually

Add the NuGet package:

dotnet add package Platform.Maui.Linux.Gtk4 --prerelease
dotnet add package Platform.Maui.Linux.Gtk4.Essentials --prerelease   # optional

Then set up your entry point:

Program.cs

using Platform.Maui.Linux.Gtk4.Platform;
using Microsoft.Maui.Hosting;

public class Program : GtkMauiApplication
{
    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

    public static void Main(string[] args)
    {
        var app = new Program();
        app.Run(args);
    }
}

MauiProgram.cs

using Platform.Maui.Linux.Gtk4.Hosting;
using Microsoft.Maui.Hosting;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp
            .CreateBuilder()
            .UseMauiAppLinuxGtk4<App>();

        return builder.Build();
    }
}

XAML Support

Platform.Maui.Linux.Gtk4 relies on MAUI's normal transitive build assets for XAML. In Linux head projects, *.xaml files are still collected as MauiXaml and compiled by MAUI's XAML build pipeline without extra package-specific overrides.

Resource Item Support

Linux head projects can use MAUI resource item groups for common Resources/* paths:

  • MauiImage from Resources/Images/**
  • MauiFont from Resources/Fonts/**
  • MauiAsset from Resources/Raw/** (with LogicalName defaulting to %(RecursiveDir)%(Filename)%(Extension))
  • MauiIcon from explicit items, or default Resources/AppIcon/appicon.{svg|png|ico}

These are copied into build/publish output so image/file lookups can resolve at runtime. When MauiIcon is present, Linux builds emit hicolor icon-theme files in output and runtime sets the GTK window default icon name from that icon.

Adding Linux to a Multi-Targeted MAUI App

Since there is no official -linux TFM (Target Framework Moniker) from Microsoft, MAUI projects can't conditionally include the Linux backend via TargetFrameworks the way they do for Android/iOS/Windows. Instead, use the "Linux head project" pattern:

MyApp/                              ← Your existing multi-targeted MAUI project
β”œβ”€β”€ MyApp.csproj                       (net10.0-android;net10.0-ios;...)
β”œβ”€β”€ App.cs
β”œβ”€β”€ MainPage.xaml
β”œβ”€β”€ ViewModels/
β”œβ”€β”€ Services/
└── Platforms/
    β”œβ”€β”€ Android/
    β”œβ”€β”€ iOS/
    └── ...

MyApp.Linux/                        ← New Linux-specific project
β”œβ”€β”€ MyApp.Linux.csproj                 (net10.0, references Platform.Maui.Linux.Gtk4)
β”œβ”€β”€ Program.cs                         (GtkMauiApplication entry point)
└── MauiProgram.cs                     (builder.UseMauiAppLinuxGtk4<App>())

Setup

  1. Create the Linux head project next to your MAUI project:
dotnet new maui-linux-gtk4 -n MyApp.Linux
  1. Reference your shared code β€” add a project reference from MyApp.Linux.csproj to your MAUI project (or a shared class library):
<!-- MyApp.Linux.csproj -->
<ItemGroup>
  <ProjectReference Include="../MyApp/MyApp.csproj" />
</ItemGroup>
  1. Run on Linux:
dotnet run --project MyApp.Linux

Why a separate project?

The platform-specific TFMs (net10.0-android, net10.0-ios, etc.) are powered by .NET workloads that Microsoft ships. Creating a custom net10.0-linux TFM would require building and distributing a full .NET workload β€” complex infrastructure that's unnecessary for most use cases.

The separate project approach is the same pattern used by OpenMaui and MauiAvalonia. It works with standard dotnet build/dotnet run, is NuGet-distributable, and keeps your existing MAUI project unchanged.

Building from Source

git clone https://github.com/Redth/Platform.Maui.Linux.Gtk4.git
cd Platform.Maui.Linux.Gtk4
dotnet restore
dotnet build

Run the sample app

# Sample app (includes native controls, Blazor Hybrid, essentials, and more)
dotnet run --project samples/Platform.Maui.Linux.Gtk4.Sample

Project Structure

Platform.Maui.Linux.Gtk4.slnx                          # Solution file
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Platform.Maui.Linux.Gtk4/                       # Core MAUI backend
β”‚   β”‚   β”œβ”€β”€ Handlers/                     # GTK4 handler implementations
β”‚   β”‚   β”œβ”€β”€ Hosting/                      # AppHostBuilderExtensions (UseMauiAppLinuxGtk4)
β”‚   β”‚   └── Platform/                     # GTK application, context, layout, theming
β”‚   β”œβ”€β”€ Platform.Maui.Linux.Gtk4.Essentials/            # MAUI Essentials for Linux (clipboard, etc.)
β”‚   └── Platform.Maui.Linux.Gtk4.BlazorWebView/         # BlazorWebView support via WebKitGTK
β”œβ”€β”€ samples/
β”‚   └── Platform.Maui.Linux.Gtk4.Sample/                # Sample app (controls, Blazor, essentials)
β”œβ”€β”€ templates/                            # dotnet new templates
└── docs/                                 # Documentation

NuGet Packages

Package Purpose
Platform.Maui.Linux.Gtk4 Core GTK4 backend β€” handlers, hosting, platform services
Platform.Maui.Linux.Gtk4.Essentials MAUI Essentials (clipboard, preferences, device info, etc.)
Platform.Maui.Linux.Gtk4.BlazorWebView Blazor Hybrid support via WebKitGTK
Platform.Maui.Linux.Gtk4.Templates dotnet new project templates

Key Dependencies

Package Purpose
GirCore.Gtk-4.0 GObject introspection bindings for GTK4
GirCore.WebKit-6.0 WebKitGTK bindings (Blazor support)
Microsoft.Maui.Controls .NET MAUI framework
Tmds.DBus.Protocol D-Bus client for Linux platform services

License

This project is licensed under the MIT License.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.