Bagikan melalui


TextElement.Background Properti

Definisi

Mendapatkan atau mengatur kuas yang digunakan untuk mengisi latar belakang area konten.

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

Nilai Properti

Kuas yang digunakan untuk mengisi latar belakang area konten, atau null untuk tidak menggunakan kuas latar belakang. Defaultnya adalah null.

Contoh

Contoh berikut menunjukkan cara mengatur atribut Background, menggunakan Paragraph sebagai elemen contoh.

<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>

Gambar berikut menunjukkan bagaimana contoh sebelumnya dirender.

Cuplikan layar: Latar depan hijau, latar belakang bisque

Contoh berikut menunjukkan cara mengatur properti Background secara terprogram.

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

Keterangan

Untuk tabel swatch yang menunjukkan warna kuas yang telah ditentukan sebelumnya yang tersedia, lihat Brushes.

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi BackgroundProperty
Properti metadata diatur ke true AffectsRender

Berlaku untuk

Lihat juga