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.

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.
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:
- C#
- VB.NET
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
};
}
}
Imports Wisej.Web.Ext.BingWallpaper
Public Class MyDesktop
Inherits Desktop
Private bingWallpaper As BingWallpaper
Public Sub New()
InitializeComponent()
' Control is left Nothing, so the images go on the current Desktop.
Me.bingWallpaper = New BingWallpaper(Me.components) With {
.MaxImages = 5,
.RotationInterval = 30000,
.FadeTime = 2000
}
End Sub
End Class
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
| Property | Default | What it does |
|---|---|---|
Control | null | The 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. |
MaxImages | 10 | How many recent images of the day to download, from 0 to 100. 0 downloads one. Bing may return fewer than requested. |
RotationInterval | 60000 | Milliseconds between two images, up to 10 hours. 0 shows only the first image. |
FadeTime | 1000 | Duration of the cross-fade in milliseconds, from 0 to 10,000. 0 switches without fading. |
EnableAnimation | true | Slowly 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.
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:
- C#
- VB.NET
private void LoginPage_Load(object sender, EventArgs e)
{
this.bingWallpaper1.Control = this.panelLogin;
this.bingWallpaper1.RotationInterval = 15000;
}
Private Sub LoginPage_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BingWallpaper1.Control = Me.panelLogin
Me.BingWallpaper1.RotationInterval = 15000
End Sub
When the target control is disposed, Control goes back to null.
Related
- CustomWallpaper does the same with your own images instead of Bing's.
- Desktop in the user guide.
API reference
BingWallpaper- The whole
Wisej.Web.Ext.BingWallpapernamespace