TextElement.Background Proprietà

Definizione

Ottiene o imposta il pennello usato per riempire lo sfondo dell'area del contenuto.

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

Valore della proprietà

Brush

Pennello utilizzato per riempire lo sfondo dell'area di contenuto, oppure null se non viene utilizzato alcun pennello. Il valore predefinito è null.

Esempio

Nell'esempio seguente viene illustrato come impostare l'attributo Background usando Paragraph come elemento di esempio.

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

Nella figura seguente viene illustrato il rendering dell'esempio precedente.

Schermata: primo piano verde, sfondo terracotta

Nell'esempio seguente viene illustrato come impostare la Background proprietà a livello di codice.

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

Commenti

Per una tabella di campioni che mostrano i colori del pennello predefiniti disponibili, vedere Brushes.

Informazioni proprietà di dipendenza

Campo Identificatore BackgroundProperty
Proprietà dei metadati impostate su true AffectsRender

Si applica a

Vedi anche