Class TextControl
Attached behavior that supports dynamic text highlighting for controls derived from TextBlock or RichTextBox.
Inherited Members
Namespace: BionicCode.Utilities.Net
Assembly: BionicCode.Utilities.Net.Wpf.dll
Syntax
public class TextControl : DependencyObject
Fields
| Improve this Doc View SourceHighlightBackgroundProperty
Attached property to define the background Brush for the highlight text, which is defined by HighlightRange items contained in the HighlightRangesProperty attached property.
Declaration
public static readonly DependencyProperty HighlightBackgroundProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
HighlightForegroundProperty
Attached property to define the foreground Brush for the highlight text, which is defined by HighlightRange items contained in the HighlightRangesProperty attached property.
Declaration
public static readonly DependencyProperty HighlightForegroundProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
HighlightRangesProperty
Attached property to define a HighlightRangeCollection of HighlightRange items. cref="HighlightRangesProperty"/> attached property.
Declaration
public static readonly DependencyProperty HighlightRangesProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
Remarks
This collection implements INotifyCollectionChanged.
IsHighlightingEnabledProperty
Attached property to enable or disable the highlight attached behavior TextControl. cref="HighlightRangesProperty"/> attached property.
Declaration
public static readonly DependencyProperty IsHighlightingEnabledProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
TextProperty
Attached property to serve as alternative text property for the RichTextBox (instead of using Document). Optional property to use with TextBlock (instead of Text). The defined HighlightRange items contained in the attached property HighlightRangesProperty collection will always be applied to Text and the TextProperty values.
Declaration
public static readonly DependencyProperty TextProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
Remarks
In case of the TextProperty being attached to a RichTextBox, the string value will be converted to a FlowDocument and assigned to the Document property.
Methods
| Improve this Doc View SourceGetHighlightBackground(DependencyObject)
Get method of the attached property HighlightBackgroundProperty.
Declaration
public static Brush GetHighlightBackground(DependencyObject attachingElement)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
Returns
| Type | Description |
|---|---|
| Brush | The Brush for the background of the highlight text ranges. |
GetHighlightForeground(DependencyObject)
Get method of the attached property HighlightForegroundProperty.
Declaration
public static Brush GetHighlightForeground(DependencyObject attachingElement)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
Returns
| Type | Description |
|---|---|
| Brush | The Brush for the foreground of the highlight text ranges. |
GetHighlightRanges(DependencyObject)
Get method of the attached property HighlightRangesProperty.
Declaration
public static HighlightRangeCollection GetHighlightRanges(DependencyObject attachingElement)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
Returns
| Type | Description |
|---|---|
| HighlightRangeCollection |
GetIsHighlightingEnabled(DependencyObject)
Get method of the attached property HighlightForegroundProperty.
Declaration
public static bool GetIsHighlightingEnabled(DependencyObject attachingElement)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
GetText(DependencyObject)
Get method of the attached property TextProperty.
Declaration
public static string GetText(DependencyObject attachingElement)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
Returns
| Type | Description |
|---|---|
| String | The current text value. |
SetHighlightBackground(DependencyObject, Brush)
Set method of attached property HighlightBackgroundProperty.
Declaration
public static void SetHighlightBackground(DependencyObject attachingElement, Brush value)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
| Brush | value | The Brush for the background of the highlight text ranges. |
SetHighlightForeground(DependencyObject, Brush)
Set method of attached property HighlightForegroundProperty.
Declaration
public static void SetHighlightForeground(DependencyObject attachingElement, Brush value)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
| Brush | value | The Brush for the foreground of the highlight text ranges. |
SetHighlightRanges(DependencyObject, HighlightRangeCollection)
Set method of attached property HighlightRangesProperty.
Declaration
public static void SetHighlightRanges(DependencyObject attachingElement, HighlightRangeCollection value)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
| HighlightRangeCollection | value |
SetIsHighlightingEnabled(DependencyObject, Boolean)
Set method of attached property IsHighlightingEnabledProperty.
Declaration
public static void SetIsHighlightingEnabled(DependencyObject attachingElement, bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
| Boolean | value |
|
SetText(DependencyObject, String)
Set method of attached property TextProperty.
Declaration
public static void SetText(DependencyObject attachingElement, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| DependencyObject | attachingElement | The attaching TextBlock or RichTextBox. |
| String | value | The text to display. |