Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TextEffect.Foreground Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

public Brush Foreground { get; set; }

Property Value

Type: System.Windows.Media.Brush

The brush used to apply to the TextEffect.

Identifier field

ForegroundProperty

Metadata properties set to true

None

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.
ColorAnimation colorAnimation =
    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.
SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Black);
solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);

// Create a new TextEffect object. Set the foreground to the color-animated brush.
TextEffect textEffect = new TextEffect();
textEffect.Foreground = solidColorBrush;

// Apply the TextEffect to the entire range of characters.
textEffect.PositionStart = 0;
textEffect.PositionCount = int.MaxValue;

// Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
Run flickerRun = new Run("Text that flickers...");
flickerRun.TextEffects = new TextEffectCollection();
flickerRun.TextEffects.Add(textEffect);

MyFlowDocument.Blocks.Add(new Paragraph(flickerRun));

.NET Framework
Available since 3.0
Return to top
Show:
© 2018 Microsoft