Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Border Class
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Border Class

Updated: November 2007

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

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/xaml/presentation

Visual Basic (Declaration)
Public Class Border _
    Inherits Decorator
Visual Basic (Usage)
Dim instance As Border
C#
public class Border : Decorator
Visual C++
public ref class Border : public Decorator
J#
public class Border extends Decorator
JScript
public class Border extends Decorator
XAML Object Element Usage
<Border>
  Child
</Border>

Content Model: Border can have only one child. To display multiple child elements, you need to place an additional Panel element within the parent Border. You can then place child elements within that Panel element.

If you want to display a border around your content, you must place the elements within a parent Border element.

The following example demonstrates how to create a Border and set properties in code and Extensible Application Markup Language (XAML).

Visual Basic
Dim myBorder As New Border
myBorder.Background = Brushes.LightBlue
myBorder.BorderBrush = Brushes.Black
myBorder.BorderThickness = New Thickness(2)
myBorder.CornerRadius = New CornerRadius(45)
myBorder.Padding = New Thickness(25)

C#
myBorder = new Border();
myBorder.Background = Brushes.LightBlue;
myBorder.BorderBrush = Brushes.Black;
myBorder.BorderThickness = new Thickness(2);
myBorder.CornerRadius = new CornerRadius(45);
myBorder.Padding = new Thickness(25);

XAML
<Border Background="LightBlue" 
        BorderBrush="Black" 
        BorderThickness="2" 
        CornerRadius="45" 
        Padding="25">

More Code

How to: Wrap a Border Around the Content of a Canvas This example shows how to wrap a Canvas element with a Border.
How to: Change Border Properties This example shows how to change the Background color of a Border element.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

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