Net4x.Xamarin.Forms.Platform.GTK
5.0.777
dotnet add package Net4x.Xamarin.Forms.Platform.GTK --version 5.0.777
NuGet\Install-Package Net4x.Xamarin.Forms.Platform.GTK -Version 5.0.777
<PackageReference Include="Net4x.Xamarin.Forms.Platform.GTK" Version="5.0.777" />
<PackageVersion Include="Net4x.Xamarin.Forms.Platform.GTK" Version="5.0.777" />
<PackageReference Include="Net4x.Xamarin.Forms.Platform.GTK" />
paket add Net4x.Xamarin.Forms.Platform.GTK --version 5.0.777
#r "nuget: Net4x.Xamarin.Forms.Platform.GTK, 5.0.777"
#:package Net4x.Xamarin.Forms.Platform.GTK@5.0.777
#addin nuget:?package=Net4x.Xamarin.Forms.Platform.GTK&version=5.0.777
#tool nuget:?package=Net4x.Xamarin.Forms.Platform.GTK&version=5.0.777
Net4x.Xamarin.Forms.Platform.GTK
The GTK3 backend for Xamarin.Forms — renderers that map the Forms visual tree onto native GTK widgets, built on GtkSharp 3.
dotnet add package Net4x.Xamarin.Forms.Platform.GTK
This is the package a GTK desktop app references; it pulls in Net4x.Xamarin.Forms.Core.
Getting started
using Gtk;
using Xamarin.Forms;
using Xamarin.Forms.Platform.GTK;
[STAThread]
static void Main(string[] args)
{
GtkThemes.Init();
Application.Init();
Forms.Init();
var window = new FormsWindow();
window.LoadApplication(new App());
window.SetApplicationTitle("My App");
window.SetApplicationIcon("icon.png");
window.Show();
Application.Run();
}
Forms.Init() populates the renderer registry by scanning for [assembly: ExportRenderer],
ExportCell, ExportImageSourceHandler, ExportFont and ExportEffect attributes; pass extra
assemblies to Forms.Init(IEnumerable<Assembly>) when your renderers live outside the app
assembly.
Native prerequisites
GTK 3 must be installed on the machine running the app — libgtk-3-0 on Linux, the
GTK3 runtime on Windows, gtk+3 via Homebrew on macOS.
GtkSharp binds these libraries at runtime; a missing GTK3 shows up as a DllNotFoundException
on the first widget touch.
WebView additionally needs WebKit2GTK 4.1 — libwebkit2gtk-4.1-0 on Debian/Ubuntu,
webkit2gtk4.1 on Fedora. This one is optional: the backend loads it lazily and, when it is
absent, a WebView renders a "WebView unavailable" placeholder instead of throwing, so the rest
of the application is unaffected.
Threading
GTK is not thread-safe. Everything that touches a widget must run on the thread that called
Forms.Init() — the thread running the GTK main loop. Use Device.BeginInvokeOnMainThread from
anywhere else.
Optional features
Nothing is behind an MSBuild switch any more. Every renderer is always compiled in; the two that depend on something outside a base GTK3 install degrade at runtime instead of at build time, so there is no property to set and no need to rebuild this backend from source:
| Renderer | Needs | Without it |
|---|---|---|
OpenGLView (Gtk.GLArea) |
An OpenGL-capable GTK build — GTK 3.16+ plus a usable GL/EGL driver | GTK stores a GError on the area and paints its own GL error placeholder inside the view's bounds. Nothing throws, and the application stays up. |
WebView (WebKit2GTK) |
libwebkit2gtk-4.1.so.0 |
The renderer shows a placeholder (see Native prerequisites). |
The former EnableGtkOpenGL / EnableGtkWebView properties are gone, along with the OpenTK
dependency OpenGLView used to carry: it now runs on Gtk.GLArea, which is part of GTK itself.
Maps
Xamarin.Forms.Maps is supported on GTK, in a separate package:
dotnet add package Net4x.Xamarin.Forms.Maps.GTK
It draws its own Web-Mercator slippy map with Cairo over OpenStreetMap-compatible raster tiles, so
it needs no API key and no native dependency beyond GTK 3 itself. MapType, MoveToRegion,
VisibleRegion, pan/zoom, Pins and MapElements (Polyline/Polygon/Circle) are implemented,
and Geocoder is backed by Nominatim. Call Xamarin.Forms.Maps.GTK.FormsMaps.Init() after
Forms.Init(). See that package's README for its known limitations (notably IsShowingUser, which
needs an application-supplied position provider because GTK has no location service) and for how to
point it at your own tile server before shipping.
Dependencies
Net4x.Xamarin.Forms.Core and GtkSharp 3.24.24.95.
About this fork
Maintenance fork of the 5.0.0 branch of xamarin/Xamarin.Forms,
published under the Net4x. package prefix. Upstream Xamarin.Forms reached end of support on
May 1, 2024 and was succeeded by .NET MAUI; note that
.NET MAUI has no GTK backend, which is why this one is still maintained here.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- GtkSharp4 (>= 4.22.4.26269)
- Net4x.JavaScriptCoreSharp (>= 4.22.4.26229)
- Net4x.WebkitGtkSharp (>= 4.22.4.26229)
- Net4x.Xamarin.Forms.Core (>= 5.0.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Net4x.Xamarin.Forms.Platform.GTK:
| Package | Downloads |
|---|---|
|
Net4x.Xamarin.Forms.Wpf
The WPF API (System.Windows) implemented over Xamarin.Forms and rendered by its GTK 4 backend: WPF code and XAML run on Linux, macOS and Windows. |
|
|
Net4x.Xamarin.Forms.Maps.GTK
GTK4 map renderer for Xamarin.Forms.Maps, drawn with Cairo over OpenStreetMap-compatible tiles. |
GitHub repositories
This package is not used by any popular GitHub repositories.