Table of Contents

Class ContentControl

Namespace
DocWright.Dom.ContentControls
Assembly
DocWright.Dom.dll

A typed view over a structured document tag — the API side of the content controls the DOM has preserved since Phase 1.

How this relates to RawXml. The raw w:sdtPr stays the source of truth and is still exactly what the DOCX writer emits. Reading a typed property parses it; setting one splices the corresponding element or attribute back into it. Two things follow, and both are the point of the design: a control nobody touched round-trips byte for byte because the writer never stopped emitting the original bytes, and a w:sdtPr child DocWright does not model survives because it was never removed from the string in the first place.

A refused edit changes nothing. Where the preserved markup cannot be understood with certainty — an undeclared prefix, a construct the fragment scanner does not accept — a setter throws ContentControlEditException and leaves both the island and this view untouched. Phase 15 established that rule for text boxes: a half-applied rewrite leaves two representations disagreeing, and unlike a refusal, that is invisible.

public sealed class ContentControl
Inheritance
ContentControl
Inherited Members

Properties

Alias

Gets or sets the friendly name (w:alias), or null.

AllowsInsertAndDelete

Gets whether a repeating section allows the user to add and remove items (the inverse of w15:doNotAllowInsertDeleteSection). True for every other kind, since the restriction does not apply.

BuildingBlockCategory

Gets the category a building-block control draws from (w:docPartCategory), or null.

BuildingBlockGallery

Gets the gallery a building-block control draws from (w:docPartGallery), or null.

CheckedSymbol

Gets the character a checked box displays (w14:checkedState/@w14:val), as a hex code point, or null.

CheckedSymbolFont

Gets the font a checked box displays its symbol in (w14:checkedState/@w14:font), or null.

ComboBoxLastValue

Gets the last value a combo box was given (w:comboBox/@w:lastValue), or null.

DataBinding

Gets the control's custom XML binding (w:dataBinding), or null when it has none.

DateCalendar

Gets the calendar the date is displayed in (w:date/w:calendar), or null.

DateFormat

Gets the date picker's display format (w:date/w:dateFormat), or null.

DateLanguageId

Gets the language the date is formatted for (w:date/w:lid), or null.

DateStoreMappedDataAs

Gets how the date is written into a bound custom XML node (w:date/w:storeMappedDataAs), or null. Word writes text, date or dateTime.

FullDate

Gets or sets the stored date of a date picker (w:date/@w:fullDate), or null.

Word stores it in the XML-schema dateTime form. Setting it writes the same form so the value round-trips through Word unchanged; it does not rewrite the control's displayed text, which SetValue(string) does.

Id

Gets or sets the unique id (w:id), or null.

IsBlockLevel

Gets a value indicating whether this control wraps block-level content.

IsChecked

Gets or sets whether a check box is checked (w14:checkbox/w14:checked).

Setting it updates the stored state only. Word also paints the check box as a symbol run inside w:sdtContent; SetValue(string) updates both, and is what a caller filling in a form should use.

IsMultiLine

Gets or sets whether a plain-text control accepts line breaks (w:text/@w:multiLine). Reading it on a control of another kind reports false.

IsTemporary

Gets or sets whether the control removes itself once its content is edited (w:temporary).

Kind

Gets the control's kind, determined by the type-specific child of w:sdtPr. A control with no such child reports Unspecified, which Word treats as rich text.

ListItems

Gets the entries of a drop-down list or combo box, in document order. Empty for every other kind.

Lock

Gets or sets the raw ST_Lock token (w:lock), or null. Word writes sdtContentLocked, sdtLocked, contentLocked or unlocked.

This is a description of the control, not an enforced restriction — see DocumentProtection.

Node

Gets the DOM node this view wraps: an SdtBlock or an SdtInline.

PlaceholderDocPart

Gets the name of the glossary-document entry supplying the placeholder text (w:placeholder/w:docPart), or null.

Properties

Gets the underlying properties, including the preserved w:sdtPr.

RepeatingSectionTitle

Gets the title shown on a repeating section's insert control (w15:sectionTitle), or null.

ShowingPlaceholder

Gets or sets whether the control is currently showing its placeholder text (w:showingPlcHdr). Word clears this the moment a user types into the control.

Tag

Gets or sets the tag (w:tag), or null.

UncheckedSymbol

Gets the character an unchecked box displays (w14:uncheckedState/@w14:val), as a hex code point, or null.

UncheckedSymbolFont

Gets the font an unchecked box displays its symbol in (w14:uncheckedState/@w14:font), or null.

Methods

AddRepeatingItem(ContentControl?)

Appends a copy of an existing repeating-section item.

GetRepeatingItems()

Returns the items of a repeating section, in document order — the w15:repeatingSectionItem controls directly inside it. Empty for every other kind.

GetValue()

Returns the control's value as text.

MoveRepeatingItem(ContentControl, int)

Moves a repeating-section item to a new position among its siblings.

RemoveRepeatingItem(ContentControl)

Removes an item from a repeating section.

SetDate(DateTimeOffset, CultureInfo?)

Sets a date picker's value from a date rather than from text, formatting the displayed text with the control's own w:dateFormat.

SetListItems(IReadOnlyList<ContentControlListItem>)

Replaces the entries of a drop-down list or combo box.

SetValue(string)

Sets the control's value, updating both the displayed content and any stored representation the kind keeps.