FuncUI
GitHub Repository
  • Getting Started
  • View Basics
    • Creating views
    • Lifetime
    • Attributes
    • How to create bindings
  • Components
    • Component basics
    • Component lifetime
    • Hooks
  • Common Questions
  • Controls
    • Button
    • Border
    • Calendar
    • CalendarDatePicker
    • CheckBox
    • DatePicker
    • DockPanel
    • Expander
    • ListBox
    • Menu
    • NativeMenu
    • NumericUpDown
    • ProgressBar
    • RadioButton
    • RepeatButton
    • Slider
    • StackPanel
    • Tabs
    • TextBlock
    • TextBox
    • TimePicker
    • ToggleButton
    • ToggleSwitch
Powered by GitBook
On this page
  1. Controls

Button

Last updated 3 years ago

Note: You can check the Avalonia docs for the and if you need more information.

For Avalonia.FuncUI's DSL properties you can check

Buttons are basic controls for any application you may build, buttons are often used to trigger an action.

Usage

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
]

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
]

for more information check the docs

Button
Button API
Button.fs
Click Mode