Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
Border Class

  Switch on low bandwidth view
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.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)
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.

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.

text surrounded by a border

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>

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.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker