PSAvalonia – Open source PowerShell bindings for Avalonia

Avalonia is a WPF-style cross-platform UI library. Today, we are open sourcing a PowerShell module to create UIs using the Avalonia library. The Avalonia bindings that were once part of PowerShell Pro Tools are now open source and up on GitHub and the PowerShell Gallery. You can download the latest version using Install-Module.

Install-Module PSAvalonia

You can contribute on GitHub here.

What can PSAvalonia do?

You can use PSAvalonia to create cross-platform UIs that work in PowerShell Core and PowerShell 7. It has been tested on 6.2 and 7. PSAvalonia does not work in Windows PowerShell at the moment.

For example, you could use the same script on both Linux and Windows.

$Xaml = '<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="avaloniaui.MainWindow" Title="avaloniaui"> <StackPanel> <Button Width="160" Name="button">My Button</Button> <TextBox HorizontalAlignment="Left" Margin="12,12,0,0" Name="txtDemo" VerticalAlignment="Top" Width="500" Height="25" /> </StackPanel> </Window>' $window = ConvertTo-AvaloniaWindow -Xaml $Xaml $Button = Find-AvaloniaControl -Name 'button' -Window $Window $txtDemo = Find-AvaloniaControl -Name 'txtDemo' -Window $Window $Button.add_Click({$txtDemo.Text = "Hello, World from $($PSVersionTable.OS) running PowerShell Core $($PSVersionTable.PSVersion)"}) Show-AvaloniaWindow -Window $Window

Running on Windows

Running on Linux