Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.86 KB

wpf-SelectionTextBrush-property-for-non-adorner-selection.md

File metadata and controls

45 lines (33 loc) · 1.86 KB

Add SelectionTextBrush public property to TextBox/PasswordBox non-adorner selection

Scope

Major

Version Introduced

4.8

Source Analyzer Status

NotPlanned

Change Description

In WPF applications using non-adorner based text selection for TextBox and PasswordBox, developers may now set the newly added SelectionTextBrush property in order to alter the rendering of the selected text. By default, this color changes with SystemColors.HighlightTextBrushKey. If non-adorner based text selection is not enabled, this property does nothing.

  • Quirked
  • Build-time break

Recommended Action

Once non-adorner based text selection is enabled, you can use the xref:System.Windows.Controls.PasswordBox.SelectionTextBrush?displayProperty=nameWithType and TextBox.SelectionTextBrush property to change the appearance of the selected text. This can be achieved using XAML:

        <TextBox SelectionBrush="Red" SelectionTextBrush="White"  SelectionOpacity="0.5"
                Foreground="Blue" CaretBrush="Blue">
            This is some text.
        </TextBox>

Affected APIs

  • F:System.Windows.Controls.Primitives.TextBoxBase.SelectionTextBrushProperty
  • P:System.Windows.Controls.Primitives.TextBoxBase.SelectionTextBrush
  • System.Windows.Controls.TextBox
  • System.Windows.Controls.PasswordBox

Category

WPF