Прочитать на английском

Поделиться через


TextElement.TextEffects Свойство

Определение

Получает или задает коллекции текстовых эффектов, чтобы применить к содержимому элемента.

public System.Windows.Media.TextEffectCollection TextEffects { get; set; }

Значение свойства

TextEffectCollection

Коллекция текстовых эффектов, применяемых к содержимому в этом элементе. Значением по умолчанию является null (не пустая коллекция).

Примеры

В следующем примере показано, как создать простой текстовый эффект и применить его к тексту Run TextEffects с помощью свойства.

// Create and configure a simple color animation sequence.  Timespan is in 100ns ticks.
ColorAnimation blackToWhite = new ColorAnimation(Colors.White, Colors.Black, new Duration(new TimeSpan(100000)));
blackToWhite.AutoReverse = true;
blackToWhite.RepeatBehavior = RepeatBehavior.Forever;

// Create a new brush and apply the color animation.
SolidColorBrush scb = new SolidColorBrush(Colors.Black);
scb.BeginAnimation(SolidColorBrush.ColorProperty, blackToWhite);

// Create a new TextEffect object; set foreground brush to the previously created brush.
TextEffect tfe = new TextEffect();
tfe.Foreground = scb;
// Range of text to apply effect to (all).
tfe.PositionStart = 0;
tfe.PositionCount = int.MaxValue;

// Create a new text run, and add the previously created text effect to the run's effects collection.
Run flickerRun = new Run("Text that flickers...");
flickerRun.TextEffects = new TextEffectCollection();
flickerRun.TextEffects.Add(tfe);

Комментарии

По умолчанию это свойство имеет значение null и не TextEffectCollection связано с ним. Перед добавлением текстовых эффектов создайте новый TextEffectCollection и назначьте его этому свойству.

Сведения о свойстве зависимостей

Поле идентификатора TextEffectsProperty
Для свойств метаданных задано значение true AffectsRender

Применяется к