Native menus were introduced in Avalonia in version 0.9.0, you can check the announcement to see a brief explanation on how to use them in Avalonia Applications.
Currently for Avalonia.FuncUI there is not a DSL and the NativeMenu control is in a weird spot for Avalonia.FuncUI since this control works directly on the main Application/Window object so it's tough to pull a DSL on top of that. But! thankfully you can just use plain F# for the menu as noted in this issue.
Usage
Inside your Program.fs File find the App class and be sure to set the name of your Application
typeMainWindow()as this =(*... code ... *)typeApp()=inherit Application()override this.Initialize()= this.Styles.Load "avares://Avalonia.Themes.Default/DefaultTheme.xaml" this.Styles.Load "avares://Avalonia.Themes.Default/Accents/BaseDark.xaml"// 🚩name visible in native menu this.Name <-"Counter App"override this.OnFrameworkInitializationCompleted()=match this.ApplicationLifetime with|:? IClassicDesktopStyleApplicationLifetime as desktopLifetime -> desktopLifetime.MainWindow <- MainWindow()|_->()
and that is enough to show your native menu. If you want to interact with the contents of your menu (the most likely scenario) you will need to add some subscriptions to hook up with your Elmish program
// 🚩hook menu actions in Elmishlet menuSub (_state:Counter.State)=let sub (dispatch:Counter.Msg ->unit)= incrementItem.Clicked.Add (fun _ -> dispatch Counter.Msg.Increment) decrementItem.Clicked.Add (fun _ -> dispatch Counter.Msg.Decrement)() Cmd.ofSub subElmish.Program.mkSimple (fun()-> Counter.init) Counter.update Counter.view|> Program.withHost this// 🚩 use menu subscription|> Program.withSubscription menuSub|> Program.withConsoleTrace|> Program.run