WPF Boarder control in VB.NET

In this article we will learn how to use Border control in WPF using VB.NET.
  • 1859

In this article we will learn how to use Border control in WPF using VB.NET.

Border control

Border control is a WPF (Window presentation Foundation) control that acts as a border. You can put one other control in it and it will act as border of the child control.

For example:

This example shows a simple demo of the Border control.

Drag a Border control from the Toolbox on the form.

bo1.gif
 

Figure 1.

XAML code

<Window x:Class="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="Silver" BorderThickness="1" Height="100"HorizontalAlignment="Left" Margin="10,10,0,0" 
Name
="Border1" VerticalAlignment="Top"Width="200" />

    </Grid>

</Window>

Using BorderThickness property

If the thickness is a positive value, the border is drawn inside the object's bounding box. If the thickness is negative, the border is drawn outside the object's bounding box.

bo2.gif
 

Figure 2.

XAML code:

<Border BorderBrush="Silver" BorderThickness="4,4,6,8" Height="100" HorizontalAlignment="Left"Margin="10,10,0,0" 
Name
="Border1" VerticalAlignment="Top" Width="200" />

Using BorderBrush property

bo3.gif
 

Figure 3.

The form looks like this.

bo6.gif
 

Figure 4.

XAML code

<Border BorderBrush="SpringGreen" BorderThickness="4,4,6,8" Height="100"HorizontalAlignment="Left" Margin="10,10,0,0" 
Name
="Border1" VerticalAlignment="Top"Width="200" />

 

Using Background property

 

Background property can be used in the same manner as the BorderBrush property. The following example will demonstrates it:


 

bo4.gif 

Figure 5.

 

The form looks like this.


 

bo5.gif 

Figure 6.

 

XAML code

 

<Border BorderBrush="SpringGreen" BorderThickness="4,4,6,8" Height="149"HorizontalAlignment="Left" Margin="10,10,0,0" 
Name
="Border1" VerticalAlignment="Top"Width="200">

            <Border.Background>

                <ImageBrush ImageSource="/WpfApplication2;component/Images/flowers-image.jpg" />

            </Border.Background>

        </Border>

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.