Skip to main content

BingWallpaper

BingWallpaper is a non-visual component that shows the recent Bing images of the day as the background of a control. By default that's the application's Desktop or, without a desktop, the main page. It downloads the list of images, cross-fades from one to the next at a fixed interval, and can slowly zoom each new image while it fades in.

It needs no images of your own and no code beyond a few property values, which makes it a quick way to give a desktop-style application or a login screen a changing, photographic background.

A Wisej.NET desktop application with a Bing image of the day, the Manhattan skyline at dusk, as its full-screen background, and a clock widget and the taskbar on top

A Wisej.NET Desktop with a Bing image of the day as its background.

Installation​

Add the Wisej-4-BingWallpaper package to your Wisej.NET project, either with the NuGet Package Manager or from the command line:

dotnet add package Wisej-4-BingWallpaper

The package targets .NET Framework 4.8 and .NET 8 or later (including the -windows, Android, iOS and Mac Catalyst targets). BingWallpaper is a component: drop it from the toolbox onto a desktop, page or form, and it appears in the designer's component tray.

Internet access is required

The server downloads the list of images from https://www.bing.com/HPImageArchive.aspx when the component is rendered, and the browser then loads each image from https://www.bing.com. Both must be able to reach bing.com, and a Content Security Policy must allow images from that host. If the list can't be downloaded, the error is written to the trace log and the background stays as it is.

Getting started​

This example rotates five Bing images on the desktop, changing every 30 seconds with a two-second cross-fade:

using Wisej.Web.Ext.BingWallpaper;

public partial class MyDesktop : Desktop
{
private BingWallpaper bingWallpaper;

public MyDesktop()
{
InitializeComponent();

// Control is left null, so the images go on the current Desktop.
this.bingWallpaper = new BingWallpaper(this.components)
{
MaxImages = 5,
RotationInterval = 30000,
FadeTime = 2000
};
}
}
Pass the container

Create the component with the BingWallpaper(IContainer) constructor, passing the designer's components container, as above. The component is then disposed together with the desktop, page or form that owns it. The designer does this for you when you drop the component from the toolbox.

Properties​

PropertyDefaultWhat it does
ControlnullThe control that shows the images. When null, the images go on the current Desktop or, if the application has none, on Application.MainPage. The images are scaled to cover the whole control.
MaxImages10How many recent images of the day to download, from 0 to 100. 0 downloads one. Bing may return fewer than requested.
RotationInterval60000Milliseconds between two images, up to 10 hours. 0 shows only the first image.
FadeTime1000Duration of the cross-fade in milliseconds, from 0 to 10,000. 0 switches without fading.
EnableAnimationtrueSlowly zooms each new image to 105% while it fades in. The zoom lasts five times FadeTime.

The images are shown in order and start again from the first after the last. The timer runs in the browser, so rotating the images causes no requests to the server. The list of images is downloaded once and reused until MaxImages changes.

Keep content readable

Photographs are busy backgrounds. Behind forms or text, set EnableAnimation = false and use a long RotationInterval, so the background doesn't move under what the user is reading. Keep FadeTime well below RotationInterval, too: otherwise the next image starts fading in before the previous transition has finished.

Showing the images on a specific control​

Set Control to put the images behind any other control, for example a login panel:

private void LoginPage_Load(object sender, EventArgs e)
{
this.bingWallpaper1.Control = this.panelLogin;
this.bingWallpaper1.RotationInterval = 15000;
}

When the target control is disposed, Control goes back to null.

API reference​