Skip to content
Browse documentation

ButtonGroup

Buttons grouped into one control that reports the selection, as uikit:ButtonGroup.

ExampleInteractive
ButtonGroup — Avalonia UIKit
Live demo unavailable
<StackPanel Spacing="8" HorizontalAlignment="Left">
  <uikit:ButtonGroup Classes="outline" Click="OnSelect">
    <Button Content="Day" />
    <Button Classes="selected" Content="Week" />
    <Button Content="Month" />
  </uikit:ButtonGroup>
  <uikit:ButtonGroup Classes="outline small" Multiple="True" Click="OnSelect">
    <Button Classes="selected" Content="Bold" />
    <Button Content="Italic" />
    <Button Content="Underline" />
  </uikit:ButtonGroup>
</StackPanel>

Usage

uikit:ButtonGroup is the Button Group as a control. It is a StackPanel, horizontal by default, of Buttons. Its color, outline, compact and size classes go on every button. A click on a button raises its Click with SelectedIndices, the buttons the selection becomes: the clicked button alone, or with Multiple="True" the selection with the clicked button added or removed. The group does not change the selection itself; the app applies it with each button's selected class. IsEnabled="False" on the group disables its buttons.

The demo has a group for one choice and one with Multiple="True"; each applies the indices its Click reports.