Use WPF DockPanel Control in VB.NET

In this article, we will learn DockPanel Control in WPF.
  • 3138
DockPanel Control:- The DockPanel control is a layout panel control. The dockpanel control is very easy and useful control. We can provides an easy docking of elements to the left, right, top, bottom and center of the panel. The DockPanel is used to anchor elements to the edges of the container, and is a good choice to set up the overall structure of the application UI. Elements are docked using the DockPanel.Dock attached property.

It uses DockPanel.Dock attached property to determine the position of the element. The Dock element when Top or Bottom, will make the element appear Top or Bottom of each other, and when its Left and right it is left and right of each other. We will use DockPanel.Dock property in the DockPanel Control.

This code of .xaml:-

<Window x:Class="Window1"
    Title="Window1" Height="300" Width="300">
            <Border Background="Green" DockPanel.Dock="Top">
                <TextBlock Text="Dock:Top" Foreground="White" />
            <Border Background="OrangeRed" DockPanel.Dock="Bottom">
                <TextBlock Text="Dock:Bottom" Foreground="White" />
            <Border Background="Purple" DockPanel.Dock="Left">
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Dock:Left" Foreground="White" />
            <Border Background="White" DockPanel.Dock="Left">
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Dock:Left" Foreground="Black" />
            <Border Background="Green" DockPanel.Dock="Bottom">
                <TextBlock Text="Dock:Top" Foreground="White" />
            <Border Background="OrangeRed" DockPanel.Dock="Top">
                <TextBlock Text="Dock:Top" Foreground="White" />
            <Border Background="OrangeRed" DockPanel.Dock="Right">
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Dock:Right" Foreground="White" />
            <Border Background="White" DockPanel.Dock="Right">
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"

Text="Dock:Right" />
            <Border Background="Green" >
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"

Text="Remaining Fill" Foreground="White" />




More Articles

© 2020 DotNetHeaven. All rights reserved.