FlowDocument.Background 属性

定义

获取或设置要用于填充内容区域背景的 Brush

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

属性值

用于填充内容区域背景的画笔,或 null(不使用背景画笔)。 默认值为 null

示例

以下示例演示如何设置 Background 元素的 FlowDocument 属性。

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>

下面的示例演示如何以编程方式设置 Background 属性。

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

注解

有关显示可用预定义画笔颜色的样本表,请参阅 Brushes

依赖项属性信息

标识符字段 BackgroundProperty
元数据属性设置为 true AffectsRender

适用于

产品 版本
.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