Skip to content
This repository was archived by the owner on Jun 25, 2023. It is now read-only.

Latest commit

 

History

History
68 lines (57 loc) · 1.67 KB

Button.md

File metadata and controls

68 lines (57 loc) · 1.67 KB

layout: control name: Button group: controls

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.

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
]

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
]