Draws a border, background, or both around another object.
Namespace:
System.Windows.Controls
Assembly:
System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
<ContentPropertyAttribute("Child", True)> _
Public NotInheritable Class Border _
Inherits FrameworkElement
[ContentPropertyAttribute("Child", true)]
public sealed class Border : FrameworkElement
XAML Object Element Usage
<Border>
singleChild
</Border>
XAML Values
- singleChild
A single object element that the border encloses. This child must be an object that derives from UIElement.
You can specify basic properties of a Border by setting its Width, Height, BorderThickness, and Background color. In addition, you can round the border corners by setting the CornerRadius property, and you can position the object inside the Border by setting the Padding property.
Border can contain only one child object. If you want to put a border around multiple objects, wrap them in a container object such as StackPanel.
The following example shows how to create a Border around some text.
<Border Background="Coral" Width="300" Padding="10" CornerRadius="20">
<TextBlock FontSize="16">Text Surrounded by a Border</TextBlock>
</Border>
The preceding example produces output that is similar to the following illustration.
.gif)
The following example shows how to put a border around several TextBlock objects contained in a StackPanel.
<Border BorderThickness="5" BorderBrush="Blue" >
<StackPanel Grid.Column="0" Grid.Row="0">
<TextBlock Text="One"/>
<TextBlock Text="Two"/>
<TextBlock Text="Three"/>
</StackPanel>
</Border>
System..::.Object
System.Windows..::.DependencyObject
System.Windows..::.UIElement
System.Windows..::.FrameworkElement
System.Windows.Controls..::.Border
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Reference
Other Resources