Border.Background Border.Background Border.Background Border.Background Property

Definition

Gets or sets the Brush that fills the background (inner area) of the border.

public : Brush Background { get; set; }
Brush Background();

void Background(Brush background);
public Brush Background { get; set; }
Public ReadWrite Property Background As Brush
<Border Background="{StaticResource resourceName}"/>

Property Value

The brush that fills the background. The default is null, (a null brush) which is evaluated as Transparent for rendering.

Examples

The following example shows how to set the background of a Border to a solid color using an inline-defined attribute value "Cyan". The XAML parser uses this "Cyan" value to refer to the named color Colors.Cyan, and to create the SolidColorBrush instance that supplies the runtime value.

<Border Background="Cyan" CornerRadius="20" Grid.Column="2" Grid.Row="2">
    <TextBlock Text="Background Brush" TextWrapping="Wrap" VerticalAlignment="Center" />
</Border>

Remarks

The Background value for a Border is visible underneath the inner area if the element that is the Child element has transparency or null value brushes for any of its defining area. It is also visible between the border edge and the Child content if nonzero values are applied for a Padding value.

See also