AVLoop 1.6.1

dotnet add package AVLoop --version 1.6.1                
NuGet\Install-Package AVLoop -Version 1.6.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AVLoop" Version="1.6.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AVLoop --version 1.6.1                
#r "nuget: AVLoop, 1.6.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AVLoop as a Cake Addin
#addin nuget:?package=AVLoop&version=1.6.1

// Install AVLoop as a Cake Tool
#tool nuget:?package=AVLoop&version=1.6.1                

AVLoop

A little bit of infractructure required to support Avalonia windows in F# interactive, courtesy of the discussion in this issue.

Run the following script code before creating Avalonia windows.

#r "nuget: AVLoop"

open FSharp.Compiler.Interactive
open AVLoop

let install(theme) =
        fsi.EventLoop <- {new IEventLoop with 
                                member x.Run() = 
                                    createApp(theme, [||])
                                    false //dummy
                                member x.Invoke(f) = disp f
                                member x.ScheduleRestart() = () //dummy
                        }

install(Default,Dark) //wait till initialization message before submitting more code

Run the above snippent interactively first. Wait till you see a message "avalonia initialized" and then proceed to submit other code.

If you run this script along with window creation code in the same submit then that will not work. It seems the F# interactive main loop thread needs to be free to 'Run' the event loop (which actually initializes Avalonia).

Window example

Here is an example of a simple window

open Avalonia
let win1 = Controls.Window()
win1.Width <- 300
win1.Height <- 300
let btn1 = Controls.Button()
btn1.Width <- 100
btn1.Height <- 50
btn1.Content <- "Click me"
btn1.Click |> Observable.subscribe (fun _ -> btn1.Content <- "Clicked!")
win1.Content <- btn1
win1.Show()

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.1 68 7/24/2024
1.5.0 182 9/23/2023
1.4.1 302 2/9/2023
1.4.0 542 1/15/2022
1.3.0 305 1/15/2022
1.1.9 287 1/13/2022

Rev to Avalonia 11