New to Telerik UI for WPFStart a free 30-day trial

Represents a customizable text block that highlights specific portions of its text based on predefined criteria. This class extends the TextBlock control, introducing properties to specify which text to highlight and how to style the highlighted text. It includes features such as case sensitivity, different highlight modes (first match, last match, all matches), and customizable foreground and background colors for the highlighted text. The RadHighlightTextBlock class supports theming through the IThemable interface, allowing it to adapt its style based on the current application theme. The highlighted text is refreshed dynamically when the underlying text or highlight properties change. Additionally, it integrates with the automation framework, enabling accessibility features.

Definition

Namespace:Telerik.Windows.Controls

Assembly:Telerik.Windows.Controls.dll

Syntax:

C#
[TelerikToolboxCategory("Common")]
public class RadHighlightTextBlock : TextBlock

Inheritance: objectRadHighlightTextBlock

Constructors

Initializes a new instance of the RadHighlightTextBlock class.

C#
public RadHighlightTextBlock()

Fields

HighlightBackgroundProperty

DependencyProperty

Identifies the HighlightBackground dependency property.

C#
public static readonly DependencyProperty HighlightBackgroundProperty

HighlightForegroundProperty

DependencyProperty

Identifies the HighlightForeground dependency property.

C#
public static readonly DependencyProperty HighlightForegroundProperty

HighlightModeProperty

DependencyProperty

Identifies the HighlightMode dependency property.

C#
public static readonly DependencyProperty HighlightModeProperty

HighlightTextProperty

DependencyProperty

Identifies the HighlightText dependency property.

C#
public static readonly DependencyProperty HighlightTextProperty

IsCaseSensitiveProperty

DependencyProperty

Identifies the IsCaseSensitive dependency property.

C#
public static readonly DependencyProperty IsCaseSensitiveProperty

Properties

Gets or sets the background of the highlighted text.

C#
public Brush HighlightBackground { get; set; }

Gets or sets the foreground of the highlighted text.

C#
public Brush HighlightForeground { get; set; }

Gets or sets the highlight mode.

C#
public HighlightMode HighlightMode { get; set; }

Gets or sets the portion of the Text which should be highlighted.

C#
public string HighlightText { get; set; }

Gets or sets a boolean value indicating whether the Text will be searched for matches in a case sensitive manner.

C#
public bool IsCaseSensitive { get; set; }

Methods

Returns the list of HighlightTextInfo objects indicating the parts of the text that need to be highlighted.

C#
protected virtual IEnumerable<HighlightTextInfo> GetHighlightInfos()
Returns:

IEnumerable<HighlightTextInfo>

Applies the styling to the TextRange instance created from the HighlightTextInfo.

C#
protected virtual void HighlightTextRange(HighlightTextInfo info)
Parameters:infoHighlightTextInfo

Creates a RadHighlightTextBlockAutomationPeer.

C#
protected override AutomationPeer OnCreateAutomationPeer()
Returns:

AutomationPeer

Raises the event. This method is invoked whenever is set to true internally.

C#
protected override void OnInitialized(EventArgs e)
Parameters:eEventArgs

The RoutedEventArgs that contains the event data.

Resets the theme.

C#
public void ResetTheme()

Sets the default style key for StyleManager based on the current theme.

C#
protected virtual void SetDefaultStyleKey()