📜 ⬆️ ⬇️

Release of cross-platform XAML UI-framework AvaloniaUI 0.5

Version 0.5 of the cross platform XAML UI framework AvaloniaUI (formerly called Perspex) was released. The framework is made according to the same principles as WPF / UWP, that is, it uses XAML, bindings, and template controls. Currently, this is the only way to make a UI on a real XAML that will work on Windows, OS X and Linux (there is also experimental support for iOS and Android).


CPDV


Catalog of embedded controls (gif 3MB)


You can start working with the framework by downloading the add-on for Visual Studio 2017 and creating a project from a template. It is also worth getting acquainted with the documentation on the wiki .


In this release: .NET Core support, transition to GTK3 for * nix-systems, support for output via Linux fbdev, system extensions, many bugs fixed.


.NET Core


.NET Core is supported as a target for the build (to support the previewer in Visual Studio, you still need to add net461 to TargetFrameworks) and it works on all three desktop platforms. The transition to netstandard1.1 for non- netstandard1.1 -specific libraries and to netstandard1.3 for Win32, GTK3 and Skia backends was also made. Patterns for dotnet new take here .


GTK3 on * nix-platforms


We no longer use GTK # bindings, which require the assembly of native binaries for each platform and are tied to Mono. Instead, interaction with GTK occurs directly via P / Invoke, which made it possible to make the backend compatible with netstandard1.3 . As a bonus on * nix-systems, smooth scrolling has started. If you need support for GTK3-free distributions, you can still switch to the old GTK2 backend.


On OS X you need to install GTK3 through brew install gtk+3 . In the future, this dependency on OSX will be eliminated, since MonoMac was able to be started on top of netstandard2.0


Mobile Platform Improvements


We are no longer trying to emulate the presence of desktop windows where they really are not. Therefore, the use of the Window class is no longer available on mobile platforms. Instead, AvaloniaView native classes for each platform are AvaloniaView with the Content property, in which the XAML controls should be placed. For convenience, AvaloniaActivity for Android and AvaloniaWindow ( UIWindow with built-in controller) for iOS are also provided. Thus, initialization now looks like this:


 public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) { AppBuilder.Configure<App>() .UseiOS() .UseSkia().SetupWithoutStarting(); Window = new AvaloniaWindow() {Content = new YOUR_CONTROL_HERE(){DataContext = ...}}; Window.MakeKeyAndVisible(); return true; } 

 public class MainActivity : AvaloniaActivity { protected override void OnCreate(Bundle savedInstanceState) { if (Avalonia.Application.Current == null) { AppBuilder.Configure(new App()) .UseAndroid() .SetupWithoutStarting(); } Content = YOUR_CONTROL_HERE(){DataContext = ...}; base.OnCreate(savedInstanceState); } } 

Linux fbdev


Added initial support for output via fbdev and input via libevdev2. This will allow further use of the framework on embedded Linux devices without an X server.


Embedding in WPF / Winforms / GTK2


Now the controls native to these platforms are supplied, which can display the AvaloniaUI controls. Arranged by analogy with mobile platforms.


Extensibility system


Improved auto-detection of platforms with a system of priorities. So far it works only on full .NET. Also included are tools for auto-registration of various kinds of dependencies for third-party libraries. See pull request with description .


^ Operator in binders


Previously, the system tried to automatically subscribe to all IObservable and Task that I saw in the property chain. This led to problems when trying to bind to the properties of classes that implement IObservable. To avoid ambiguity, the ^ operator was introduced. You can use it like this:


 <!-- Bind to the values produced by Content.Observable --> <TextBlock Text="{Binding Content.Observable^}"/> <!-- Bind to the Name property on the values produced by Content.Observable --> <TextBlock Text="{Binding Content.Observable^.Name}"/> 

The operator supports extensibility, you need to implement IStreamPlugin


3rd-party libraries


Since the previous release, they have been ported and work to some extent:



The libraries have not yet been updated to support the latest version, because the release has been published on nuget only the day before yesterday.


Many bugs fixed


Closed 133 issue / PR on github. Not all of them were mistakes. Full list can be found here .


We always welcome counterparts. If you think you can help or you just have a question, knock on our gitter chat .


')

Source: https://habr.com/ru/post/328684/


All Articles