menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class Background - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Class Background

    Represents the background effects.

    Inheritance
    System.Object
    OwnerHolder
    XDLSSerializableBase
    Background
    Implements
    IXDLSSerializable
    Inherited Members
    OwnerHolder.Document
    OwnerHolder.m_doc
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    XDLSSerializableBase.CloneImpl()
    XDLSSerializableBase.IXDLSSerializable.ReadXmlAttributes(IXDLSAttributeReader)
    XDLSSerializableBase.IXDLSSerializable.ReadXmlContent(IXDLSContentReader)
    XDLSSerializableBase.IXDLSSerializable.RestoreReference(String, Int32)
    XDLSSerializableBase.IXDLSSerializable.WriteXmlAttributes(IXDLSAttributeWriter)
    XDLSSerializableBase.IXDLSSerializable.WriteXmlContent(IXDLSContentWriter)
    XDLSSerializableBase.IXDLSSerializable.XDLSHolder
    XDLSSerializableBase.RestoreReference(String, Int32)
    XDLSSerializableBase.XDLSHolder
    Namespace: Syncfusion.DocIO.DLS
    Assembly: Syncfusion.DocIO.Base.dll
    Syntax
    public class Background : XDLSSerializableBase, IXDLSSerializable

    Properties

    Color

    Gets or sets the background color of the document.

    Declaration
    public Color Color { get; set; }
    Property Value
    Type Description
    System.Drawing.Color

    The System.Drawing.Color specifies the background color for this document.

    Examples
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Load an existing Word document into WordDocument instance
        WordDocument document = new WordDocument("Sample.docx");
        //Set the background type of the document
        document.Background.Type = BackgroundType.Color;
        //Set the background color of the document
        document.Background.Color = Color.AliceBlue;
        //Save the document in the given name and format
        document.Save("Document.docx", FormatType.Docx);
        //Release the resources occupied by WordDocument instance
        document.Close(); 
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Load an existing Word document into WordDocument instance
        Dim document As New WordDocument("Sample.docx")
        'Set the background type of the document
        document.Background.Type = BackgroundType.Color
        'Set the background color of the document
        document.Background.Color = Color.AliceBlue
        'Save the document in the given name and format
        document.Save("Document.docx", FormatType.Docx)
        'Release the resources occupied by WordDocument instance
        document.Close()
    End Sub

    Gradient

    Gets or sets the background gradient.

    Declaration
    public BackgroundGradient Gradient { get; set; }
    Property Value
    Type Description
    BackgroundGradient

    The BackgroundGradient object that specifies the gradient effect.

    See Also
    BackgroundGradient

    Picture

    Gets or sets the background picture.

    Declaration
    public Image Picture { get; set; }
    Property Value
    Type Description
    System.Drawing.Image

    The System.Drawing.Image that represents the background for the document.

    Examples

    The following code example demonstrates how to set the background for the document.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Create an instance of WordDocument class 
        WordDocument document = new WordDocument();
        //Set the background type of the document
        document.Background.Type = BackgroundType.Picture;
        //Set the background image of the document
        document.Background.Picture = Image.FromFile("Image.png");
        //Add one section with one paragraph to the document
        document.EnsureMinimal();
        //Add the text range to the last paragraph of the section
        document.LastParagraph.AppendText("Hello World!");
        //Save the document in the given name and format
        document.Save("Sample.docx", FormatType.Docx);
        //Release the resources occupied by WordDocument instance
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Create an instance of WordDocument class 
        Dim document As New WordDocument()
        'Set the background type of the document
        document.Background.Type = BackgroundType.Picture
        'Set the background image of the document
        document.Background.Picture = Image.FromFile("Image.png")
        'Add one section with one paragraph to the document
        document.EnsureMinimal()
        'Add the text range to the last paragraph of the section
        document.LastParagraph.AppendText("Hello World!")
        'Save the document in the given name and format
        document.Save("Sample.docx", FormatType.Docx)
        'Release the resources occupied by WordDocument instance
        document.Close()
    End Sub

    Type

    Gets or sets the type of background effect.

    Declaration
    public BackgroundType Type { get; set; }
    Property Value
    Type Description
    BackgroundType

    The BackgroundType member that specifies the type of background.

    Methods

    InitXDLSHolder()

    Registers child objects in XDSL holder.

    Declaration
    protected override void InitXDLSHolder()
    Overrides
    XDLSSerializableBase.InitXDLSHolder()

    ReadXmlAttributes(IXDLSAttributeReader)

    Reads object data from xml attributes.

    Declaration
    protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
    Parameters
    Type Name Description
    IXDLSAttributeReader reader

    The IXDLSAttributeReader object.

    Overrides
    XDLSSerializableBase.ReadXmlAttributes(IXDLSAttributeReader)

    ReadXmlContent(IXDLSContentReader)

    Reads object data from xml attributes.

    Declaration
    protected override bool ReadXmlContent(IXDLSContentReader reader)
    Parameters
    Type Name Description
    IXDLSContentReader reader

    The IXDLSContentReader object.

    Returns
    Type Description
    System.Boolean

    The value indicating the presence of xml content.

    Overrides
    XDLSSerializableBase.ReadXmlContent(IXDLSContentReader)

    WriteXmlAttributes(IXDLSAttributeWriter)

    Writes object data as xml attributes.

    Declaration
    protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
    Parameters
    Type Name Description
    IXDLSAttributeWriter writer

    The IXDLSAttributeWriter object.

    Overrides
    XDLSSerializableBase.WriteXmlAttributes(IXDLSAttributeWriter)

    WriteXmlContent(IXDLSContentWriter)

    Writes object data as inside xml element.

    Declaration
    protected override void WriteXmlContent(IXDLSContentWriter writer)
    Parameters
    Type Name Description
    IXDLSContentWriter writer

    The IXDLSContentWriter object.

    Overrides
    XDLSSerializableBase.WriteXmlContent(IXDLSContentWriter)

    Implements

    IXDLSSerializable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved