System.Windows.Controls Nam ...


.NET Framework Class Library for Silverlight
Border Class

Draws a border, background, or both around another object.

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

Visual Basic (Declaration)
<ContentPropertyAttribute("Child", True)> _
Public NotInheritable Class Border _
    Inherits FrameworkElement
Visual Basic (Usage)
Dim instance As Border
C#
[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.

Remarks

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.

Examples

The following example shows how to create a Border around some text.

XAML
<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.

text surrounded by a border

The following example shows how to put a border around several TextBlock objects contained in a StackPanel.

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

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows..::.UIElement
      System.Windows..::.FrameworkElement
        System.Windows.Controls..::.Border
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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

Tags :


Page view tracker