Vixen
dd8b0a81
csharp
public sealed class SegmentedControl

A row of joined buttons of which exactly one is chosen.

Read the guide page for this →

Remarks

What a view switcher, a mode picker and an alignment control are. The editor draws one out of a bare UiElement and CSS — ToolbarPresenter.cs:212 plus EditorTheme.vcss:289 — so no application could reach it and the version that existed had no keyboard, no exclusivity and no accessible structure.

⚠ The same model as RadioGroup, deliberately, and not a subclass of it. The exclusion, the roving tab index and the wrapping arrows are the same behaviour and the members are not: a radio group's children are radios with a dot and a label beside them, a segmented control's are joined buttons, and a base class shared between them would have to be parameterised on the member type to say anything useful. What it would save is thirty lines; what it would cost is a hierarchy where <RadioButton> inside a <SegmentedControl> type-checks.

Single selection only. Multiple selection is a different control — a strip of ToggleButtons in a Toolbar, which is already reachable — and a mode flag here would make Value mean two things.

Fields and properties (6)

  • protected override string TagName

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

  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • protected override AccessibleRole NativeRole
  • public string? Value
  • public IReadOnlyList<Segment> Segments

    The segments, in order.

  • public static readonly UiPropertyKey ValueProperty

    Identity for Value.

Events (1)

  • public Action<SegmentedControl, string?>? ValueChanged

    Raised when the choice changes.

Methods (4)

  • protected override void OnCreated()

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

  • public Segment AddSegment(string value, string? label = null)

    Adds a segment.

  • protected override void OnChildAdded(UiElement child)

    Called on the parent, once a child of it has been created and initialised.

  • public void ClearValue()

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

Used by (9)

  • ApplicationBarTestsVixen.Ui.Controls.Tests
  • ImageViewBarVixen.Ui.Controls.Advanced
  • ImageViewBarTestsVixen.Ui.Controls.Advanced.Tests
  • LiveCombinatorPairTestsVixen.Ui.Controls.Advanced.Tests
  • ImageViewBarWiringTestsVixen.Editor.Texturing.Tests
  • PaintBrushInspectorVixen.Editor.Texturing
  • PaintToolTestsVixen.Editor.Texturing.Tests
  • ToolbarPresenterVixen.Editor.Ui
  • ToolbarSectionTestsVixen.Editor.Ui.Tests