TextEffect.Foreground Property


Gets or sets the Brush to apply to the content of the TextEffect.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

Public Property Foreground As Brush

Property Value

Type: System.Windows.Media.Brush

The brush used to apply to the TextEffect.

Identifier field


Metadata properties set to true


The following code example shows how to create an animatable Brush and set it as the Foreground property value.

' Create and configure a simple color animation sequence.  Timespan is in 1000ns ticks.
Dim colorAnimation As New ColorAnimation(Colors.Maroon, Colors.White, New Duration(New TimeSpan(1000000)))
colorAnimation.AutoReverse = True
colorAnimation.RepeatBehavior = RepeatBehavior.Forever

' Create a new brush and apply the color animation.
Dim solidColorBrush As New SolidColorBrush(Colors.Black)
solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation)

' Create a new TextEffect object. Set the foreground to the color-animated brush.
Dim textEffect As New TextEffect()
textEffect.Foreground = solidColorBrush

' Apply the TextEffect to the entire range of characters.
textEffect.PositionStart = 0
textEffect.PositionCount = Integer.MaxValue

' Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
Dim flickerRun As New Run("Text that flickers...")
flickerRun.TextEffects = New TextEffectCollection()

MyFlowDocument.Blocks.Add(New Paragraph(flickerRun))

.NET Framework
Available since 3.0
Return to top