Editar

Compartilhar via


FlowDocument.Foreground Property

Definition

Gets or sets the Brush to apply to the text contents of the FlowDocument.

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

Property Value

The brush used to apply to the text contents. The default is Black.

Examples

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

<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 Foreground property programmatically.

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));
flowDoc.Background = Brushes.IndianRed;
flowDoc.Foreground = Brushes.NavajoWhite;
Dim flowDoc As 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 shows the available predefined brush colors, see Brushes.

Any Foreground settings on child elements override this top-level setting.

Dependency Property Information

Item Value
Identifier field ForegroundProperty
Metadata properties set to true AffectsRender, Inherits,

SubPropertiesDoNotAffectRender

Applies to