officefileapi-405428-presentation-api-slides-backgrounds.md
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.
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.FillIndexSpecifies 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.ColorSpecifies 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:
using DevExpress.Docs;
using DevExpress.Docs.Presentation;
slide.Background = new ThemedSlideBackground(2) { Color = new OfficeColor(Color.RoyalBlue) };
using DevExpress.Docs;
using DevExpress.Docs.Presentation;
slide.Background = New ThemedSlideBackground(2) With {.Color = New OfficeColor(Color.RoyalBlue)}
Refer to the following help topic for more information about themes: Customize Themes with the DevExpress Presentation API Library.
Assign a CustomSlideBackground instance to the SlideBase.Background property to apply a custom background. CustomSlideBackground contains the following settings:
CustomSlideBackground.FillSpecifies background fill type.CustomSlideBackground.ShadeToTitleSpecifies whether to add shadow effects around the slide title.
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:
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);
Imports DevExpress.Docs.Presentation
Imports DevExpress.Drawing
Imports System.Drawing
Dim slide As Slide = New Slide(New SlideLayout(layoutType:=SlideLayoutType.Blank, name:="slide"))
Dim fill As SolidFill = New SolidFill(Color.LightCyan)
slide.Background = New CustomSlideBackground(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.GradientStopsProvides access to gradient stops.GradientFill.GradientTypeSpecifies the type of the gradient. Available options include Circular, Linear, Rectangular, Shape.GradientFill.AngleSpecifies the gradient rotation angle.GradientFill.FillRectSpecifies the gradient fill direction.GradientFill.TileRectSpecifies the rectangular region to which a gradient is applied.GradientFill.FlipTypeSpecifies how the image is flipped.GradientFill.ScaledSpecifies whether a gradient is scaled.
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);
Imports DevExpress.Docs.Presentation
Imports DevExpress.Drawing
Imports System.Drawing
Dim slide As New Slide(New SlideLayout(SlideLayoutType.Blank, "slide"))
Dim fill As New GradientFill(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)
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.PatternTypeSpecifies a pattern.PatternFill.BackgroundColorSpecifies pattern background color.PatternFill.ForegroundColorSpecifies pattern foreground color.
As an alternative to standalone properties, you can use a PatternFill constructor to set pattern fill settings in parameters:
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);
Imports DevExpress.Docs
Imports DevExpress.Docs.Presentation
Imports DevExpress.Drawing
Imports System.Drawing
Dim slide As New Slide(New SlideLayout(SlideLayoutType.Blank, "slide"))
Dim fill As New PatternFill(FillPatternType.Vertical, Color.White, Color.Lavender)
slide.Background = New CustomSlideBackground(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.ImageSpecifies the image used to fill the background.PictureFill.AlignTypeSpecifies image alignment.PictureFill.FillRectSpecifies the portion of the slide to fill with the image.PictureFill.SourceRectSpecifies the portion of the source image to fill the slide.PictureFill.FlipTypeSpecifies image flipping mode.PictureFill.OffsetX / PictureFill.OffsetYSpecify the horizontal and vertical offsets of the image relative to its original position.PictureFill.ScaleX / PictureFill.ScaleYSpecify the horizontal and vertical scale factors for the image used to tile the background.PictureFill.StretchSpecifies whether to stretch the source image.
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);
Imports DevExpress.Docs.Presentation
Imports DevExpress.Drawing
Imports System.Drawing
Imports System.IO
Dim slide As New Slide(New SlideLayout(SlideLayoutType.Blank, "slide"))
Dim imagePath As String = "D:\image.png"
Using stream As Stream = New FileStream(imagePath, FileMode.Open, FileAccess.Read)
Dim fill As New PictureFill(DXImage.FromStream(stream))
fill.Stretch = True
slide.Background = New CustomSlideBackground(fill)
End Using