Vixen
dd8b0a81
csharp
public sealed class GroupBox

A titled box round a set of related controls, announced as one group.

Read the guide page for this →

Remarks

The other half of doc 49 § 7.1's rank 4, and the half that is a container. LabeledContent is the row; this is what a set of rows is put inside. Card and Panel already draw the picture — a bordered box with a heading in it — and are exempt from the accessibility sweep for saying so: they are layout, and announcing them would put a group round every four fields. That is the right decision for a box that happens to have a border and the wrong one for a box whose whole purpose is to say these belong together.

⚠ The role is the reason this type exists, and the border is not. This is HTML's <fieldset> with its <legend>: a screen reader entering it says the legend and then the controls, so somebody who arrives at the third one down is told what question it answers. A Card with a TextBlock in its header draws the same thing and says nothing — those words are read when a reader walks past them and never again, and a keyboard user who tabbed straight into the group never walked past them at all.

⚠ The name is written on the group rather than fetched from the legend by a relation, which is the opposite of what LabeledContent does and for a difference that matters. A row's caption names a control the row does not own, so the join has to be a relation; a legend is part of this control, and a fieldset's own name is computed from it. One string, one copy, and no second node carrying the same words.

⚠ An unnamed group is still a group. Reporting None until somebody sets Label would be a role that moves under a property — nothing could rely on it, and the coverage sweep could not see it either, because it builds one bare instance of every type and reads the answer once. A group with nothing to say is a caller reaching for the wrong container, and Panel is the right one.

What it deliberately is not. It does not collapse: that is Expander, whose header is a button that says what it opens, and a container with both behaviours would offer two ways to hide the same content. It is also not the Form or the Section doc 49 ranks beside it — a form is a submission and a section is a document landmark, and neither of those is a bordered box with a caption. Both are still owed.

Fields and properties (9)

  • protected override string TagName

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

  • protected override bool AcceptsFocus
  • protected override AccessibleRole NativeRole

    The role this kind of element has when nobody says otherwise.

  • protected override string? NativeAccessibleName
  • public UiElement Legend

    Where the caption is drawn.

  • public UiElement Content

    Where the controls go.

  • protected override UiElement ContentHost
  • public string? Label
  • public static readonly UiPropertyKey LabelProperty

    Identity for Label.

Methods (2)

  • protected override void OnCreated()

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

  • public void ClearLabel()

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

Used by (2)

  • GalleryHelloUi
  • GroupBoxTestsVixen.Ui.Controls.Tests