Note: You can check the Avalonia docs for the Button and Button API if you need more information.
For Avalonia.FuncUI's DSL properties you can check Button.fs
Buttons are basic controls for any application you may build, buttons are often used to trigger an action.


You can check the general usage of Avalonia.FuncUI's views and attributes in the following link Views and Attributes
Create a Button
Button.create []
Register Click
Button.create [
Button.onClick(fun _ -> dispatch MyMsg)
Set Click Mode
Button.create [
Button.clickMode ClickMode.Press
// or
Button.create [
Button.clickMode ClickMode.Release
for more information check the Click Mode docs
Set Content
Button.create [ Button.content "My Button" ]
Buttons can have arbitrary content, for example it can be a string as the example above. It also can be another entire control like a StackPanel
let playIcon =
Canvas.create [ ... ]
let textbox =
TextBox.create [ ... ]
let iconAndTextBlock =
StackPanel.create [
StackPanel.orientation Horizontal
StackPanel.spacing 8.0
StackPanel.children [ playIcon; textbox ]
Button.create [
Button.content iconAndTextBlock
Last modified 1yr ago