WPF Border Control


The Border control is a Decorator control that you can use to draw a border, a background, or even both, around another element. Since the WPF panels don’t support drawing a border around its edges, the Border control can help you achieve that. You could surround a Panel with a Border.

Below is the XAML code for this project.

1<Window x:Class="BorderControl.MainWindow"
6        xmlns:local="clr-namespace:BorderControl"
7        mc:Ignorable="d"
8        WindowStartupLocation="CenterScreen"
9        Title="BorderControl" Height="250" Width="400">
10    <Grid>
11        <Border Background="Azure" BorderBrush="Gray" BorderThickness="2">
12            <StackPanel Margin="10">
13                <Button>Button 1</Button>
14                <Button Margin="0,10">Button 2</Button>
15                <Button>Button 3</Button>
16            </StackPanel>
17        </Border>
18    </Grid>
19</Window>

In the next section we will do a little more.