Freigeben über


Border.BorderBrush Property

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

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

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

Syntax

'Declaration
Public Property BorderBrush As Brush
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 defined by Silverlight: 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.

Remarks

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.

Examples

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>

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.

See Also

Reference

Other Resources