Share via


RichTextBlock.Foreground 屬性

定義

取得或設定 Brush ,以套用至 RichTextBlock 的文字內容。

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 的資源,以變更所有預設文字的前景值。

適用於

另請參閱