Panel.Background Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
property Brush ^ Background { Brush ^ get(); void set(Brush ^ value); };
Brush Background();
void Background(Brush value);
public Brush Background { get; set; }
var brush = panel.background;
panel.background = brush;
Public Property Background As Brush
<panel Background="{StaticResource resourceName}"/>
- or -
<panel Background="colorString"/>
- or -
<panel>
<panel.Background>singleBrush</panel.Background>
</panel>
The brush that fills the panel content area. The default is null, (a null brush) which is evaluated as Transparent for rendering.
The Background value for a Panel-derived panel is visible underneath the inner area if the elements that are in the Children collection have transparency or null brushes for any of their defining area. It displays in the child margin area for any case where a child element has a nonzero Margin affecting its position. It is also visible between the layout positions of any child elements regardless of margin, although that can depend on how the panel implements its layout behavior. For example, in a Canvas, any pixel in the content area where there's not an absolutely positioned element covering it will show the panel Background brush.
If you're using a Panel class such as Grid or StackPanel as the root element of a control template, it's a common practice to use a {TemplateBinding} markup extension to bind the panel's background to the Control.Background property of the template parent (the control class that uses your template).