Can Dotnetcore Be Built on Windows and Run on Linux
Develop Cross-Platform Desktop GUI Apps on Linux with .Net Core
Building reactive graphical user interfaces on Ubuntu with XAML
With the initial release of .Cyberspace Core, nosotros can now build cantankerous-platform .Cyberspace applications using not only Windows, just also macOS, Ubuntu, and other Linux distros. Every bit a full-stack developer who is pretty excited well-nigh the evolution of the .Cyberspace ecosystem, I use a laptop with Ubuntu and Windows in dual boot, and with .NET Core SDK installed on both operating systems. However, nearly of the evolution time I adopt using Ubuntu KDE. On the one hand, the control-line interface in Linux makes a wide variety of problems way easier to solve, including package management, network configuration, and orchestration of Docker containers. On the other paw, using the same environment on your product and development servers likewise offers some benefits.
Notwithstanding, no cantankerous-platform desktop GUI exists in .Internet Core out of the box. Such awesome desktop frameworks as WPF and UWP currently support Windows only, even after WPF was ported to .NET Core. To overcome this issue, Microsoft has recently announced the new Multiplatform App UI, planning to target general availability in November of 2021. However, according to the MAUI page on GitHub, Linux devices won't receive official support from Microsoft. Surely, 1 could apply a framework based on spider web technologies in order to develop a desktop app, but this tin can atomic number 82 to users lament well-nigh loftier RAM and CPU usage. In this state of affairs, AvaloniaUI comes to the rescue!
What is AvaloniaUI? 🔥
AvaloniaUI is an open up-source, free, and feature-rich .Net Core framework, allowing us to build cross-platform apps of any complexity, on any operating system, including Ubuntu, macOS, and Windows.
The framework uses a XAML dialect, which should feel familiar to folks coming from WPF, UWP, or Xamarin Forms worlds. XAML is a markup language that allows describing app UI declaratively, using a concise XML-like syntax. Similarly to WPF and UWP, Avalonia XAML supports the MVVM blueprint and data bindings.
The main difference is, however, in the XAML compilation engine. The XAML markup in AvaloniaUI is type-checked at compile-fourth dimension, making typos and other markup bugs much easier to observe and fix. Worth noting, that AvaloniaUI supports debugging XAML right in the debugger of your favorite IDE. AvaloniaUI uses the XamlX compiler internally in order to enable these crawly features.
Additionally, AvaloniaUI allows using regular C# lawmaking for edifice user interfaces, and this may seem similar to the technique used in Flutter. Binding from code is supported also, and a specific syntax exists, which allows attaching the bindings to the specified properties in the initializers of C# objects. Worth noting, that IObservablesouth from reactive extensions are showtime-course citizens in AvaloniaUI.
The styling system in AvaloniaUI is heavily inspired past CSS and can be thought of equally a mix of XAML templates and CSS selectors. From my personal experience, combining these two powerful techniques for building user interfaces is a really absurd thought, which profoundly simplifies the procedure of styling a circuitous awarding. With a CSS-like selector, you can hands select the required control, and the setters declared in XAML allow using brushes from resource dictionaries. Such resource dictionaries can be changed dynamically at runtime, making theming AvaloniaUI applications incredibly easy.
Another cool feature that distinguishes AvaloniaUI from practiced old technologies like WPF is intelligent information templates. Data templates in AvaloniaUI have a DataType holding, and the template for the data can be called at runtime based on the blazon of the leap object. The bound object, on its plough, is usually a view model built with ReactiveUI. In Avalonia applications, ReactiveUI is used as the MVVM framework by default.
What is ReactiveUI? 💫
ReactiveUI should feel familiar to folks coming from WPF, UWP, and Xamarin Forms worlds. Information technology is an avant-garde, composable, reactive MVVM framework for all .NET platforms, with nearly 1.five 1000000 downloads on NuGet. ReactiveUI copes gracefully as your application scales, allowing you to avoid overcomplicating things by using the full power of reactive extensions.
A typical view model made with ReactiveUI may look similar the one below. Such code can be placed into a .Cyberspace Standard library, and become easily portable and testable.
ReactiveUI allows observing property changes via the WhenAnyValue extension method. Computed properties are implemented via the ObservableAsPropertyHelper course, or with the [ObservableAsProperty] attribute, the ReactiveCommand class is the default implementation for the ICommand interface. Such commands are unremarkably jump to buttons, and so the buttons stay disabled until the WhenAnyValue condition is satisfied. The sample XAML markup for the SearchViewModel is shown below.
Additionally, ReactiveUI supports view model activation and routing. ReactiveUI routing consists of an IScreen, a bunch of IRoutableViewModelsouth, and a platform-specific RoutedViewHost command. AvaloniaUI provides its own implementation of aRoutedViewHost control in Avalonia.ReactiveUI support package.
The ReactiveUI ecosystem includes such helper projects, as Pharmacist, DynamicData, Sextant, and others. These tools can give you lot superpower in building rich and reactive user interfaces. The ReactiveUI.Validation parcel contains validation helpers and the implementation for the INotifyDataErrorInfo interface.
Developing AvaloniaUI Apps on Linux
Using the engineering stack described in a higher place, we can easily build a .NET Cadre GUI application on Linux, using JetBrains Rider as our IDE. There are helper packages such as Live.Avalonia that can simplify and speed up the GUI evolution process by adding the hot reload characteristic to our Avalonia graphical interfaces.
Visual Studio Code IDE from Microsoft can too be used for development.
In order to get started with building cross-platform .Cyberspace Cadre GUI apps using AvaloniaUI and ReactiveUI on Linux, install the templates from GitHub, and follow the tutorial on AvaloniaUI website. Another option is to follow notwithstanding some other tutorial, which provides detailed instructions about how to ready upwards ReactiveUI routing in an Avalonia app.
Source: https://medium.datadriveninvestor.com/develop-cross-platform-net-core-desktop-apps-on-linux-with-xaml-bf3dbba9afa0
Post a Comment for "Can Dotnetcore Be Built on Windows and Run on Linux"