共用方式為


TextElement.Background 屬性

定義

取得或設定用來填滿內容區域背景的筆刷。

public:
 property System::Windows::Media::Brush ^ Background { System::Windows::Media::Brush ^ get(); void set(System::Windows::Media::Brush ^ value); };
public System.Windows.Media.Brush Background { get; set; }
member this.Background : System.Windows.Media.Brush with get, set
Public Property Background As Brush

屬性值

Brush

用來填滿內容區域背景的筆刷,不使用背景筆刷則為 null。 預設為 null

範例

下列範例示範如何使用 做為範例專案來設定 Background 屬性 Paragraph

<FlowDocumentReader>
  <FlowDocument>
    <Paragraph
      Background="Bisque"
      Foreground="DarkGreen"
      Padding="4"
    >
      <Run>
        This text has a foreground color of dark green, and a background color of bisque.
      </Run>
    </Paragraph>
  </FlowDocument>
</FlowDocumentReader>

下圖顯示上述範例的呈現方式。

螢幕擷取畫面:前景為綠色,背景為淡黃色

下列範例示範如何以程式設計方式設定 Background 屬性。

Run run = new Run(
    "This text has a foreground color of dark green, and a background color of bisque.");
Paragraph par = new Paragraph(run);

par.Background = Brushes.Bisque;
par.Foreground = Brushes.DarkGreen;
Dim run As New Run("This text has a foreground color of dark green, and a background color of bisque.")
Dim par As New Paragraph(run)

par.Background = Brushes.Bisque
par.Foreground = Brushes.DarkGreen

備註

如需顯示可用預先定義筆刷色彩的色板表格,請參閱 Brushes

相依性屬性資訊

識別碼欄位 BackgroundProperty
中繼資料屬性設定為 true AffectsRender

適用於

另請參閱