Convert Figma logo to code with AI

mono logoxwt

A cross-platform UI toolkit for creating desktop applications with .NET and Mono

1,364
239
1,364
160

Top Related Projects

27,472

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology

7,228

WPF is a .NET Core UI framework for building Windows desktop applications.

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.

3,778

Cross platform GUI framework for desktop and mobile applications in .NET

22,629

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.

A curated list of awesome Xamarin.Forms libraries and resources

Quick Overview

Xwt (X-platform Widget Toolkit) is a cross-platform UI toolkit for creating desktop applications with .NET. It provides a set of widgets and controls that can be used to build native-looking applications on multiple platforms, including Windows, macOS, and Linux, using a single codebase.

Pros

  • Cross-platform compatibility, allowing developers to create applications for multiple operating systems with a single codebase
  • Native look and feel on each supported platform, enhancing user experience
  • Extensive set of widgets and controls for building rich user interfaces
  • Integration with existing .NET technologies and frameworks

Cons

  • Limited community support compared to more popular UI frameworks
  • Documentation could be more comprehensive and up-to-date
  • Fewer third-party extensions and components available
  • May have performance limitations compared to platform-specific frameworks

Code Examples

  1. Creating a simple window with a button:
using Xwt;

class MainWindow : Window
{
    public MainWindow()
    {
        Title = "Hello Xwt";
        Width = 300;
        Height = 200;

        var button = new Button("Click me!");
        button.Clicked += (sender, e) => MessageDialog.ShowMessage("Button clicked!");

        Content = button;
    }
}

class Program
{
    static void Main()
    {
        Application.Initialize();
        var mainWindow = new MainWindow();
        mainWindow.Show();
        Application.Run();
    }
}
  1. Creating a layout with multiple widgets:
using Xwt;

class LayoutExample : Window
{
    public LayoutExample()
    {
        Title = "Layout Example";
        Width = 300;
        Height = 200;

        var vbox = new VBox();
        vbox.PackStart(new Label("Enter your name:"));
        vbox.PackStart(new TextEntry());
        vbox.PackStart(new Button("Submit"));

        Content = vbox;
    }
}
  1. Handling events:
using Xwt;

class EventExample : Window
{
    public EventExample()
    {
        Title = "Event Example";
        Width = 300;
        Height = 200;

        var button = new Button("Click me!");
        button.Clicked += OnButtonClicked;

        Content = button;
    }

    private void OnButtonClicked(object sender, EventArgs e)
    {
        MessageDialog.ShowMessage("Button was clicked!");
    }
}

Getting Started

To get started with Xwt, follow these steps:

  1. Install the Xwt NuGet package in your .NET project:

    dotnet add package Xwt
    
  2. Create a new class that inherits from Xwt.Window:

    using Xwt;
    
    public class MainWindow : Window
    {
        public MainWindow()
        {
            Title = "My Xwt App";
            Width = 400;
            Height = 300;
    
            // Add your UI components here
        }
    }
    
  3. In your Program.cs, initialize the application and show the main window:

    using Xwt;
    
    class Program
    {
        static void Main()
        {
            Application.Initialize();
            var mainWindow = new MainWindow();
            mainWindow.Show();
            Application.Run();
        }
    }
    
  4. Build and run your application to see the Xwt window in action.

Competitor Comparisons

27,472

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology

Pros of Avalonia

  • More modern and actively developed, with frequent updates and a larger community
  • Supports cross-platform development for desktop and mobile applications
  • Utilizes XAML for UI design, familiar to WPF developers

Cons of Avalonia

  • Steeper learning curve for developers new to XAML-based frameworks
  • Less mature than Xwt, which may lead to more frequent breaking changes

Code Comparison

Avalonia:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Button Content="Click me!" />
</Window>

Xwt:

using Xwt;

var window = new Window();
var button = new Button("Click me!");
window.Content = button;
window.Show();

Summary

Avalonia is a more modern and feature-rich framework compared to Xwt, offering cross-platform development and XAML-based UI design. However, it may have a steeper learning curve and be less stable due to its ongoing development. Xwt, while older, provides a simpler API and may be more suitable for developers looking for a lightweight, stable solution. The choice between the two depends on project requirements, target platforms, and developer expertise.

7,228

WPF is a .NET Core UI framework for building Windows desktop applications.

Pros of WPF

  • Extensive UI controls and rich styling capabilities
  • Deep integration with Windows platform features
  • Large community and extensive documentation

Cons of WPF

  • Limited cross-platform support (Windows-only)
  • Steeper learning curve due to XAML complexity
  • Heavier resource usage compared to lightweight alternatives

Code Comparison

WPF (XAML):

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Button Content="Click me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
</Window>

Xwt (C#):

using Xwt;

public class MainWindow : Window
{
    public MainWindow()
    {
        Title = "MainWindow";
        Width = 800;
        Height = 450;
        Content = new Button { Label = "Click me" };
    }
}

The code comparison shows that WPF uses XAML for UI definition, while Xwt uses C# code. WPF's XAML approach offers more declarative and designer-friendly UI creation, whereas Xwt's code-based approach may be more familiar to developers accustomed to traditional programming paradigms.

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.

Pros of Xamarin.Forms

  • More extensive platform support, including iOS, Android, and UWP
  • Larger community and ecosystem with more resources and third-party libraries
  • Native UI rendering for better performance and platform-specific look and feel

Cons of Xamarin.Forms

  • Steeper learning curve, especially for developers new to mobile development
  • Larger app size due to inclusion of runtime libraries
  • Potential performance overhead compared to native development

Code Comparison

Xamarin.Forms:

public class MainPage : ContentPage
{
    public MainPage()
    {
        Content = new StackLayout
        {
            Children = {
                new Label { Text = "Welcome to Xamarin.Forms!" }
            }
        };
    }
}

Xwt:

public class MainWindow : Window
{
    public MainWindow()
    {
        Title = "Xwt Application";
        Width = 300;
        Height = 200;
        Content = new Label { Text = "Welcome to Xwt!" };
    }
}

Both frameworks use C# for creating user interfaces, but Xamarin.Forms focuses on cross-platform mobile development, while Xwt is geared towards desktop applications with a more lightweight approach. Xamarin.Forms offers a richer set of controls and platform-specific features, whereas Xwt provides a simpler API for creating cross-platform desktop applications with a native look and feel.

3,778

Cross platform GUI framework for desktop and mobile applications in .NET

Pros of Eto

  • More active development and frequent updates
  • Broader platform support, including mobile platforms
  • Larger community and more third-party controls

Cons of Eto

  • Steeper learning curve for beginners
  • Less integrated with Mono ecosystem
  • Slightly more complex API in some areas

Code Comparison

Xwt example:

using Xwt;

public class MainWindow : Window
{
    public MainWindow()
    {
        Title = "Hello Xwt";
        Content = new Label("Welcome to Xwt!");
    }
}

Eto example:

using Eto.Forms;
using Eto.Drawing;

public class MainForm : Form
{
    public MainForm()
    {
        Title = "Hello Eto";
        Content = new Label { Text = "Welcome to Eto!" };
    }
}

Both frameworks aim to provide cross-platform GUI development for .NET, but they have different approaches and target audiences. Xwt is more tightly integrated with the Mono ecosystem and offers a simpler API, making it easier for beginners. Eto, on the other hand, provides broader platform support and a more extensive set of controls, but with a slightly steeper learning curve.

The code comparison shows that both frameworks have similar syntax for creating basic windows and controls, with minor differences in naming conventions and structure. Eto's approach is more object-oriented, while Xwt's is more procedural.

22,629

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.

Pros of MAUI

  • More comprehensive framework with native UI controls for multiple platforms
  • Stronger backing from Microsoft and larger community support
  • Integrated with .NET 6+ ecosystem for modern development

Cons of MAUI

  • Steeper learning curve due to complexity and broader scope
  • Potentially larger app size and resource usage
  • Limited support for older .NET versions

Code Comparison

MAUI:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp.MainPage">
    <Button Text="Click me!" Clicked="OnButtonClicked" />
</ContentPage>

Xwt:

using Xwt;

var button = new Button("Click me!");
button.Clicked += (sender, e) => Console.WriteLine("Button clicked!");
Window.Content = button;

Key Differences

  • MAUI uses XAML for UI definition, while Xwt uses C# code
  • MAUI targets multiple platforms natively, Xwt uses abstraction layer
  • MAUI has more built-in controls and features for modern app development
  • Xwt is lighter and simpler, suitable for cross-platform desktop apps
  • MAUI has better integration with latest .NET features and tooling

A curated list of awesome Xamarin.Forms libraries and resources

Pros of awesome-xamarin-forms

  • Comprehensive collection of Xamarin.Forms resources and libraries
  • Regularly updated with community contributions
  • Covers a wide range of topics including UI controls, animations, and best practices

Cons of awesome-xamarin-forms

  • Not a standalone framework or toolkit like Xwt
  • Lacks direct code implementation examples
  • May require additional research to integrate listed resources

Code Comparison

While a direct code comparison isn't applicable due to the nature of the repositories, here's a brief example of how they might be used:

awesome-xamarin-forms (resource usage):

// Using a library listed in awesome-xamarin-forms
using Rg.Plugins.Popup;
await Navigation.PushPopupAsync(new MyPopupPage());

Xwt (direct implementation):

using Xwt;
var dialog = new Dialog();
dialog.Buttons.Add(Command.Ok);
dialog.Run();

Summary

awesome-xamarin-forms serves as a curated list of resources for Xamarin.Forms development, while Xwt is a cross-platform UI toolkit. The former provides a wealth of information and third-party libraries, while the latter offers direct implementation of UI elements. Developers should choose based on their specific needs: a resource guide or a standalone toolkit.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

This document is an introduction to XWT, a cross-platform UI toolkit for creating desktop applications.

If you have any question about XWT or do you want to contribute a discussion group for XWT is available here:

http://groups.google.com/group/xwt-list

Introduction

Xwt is a new .NET framework for creating desktop applications that run on multiple platforms from the same codebase. Xwt works by exposing one unified API across all environments that is mapped to a set of native controls on each platform.

This means that Xwt tends to focus on providing controls that will work across all platforms. However, that doesn't mean that the functionality available is a common denominator of all platforms. If a specific feature or widget is not available in the native framework of a platform, it will be emulated or implemented as a set of native widgets.

Xwt can be used as a standalone framework to power the entire application or it can be embedded into an existing host. This allows developers to develop their "shell" using native components (for example a Ribbon on Windows, toolbars on Linux) and use Xwt for specific bits of the application, like dialog boxes or cross platform surfaces.

Xwt works by creating an engine at runtime that will map to the underlying platform. These are the engines that are supported on each platform:

  • Windows: WPF engine, Gtk engine (using Gtk#)
  • MacOS X: Cocoa engine (using Xamarin.Mac) and Gtk engine (using Gtk#)
  • Linux: Gtk engine (using Gtk#)

This means for example that you can write code for Xwt on Windows that can be hosted on an existing WPF application (like Visual Studio) or an existing Gtk# application (like MonoDevelop). Or on Mac, you can host Xwt on an existing Cocoa/Xamarin.Mac application or you can host it in our own MonoDevelop IDE.

Getting Started

Open the Xwt.sln with MonoDevelop (or VisualStudio on Windows) and build the solution. You should end up with the libraries that you can use in your project and a couple of sample applications.

Using Xwt in your app

Based on your platform and the backend that you want to use, you need to pick the libraries that you want to use in your project.

  • Windows+WPF: Xwt.dll + Xwt.WPF.dll (requires WPF)
  • Windows+Gtk: Xwt.dll + Xwt.Gtk.dll (requires Gtk#)
  • Linux+Gtk: Xwt.dll + Xwt.Gtk.dll (requires Gtk#)
  • Mac+Gtk: Xwt.dll + Xwt.Gtk.dll (requires Gtk#)
  • Mac+Cocoa: Xwt.dll + Xwt.XamMac.dll (requires Xamarin.Mac.dll)

Hello World

To write your first application, create an empty .NET project in your favorite language in MonoDevelop or Visual Studio and reference the Xwt.dll library. This is the only library that you need to reference at compile time.

This is the simplest Xwt program you can write:

using System;
using Xwt;

class XwtDemo
{
    [STAThread]
    static void Main()
    {
        Application.Initialize(ToolkitType.Gtk);
        var mainWindow = new Window()
        {
            Title = "Xwt Demo Application",
            Width = 500,
            Height = 400
        };
        mainWindow.Show();
        Application.Run();
        mainWindow.Dispose();
    }
}

You use the Application.Initialize() method to get the backend initialized. In this example we are using the Gtk backend. If you want to use another backend, just change the parameter provided to the Initialize() method. Also make sure the appropiate backend DLL is available in the application directory.

Then we create an instance of the Window class, this class exposes two interesting properties, MainMenu which can be used to set the Window's main menu and "Content" which is of type "Widget" and allows you to add some content to the window.

Finally, the Application.Run method is called to get the UI events processing going.

Widget Class Hierarchy

You will be using widgets to create the contents for your application. Xwt.Widget is the abstract base class from which all the other components are created.

Some Widgets can contain other widgets, these are container widgets, and in Xwt those are Canvas, Paned, HBox, VBox and Table. The first two implement a box layout system, while the last one implements a Table layout that allows widgets to be attached to different anchor-points in a grid.

The layout system uses an auto-sizing system similar to what is availble in Gtk and HTML allowing the user interface to grow or shrink based on the contents of the childrens on it.

  • XwtComponent
    • Menu
    • MenuItem
    • Widget
      • Box (Container)
        • HBox (Container)
        • VBox (Container)
      • Button
        • MenuButton
        • ToggleButton
      • Calendar
      • Canvas (Container)
      • Checkbox
      • ComboBox
      • Frame
      • ImageView
      • Label
      • ListView
      • NoteBook
      • Paned (Container)
        • HPaned (Container)
        • VPaned (Container)
      • ProgressBar
      • ScrollView
      • Separator
        • VSeparator
        • HSeparator
      • Table (Container)
      • TextEntry
      • TreeView
    • WindowFrame
      • Window
        • Dialog

For example, the following attaches various labels and data entries to a Table:

var table = new Table();
table.Attach(new Label ("One:"), 0, 1, 0, 1);
table.Attach(new TextEntry (), 1, 2, 0, 1);
table.Attach(new Label ("Two:"), 0, 1, 1, 2);
table.Attach(new TextEntry (), 1, 2, 1, 2);
table.Attach(new Label ("Three:"), 0, 1, 2, 3);
table.Attach(new TextEntry (), 1, 2, 2, 3);

The Application Class

The Application class is a static class that provides services to run your application.

Initialization

The Application.Initialize API will instruct Xwt to initialize its binding to the native toolkit. You can pass an optional parameter to this method that specifies the full type name to load as the backend.

For example, you can force the initialization of the backend to be specifically Gtk+ or specifically Xamarin.Mac based on MacOS. This is currently done like this:

Application.Initialize("Xwt.GtkBackend.GtkEngine, Xwt.Gtk, Version=1.0.0.0");

or:

Application.Initialize("Xwt.Mac.MacEngine, Xwt.XamMac, Version=1.0.0.0");

As you saw from the Hello World sample, toplevel windows are created by creating an instance of the "Xwt.Window" class. This class exposes a couple of properties that you can use to spice it up. The MainMenu property is used to control the contents of the application menus while the "Content" property is used to hold a Widget.

Timers

The Application.TimeoutInvoke method takes a timespan and a Func action method and invokes that method in the main user interface loop.

If the provided function returns true, then the timer is restarted, otherwise the timer ends.

Background Threads

It is very common to perform tasks in the background and for those tasks in the background to later update the user interface. The Xwt API is not thread safe, which means that calls to the Xwt API must only be done from the main user interface thread.

This is a trait from the underlying toolkits used by Xwt.

If you want a background thread to run some code on the main loop, you use the Application.Invoke (Action action) method. The provided "action" method is guaranteed to run on the main loop.