fsharp avalonia add tag
Docs [says](Avaloniaui.net/docs/) that Avalonia lets use any .NET languages. But [currently](https://github.com/AvaloniaUI/avaloniaui.net/issues/115) all sections are about C#: documentation even doesn't contain getting started guide for F#.

Besides all available Avalonia templates for `dotnet new` are only for C#.

Yet one concern is that XAML, probably, doesn't fit well to F#. So I'd also like to see how write application without it.
Top Answer
How to create almost empty F#-Avalonia application:

1. Create console .net core app (Avalonia has support for .net Framework but better option would be .net core nevertheless)

2. Add reference to [Avalonia.Desktop](https://www.nuget.org/packages/Avalonia.Desktop/) package.

3. Write the View. Since it is a very simple sample let's create Window that contains single TextBlock that shows "F# Avalonia app":

open Avalonia.Controls
open Avalonia.Layout

type MainWindow () as self = 
    inherit Window ()
    let txb = TextBlock(Text = "F# Avalonia app", 
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment = VerticalAlignment.Center)
    do self.Content <- txb

4. Add App:

open System
open Avalonia
open Avalonia.Controls.ApplicationLifetimes
open Avalonia.Markup.Xaml.Styling

type App() =
    inherit Application()

    override x.Initialize() =
        x.Styles.AddRange [ 
            new StyleInclude(baseUri=null, Source = Uri("resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"))
            new StyleInclude(baseUri=null, Source = Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"))

    override x.OnFrameworkInitializationCompleted() =
        match x.ApplicationLifetime with
        | :? IClassicDesktopStyleApplicationLifetime as desktop ->
             desktop.MainWindow <- new MainWindow()
        | _ -> ()


5. Create `AppBuilder`:

open Avalonia.Logging.Serilog
[<CompiledName "BuildAvaloniaApp">] 
let buildAvaloniaApp () = 

6. Put it all together:

let main argv =

Now, all we have to do is run our basic sample:


And it takes only 42 (:-)) lines of code. Not that bad!

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.