ironmansoftware / psavalonia

Avalonia bindings for PowerShell

Home Page:https://ironmansoftware.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Asynchronous PSAvalonia

pinuke opened this issue · comments

The current problem with PSAvalonia is the fact that it can't run the App asynchronously. This kind of defeats the purpose of GUI apps in PowerShell.

It may be worth while to write a cmdlet that starts the GUI in a separate PowerShell Runspace, similarly to:
https://stackoverflow.com/questions/34440599/using-dispatcher-invoke-with-a-runspace-in-powershell

In theory, you would be able to use Avalonia's Dispatcher to similarly to how you would do it in WPF

After a bit of investigation, @MaynardMiner's fork inside of a powershell runspace seems to make this feature achievable, however I'm getting a black screen:

image

This is the 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"
    Width="800" Height="450"
    Title="Test">
    <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>