FlowDocument.Background Property

Definition

Gets or sets the Brush used to fill the background of content area.

C#
public System.Windows.Media.Brush Background { get; set; }

Property Value

The brush used to fill the background of the content area, or null to not use a background brush. The default is null.

Examples

The following example shows how to set the Background attribute of a FlowDocument element.

XAML
<FlowDocumentReader>
  <FlowDocument 
    Background="IndianRed"
    Foreground="NavajoWhite"
  >
    <Paragraph>
      This FlowDocument will have a background color of Indian red, with the text
      colored Navajo white.  Any Forground or Background settings on this paragraph
      would override the top-level settings for the FlowDocument.
    </Paragraph>
  </FlowDocument>
</FlowDocumentReader>

The following example shows how to set the Background property programmatically.

C#
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));
flowDoc.Background = Brushes.IndianRed;
flowDoc.Foreground = Brushes.NavajoWhite;

Remarks

For a table of swatches that show the available predefined brush colors, see Brushes.

Dependency Property Information

Item Value
Identifier field BackgroundProperty
Metadata properties set to true AffectsRender

Applies to

Produto Versões
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10