This topic has not yet been rated - Rate this topic

Border.BorderBrush Property

April 12, 2014

Gets or sets the Brush that is used to create the border.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
public Brush BorderBrush { get; set; }
<Border>
  <Border.BorderBrush>
    singleBrush
  </Border.BorderBrush>
</Border>
<Border BorderBrush="colorString"/>

XAML Values

singleBrush

Within opening and closing property elements for Border.BorderBrush, exactly one object element for an object that derives from Brush. This is typically one of the following classes: LinearGradientBrush, RadialGradientBrush, ImageBrush, SolidColorBrush, 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. See the XAML Values section in Color.

Property Value

Type: System.Windows.Media.Brush
The brush that fills the border.

Dependency property identifier field: BorderBrushProperty

The BorderThickness property is 0 by default. In order for the BorderBrush to be visible, you must set the BorderThickness to a nonzero value.

The following example shows how to set the border to a solid color.


<Border BorderThickness="5" BorderBrush="Blue" >
    <StackPanel Grid.Column="0" Grid.Row="0">
        <TextBlock Text="One"/>
        <TextBlock Text="Two"/>
        <TextBlock Text="Three"/>
    </StackPanel>
</Border>


You can also make the border using brushes that derive from Brush, such as LinearGradientBrush, which is shown below.


<Border BorderThickness="10" Grid.Column="2" Grid.Row="0">
    <Border.BorderBrush>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
            <GradientStop Color="Gold" Offset="0"/>
            <GradientStop Color="Purple" Offset="1"/>
        </LinearGradientBrush>
    </Border.BorderBrush>
    <TextBlock Text="Gradient Brush" TextWrapping="Wrap" VerticalAlignment="Center" />
</Border>


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.