Share via


RichTextBlock.Foreground 属性

定义

获取或设置应用于 RichTextBlock 的文本内容的 Brush

public:
 property Brush ^ Foreground { Brush ^ get(); void set(Brush ^ value); };
Brush Foreground();

void Foreground(Brush value);
public Brush Foreground { get; set; }
var brush = richTextBlock.foreground;
richTextBlock.foreground = brush;
Public Property Foreground As Brush
<RichTextBlock Foreground="{StaticResource resourceName}"/>
- or -
<RichTextBlock Foreground="colorString"/>
- or -
<RichTextBlock>
  <RichTextBlock.Foreground>singleBrush</RichTextBlock.Foreground>
</RichTextBlock>

属性值

要应用于文本内容的画笔。 从纯代码的角度来看,默认值为 null 画笔,但对于 UI 中的 TextBlock 元素,默认文本样式将其设置为黑色 ((浅主题) )或深主题) 白色 (。

注解

设置 Foreground 属性以指定要用于 RichTextBlock 中所有文本的默认画笔。 可以通过设置 TextElement.Foreground 属性,替代特定文本元素 (,例如 RichTextBlock 中的 Run) 。

文本和文本样式的默认外观在很大程度上取决于活动主题和其他设置。 使用默认系统设置或用户首选项的主题和各种样式和行为是 RichTextBlock 文本前景色的有效运行时外观以及其他文本特征的来源。 可以通过更改属性值或向特定 RichTextBlock 实例应用不同的样式来更改这些默认值。 可以通过替代 App.xaml 中名为 DefaultTextForegroundThemeBrush 的资源来更改所有默认文本的前景值。

适用于

另请参阅