# Background Shading

Learn how easily you can apply background shading to a paragraph using DsWord. Learn more in DsWord docs.

## Content

DsWord allows you to specify the background shading for a paragraph using [BackgroundPatternColor](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Shading.BackgroundPatternColor.html) property of the [Shading](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Shading.html) class which can be accessed using [Shading](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ParagraphFormat.Shading.html) property of the [ParagraphFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ParagraphFormat.html) class.

## Get Shading

To get the shading:

1. Access a paragraph from the paragraph collection using [Paragraphs](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.RangeBase.Paragraphs.html) property of the **RangeBase** class.
2. Access the paragraph formatting properties using [Format](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Paragraph.Format.html) property of the **Paragraph** class.
3. Access the shading formatting for the paragraph using **Shading** property of the **ParagraphFormat** class.
4. Get shading property. For example, get the shading texture using [Texture](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Shading.Texture.html) property of the **Shading** class.
5. Get the background color using **BackgroundPatternColor** property of the Shading class.
6. Display the shading pattern and color on the console.

    ```csharp
    //Get shading
    TexturePattern texture = 
        doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.Texture;
    Color shading=
        doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.BackgroundPatternColor.RGB;
    Console.WriteLine("Shading Pattern: " + texture + "\n Shading Color: " + shading);
    ```

## Set Shading

To set the shading:

1. Access a paragraph from the paragraph collection using **Paragraphs** property of the RangeBase class.
2. Access the paragraph formatting properties using **Format** property of the Paragraph class.
3. Access the shading formatting for the paragraph using **Shading** property of the ParagraphFormat class.
4. Set a shading property. For example, set the shading texture using **Texture** property of the Shading class.
5. Set the background color using **BackgroundPatternColor** property of the Shading class.

    ```csharp
    //Set shading
    doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.Texture = 
        TexturePattern.Percent15;
    doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Shading.BackgroundPatternColor.RGB = 
        Color.LightPink;
    ```

For more information on how to implement background shading using DsWord, see [DsWord sample browser](https://developer.mescius.com/documents-api-word/demos/).