Partager via


Background (Silverlight Plug-in Object)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the background color of the rectangular region that displays XAML content.

Syntax

object Element

<object ...>
  <param name="background" value="colorValue"/>
  ...
</object>

Silverlight.js

Silverlight.CreateObject(,,,{background:'colorValue'});
-or-
Silverlight.CreateObjectEx({properties:{background:'colorValue'}});

JavaScript

value = silverlightObject.settings.Background;
silverlightObject.settings.Background = colorValue;

COM

IXcpControl::Content gets an IDispatch interface, which you can use to call Background.

Managed Code

See SilverlightHost.Background. In managed code, this property is read-only at run time.

Property Value

Specifies the background color value as a string. This string can specify a named color value or a color value that is specified by using several possible conventions, which includes RGB and ScRGB. RGB and ScRGB values can be specified with or without alpha transparency. The following table lists conventions that are used to specify color values.

Convention

Example

Description

Named color

Red

A named color value. (The name is not case-sensitive.) For more information about color names, including a color table, see Color.

8-bit RGB, no alpha

#F00

An 8-bit RGB value, in the form #RGB.

8-bit RGB, alpha

#8F00

An 8-bit RGB value with alpha transparency, in the form #ARGB.

16-bit RGB, no alpha

#FF0000

A 16-bit RGB value, in the form #RRGGBB.

16-bit RGB, alpha

#80FF0000

A 16-bit RGB value with alpha transparency, in the form #AARRGGBB.

scRGB, no alpha

sc#1,0,0

An ScRGB value without alpha transparency, in the form sc#R,G,B.

scRGB, alpha

sc#0.5,1,0,0

An ScRGB value without alpha transparency in the form sc#A,R,G,B.

The default value is null.

Remarks

For rendering purposes, a null value for the Background property of the Silverlight plug-in is interpreted as the named color White.

If the Windowless property is set to true, or if Silverlight is running on a Macintosh computer (where windowless mode is always active, regardless of the Windowless setting), the Background property value can specify an alpha value for the color. The color value is then blended with the HTML page.

So long as Windowless is false, in many cases the Background color of a Silverlight plug-in will never be visible. The content you specify as RootVisual totally covers the background, if you use the recommended technique of leaving Height and Width of any root visual unset so that it uses the automatic behavior of filling all available space in the plug-in content area.

Important noteImportant Note:

Setting an alpha channel value for full or partial transparency has possible performance consequences, especially in certain client environments. See Performance Tips.