Skip to main content
All docs
V25.2
  • DevExpress Presentation API Library: Set Slide Background

    • 4 minutes to read

    DevExpress Presentation API supports various background types and fill patterns. You can apply a background style to an individual slide. You can also use a slide master or slide layout to apply a consistent style to all child slides.

    Apply a Background from a Theme

    A Theme is a predefined set of color schemes, fonts, and effects.

    Assign a ThemedSlideBackground instance to the SlideBase.Background property to apply a fill from the slide master’s theme to a slide. ThemedSlideBackground contains the following options:

    ThemedSlideBackground.FillIndex
    Specifies the index of a fill to be applied to slides. Fill indexes can be in the following range: [1..999]. A valid presentation must contain at least three fill elements in the theme (for example, one SolidFill and two GradientFills.
    ThemedSlideBackground.Color
    Specifies the color used to fill the slide background.

    The following code snippet applies the second fill from the theme set in the presentation file and specifies the fill color:

    DevExpress Presentation API - Themed Backgrounds

    using DevExpress.Docs;
    using DevExpress.Docs.Presentation;
    
        slide.Background = new ThemedSlideBackground(2) { Color = new OfficeColor(Color.RoyalBlue) };
    

    Refer to the following help topic for more information about themes: Customize Themes with the DevExpress Presentation API Library.

    Configure Custom Background

    Assign a CustomSlideBackground instance to the SlideBase.Background property to apply a custom background. CustomSlideBackground contains the following settings:

    CustomSlideBackground.Fill
    Specifies background fill type.
    CustomSlideBackground.ShadeToTitle
    Specifies whether to add shadow effects around the slide title.

    Apply a Solid Fill

    Assign a SolidFill to the CustomSlideBackground.Fill property to fill a slide with a solid color. To set a fill color, specify the SolidFill.Color property or use the corresponding SolidFill constructor:

    DevExpress Presentation API - Backgrounds - Solid Fill

    using DevExpress.Docs.Presentation;
    using DevExpress.Drawing;
    using System.Drawing;
    
        Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
        SolidFill fill = new SolidFill(Color.LightCyan);
        slide.Background = new CustomSlideBackground(fill);
    

    Apply a Gradient Fill

    Assign a GradientFill to the CustomSlideBackground.Fill property to fill a slide with a color gradient. Use the following properties to configure gradient settings:

    GradientFill.GradientStops
    Provides access to gradient stops.
    GradientFill.GradientType
    Specifies the type of the gradient. Available options include Circular, Linear, Rectangular, Shape.
    GradientFill.Angle
    Specifies the gradient rotation angle.
    GradientFill.FillRect
    Specifies the gradient fill direction.
    GradientFill.TileRect
    Specifies the rectangular region to which a gradient is applied.
    GradientFill.FlipType
    Specifies how the image is flipped.
    GradientFill.Scaled
    Specifies whether a gradient is scaled.

    DevExpress Presentation API - Backgrounds - Gradient Fill

    using DevExpress.Docs.Presentation;
    using DevExpress.Drawing;
    using System.Drawing;
    
        Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
        GradientFill fill = new GradientFill(gradientType: GradientType.Linear);
        fill.GradientStops.Add(new GradientStop(Color.Cornsilk, 10));
        fill.GradientStops.Add(new GradientStop (Color.AliceBlue, 30));
        fill.GradientStops.Add(new GradientStop (Color.RoyalBlue, 90));
        slide.Background = new CustomSlideBackground(fill);
    

    Apply a Pattern Fill

    Assign a PatternFill to the CustomSlideBackground.Fill property to fill a slide with a pattern. Use the following properties to configure pattern fill settings:

    PatternFill.PatternType
    Specifies a pattern.
    PatternFill.BackgroundColor
    Specifies pattern background color.
    PatternFill.ForegroundColor
    Specifies pattern foreground color.

    As an alternative to standalone properties, you can use a PatternFill constructor to set pattern fill settings in parameters:

    DevExpress Presentation API - Backgrounds - Pattern Fill

    using DevExpress.Docs.Presentation;
    using DevExpress.Drawing;
    using System.Drawing;
    
        Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
        PatternFill fill = new PatternFill(patternType: FillPatternType.Vertical, Color.White, Color.Lavender);
        slide.Background = new CustomSlideBackground(fill);
    

    Apply a Picture Fill

    Assign a PictureFill to the CustomSlideBackground.Fill property to fill a slide with a picture. Use the following properties to configure picture fill settings:

    PictureFill.Image
    Specifies the image used to fill the background.
    PictureFill.AlignType
    Specifies image alignment.
    PictureFill.FillRect
    Specifies the portion of the slide to fill with the image.
    PictureFill.SourceRect
    Specifies the portion of the source image to fill the slide.
    PictureFill.FlipType
    Specifies image flipping mode.
    PictureFill.OffsetX / PictureFill.OffsetY
    Specify the horizontal and vertical offsets of the image relative to its original position.
    PictureFill.ScaleX / PictureFill.ScaleY
    Specify the horizontal and vertical scale factors for the image used to tile the background.
    PictureFill.Stretch
    Specifies whether to stretch the source image.

    DevExpress Presentation API - Backgrounds - Picture Fill

    using DevExpress.Docs.Presentation;
    using DevExpress.Drawing;
    using System.Drawing;
    
        Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
        string imagePath = "D:\\image.png";
        Stream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
        PictureFill fill = new PictureFill(DXImage.FromStream(stream));
        fill.Stretch = true;
        slide.Background = new CustomSlideBackground(fill);