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執行) 。

文字和文字樣式的預設面板取決於使用中主題和其他設定。 使用預設系統設定或使用者喜好設定的主題和各種樣式和行為,都是 RichTextBlock 前景色彩和其他文字特性的有效執行時間外觀來源。 您可以藉由變更屬性值,或將不同的樣式套用至特定的 RichTextBlock 實例,來變更這些預設值。 您可以覆寫 App.xaml 中名為 DefaultTextForegroundThemeBrush 的資源,以變更所有預設文字的前景值。

適用於

另請參閱