Export (0) Print
Expand All

TextElement.Background Property

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

Namespace: System.Windows.Documents
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public Brush Background { get; set; }
/** @property */
public Brush get_Background ()

/** @property */
public void set_Background (Brush value)

public function get Background () : Brush

public function set Background (value : Brush)

For XAML information, see the Brush type.

Property Value

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

For a table of swatches that show the available pre-defined brush colors, see Brushes.

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft