Skip to main content

TextBox

Description​

TextBox extends the WPF TextBox with Fluent placeholder, helper, clear-button, and validation presentation.

TextBox in light mode TextBox in dark mode

Text entered​

TextBox text entered in light mode TextBox text entered in dark mode

Example usage​

<fluence:TextBox PlaceholderText="With helper text" />

Key properties​

PropertyDefaultPurpose
PlaceholderTextEmpty stringText displayed when the field is empty.
HelperTextEmpty stringGuidance shown below the field.
ValidationStateNoneSelects the validation presentation.
ValidationMessageEmpty stringMessage associated with validation state.
ClearButtonEnabledtrueEnables the clear button.

State and behavior​

Focus, text entry, helper text, and validation states change the field presentation. See the accessibility guidance.

Use AutomationProperties.LabeledBy to connect the field to its visible label, and AutomationProperties.HelpText for app guidance. App-supplied help text, bindings, and styles take precedence over the validation HelpText fallback; loading or clearing validation preserves them. Visible validation text and the helper live region continue to represent validation status.

Events​

The inherited TextChanged event reports changes to the text.

Theme resource roles​

TextControlElevationBorderFocusedBrush paints the rounded focus border for TextBox, PasswordBox, and NumberBox. The stock AutoSuggestBox template receives the same focus treatment through its embedded Fluence TextBox, as do the ColorPicker Hex, RGB, HSV, and alpha editors. Editable ComboBox uses the same resources on its field border. Its accent band follows the border's corner radius. TextControlBorderThemeThicknessFocused is 1,1,1,2 in Light and Dark and 2 on every side in High Contrast. Use both resources dynamically in custom templates so an already focused control follows theme and accent changes. Keep content insets independent of the focused stroke thickness to avoid moving the editor.

Platform behavior​

Text input focus​

TextBox, the styled native PasswordBox, NumberBox, editable ComboBox, the embedded TextBox in AutoSuggestBox, and the ColorPicker Hex, RGB, HSV, and alpha editors paint the focus accent inside their rounded border. Light and Dark use a 2-DIP bottom stroke; High Contrast uses a 2-DIP outline on all sides. Changing the painted focus stroke leaves content insets unchanged. The normal TextBox clear-button visibility still follows focus and text. TextBox validation keeps its status color and takes precedence over the accent.

Selected text​

Fluence supplies the selection highlight for TextBox, native PasswordBox, and the editor inside NumberBox. WPF draws the highlight and selected glyphs. Legacy adorner rendering uses a translucent overlay by default. Non-adorner rendering draws the highlight behind the glyphs. Use the native selection appearance on net472. On WPF versions that expose SelectionTextBrush, enable non-adorner selection to set the glyph color. Selected-text behavior

Reference​