C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
BorderBrush: We can set the BorderBrush to a named color. In this example, I use a red color: Tomato.
BorderThickness: This attribute indicates the number of pixels wide the border itself is.
Alignment: We set the HorizontalAlignment and VerticalAlignment attributes to Stretch. These expand (anchor) the border to the container.
HorizontalAlignmentAlso: I changed the Margin value in the border to equal 10 on each side. We could use the value "10" as the entire margin value.
Example markup: XAML
<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Border
BorderBrush="Tomato"
BorderThickness="3"
HorizontalAlignment="Stretch"
Margin="10,10,10,10"
VerticalAlignment="Stretch"/>
</Grid>
</Window>
Here: We nested an "aqua" border within our "tomato" border. We use the simplified margin syntax. We set the thickness to 3.
Example markup 2: XAML
<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Border
BorderBrush="Tomato"
BorderThickness="3"
HorizontalAlignment="Stretch"
Margin="10"
VerticalAlignment="Stretch">
<Border
BorderBrush="Aqua"
BorderThickness="3"
Margin="10"/>
</Border>
</Grid>
</Window>