Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

TextElement.Background Property

Definition

Namespace:
System.Windows.Documents
Assembly:
PresentationFramework.dll

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

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

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, using Paragraph as the example element.

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

The following figure shows how the preceding example renders.

πŸ‘ Screenshot: Foreground of green, background bisque

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

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

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

See also


Feedback

Was this page helpful?