Vixen
02b45cc4
csharp
public sealed class RadioGroup

A set of radios, of which exactly one is chosen.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The exclusion lives here rather than in a shared static, which is the mistake HTML made with name: two forms on one page with a field called colour are one radio group, and nobody finds out until both are on screen. A group is an element, its members are its children, and two groups cannot interfere.

⚠ The arrow keys move the selection, not just the focus, and that is deliberate. It is what every desktop toolkit does and what the ARIA authoring practices specify, and the reason is that a radio group is one stop in the tab order — Tab enters it at whichever radio is chosen and Tab leaves it, so arrowing without selecting would leave the keyboard with no way to choose at all.

Which is also why the tab index roves: only the chosen radio is a stop, so tabbing into a group with a selection lands on the selection rather than at the top of the list.

Fields and properties (5)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus
  • public string? Value
  • public IReadOnlyList<RadioButton> Options

    The radios, in order.

  • public static readonly UiPropertyKey ValueProperty

    Identity for Value.

Events (1)

  • public Action<RadioGroup, string?>? ValueChanged

    Raised when the choice changes.

Methods (3)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • public RadioButton AddOption(string value, string? label = null)

    Adds a choice.

  • public void ClearValue()

    Unsets Value, so it takes its default or its ancestor's value again.

Used by (4)

  • ShellHelloUi
  • ControlVisualTestsVixen.Ui.Controls.Tests
  • SelectionTestsVixen.Ui.Controls.Tests
  • ToggleInteractionTestsVixen.Ui.Controls.Tests