Partager via


Panel.Background Property

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

Gets or sets a Brush that is used to fill the panel.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property Background As Brush
public Brush Background { get; set; }
<panel>
  <panel.Background>
    singleBrush
  </panel.Background>
</panel>
<panel Background="colorString"/>

XAML Values

  • singleBrush
    Within opening and closing property elements for object.Background, exactly one object element for an object that derives from Brush. The object element can be one of the following: LinearGradientBrush, RadialGradientBrush, ImageBrush, SolidColorBrush, or VideoBrush.

  • colorString
    The Color for a SolidColorBrush expressed as an attribute string. This can be a named color, an RGB value, or an ScRGB value. RGB or ScRGB may also specify alpha information.

Property Value

Type: System.Windows.Media.Brush
The brush used to fill the panel. The default is nulla null reference (Nothing in Visual Basic).

Remarks

Dependency property identifier field: BackgroundProperty

The Background property determines the background color of the Panel. For information about setting the background and other properties for the Silverlight plug-in, see How to: Add Silverlight to a Web Page by Using HTML.

The Background property specifies a Brush for the object. A Brush can represent a solid color, a linear or radial gradient, an image, or an applied video brush.

Some brush types (SolidColorBrush) support a XAML attribute syntax, whereas other brush types (ImageBrush, LinearGradientBrush, RadialGradientBrush) support only an object element syntax. This is why two versions of XAML syntax are shown for this property.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.