Vixen
feb85697
csharp
public sealed class Section

A titled part of a page that a screen reader can jump to: a heading, and what it heads.

Read the guide page for this →

Remarks

The landmark half of doc 49 § 7.1's rank 4. GroupBox says these controls answer one question; Form says these fields are sent together; this says this is a part of the page, and here is its name. It is HTML's <section aria-labelledby> with its <h2>, and it is what a settings window made of "Display", "Audio" and "Controls" is built from.

⚠ Two nodes in the tree, deliberately, where GroupBox has one. A screen-reader user moves through a long page in two ways — by landmark and by heading — and a section has to be reachable by both. So the heading is a real Heading node, and the section is a Region named by it through LabelledBy, which is ARIA's own pattern. A group box's legend is not a heading anybody navigates to, so there the name is written on the group and the legend stays a caption; here the relation is what keeps the one string in one place while two nodes read it.

⚠ Unnamed, it is still a region — and an unnamed region is a defect the tree reports rather than hides. ARIA exposes a <section> with no name as a plain generic, so a role that appeared only once a title was set would look correct and make the omission invisible: AccessibilitySnapshot.Unnamed cannot see a landmark that is not there. Kept a region, a titleless section is an unnamed node that gate reports, which is where GroupBox came out for the same reason. An application that wants the landmark without a visible heading sets AccessibleName, which wins over the relation.

⚠ The heading's role does move with Title, and that is the other answer on purpose. The heading part is hidden when there is no title, and a hidden part is still walked by the accessibility tree — display is a picture, not a statement about the tree — so an empty heading would be announced as a heading with no name. No title means no heading; the section it belongs to is what stays put.

What it deliberately is not. It draws no border: it is a part of a page rather than a box on one, and a settings window framing every section would read as a stack of cards. It does not collapse — that is Expander. And there is no heading level: the accessibility model has no aria-level to carry one, so a section inside a section is announced as a heading exactly like its parent's. That is recorded here rather than implied by a smaller font.

⚠ Nest in markup, or add from C#, and both land in Content. A nested tag goes to ContentHost, and so does section.Add<T>() since #1425 — before that it parented on the section itself, beside the heading, as it did for every container in this assembly.

Fields and properties (8)

  • 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
  • public UiElement Heading

    Where the title is drawn, and the heading a screen reader navigates to.

  • public UiElement Content

    Where the section's controls go.

  • protected override UiElement ContentHost
  • public string? Title
  • public static readonly UiPropertyKey TitleProperty

    Identity for Title.

Methods (2)

  • protected override void OnCreated()

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

  • public void ClearTitle()

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

Used by (3)

  • GalleryHelloUi
  • SectionSheetVixen.Ui.Controls.Tests
  • SectionTestsVixen.Ui.Controls.Tests