Skip to content

Instantly share code, notes, and snippets.

@FoggyFinder
Created May 13, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoggyFinder/8aab4df343b7b2dc1cd2e7ee0c315eb7 to your computer and use it in GitHub Desktop.
Save FoggyFinder/8aab4df343b7b2dc1cd2e7ee0c315eb7 to your computer and use it in GitHub Desktop.
FsharpAvaloniaSample
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
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()
| _ -> ()
base.OnFrameworkInitializationCompleted()
open Avalonia.Logging.Serilog
[<CompiledName "BuildAvaloniaApp">]
let buildAvaloniaApp () =
AppBuilder.Configure<App>().UsePlatformDetect().LogToDebug()
[<STAThread>][<EntryPoint>]
let main argv =
buildAvaloniaApp().StartWithClassicDesktopLifetime(argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment