In XAML <DockPanel /> element is used to create DockPanel control in WPF. DockPanel is used to dock child elements in left, right, top and bottom positions of relative item. The Dock side of an element is defined by the attached property DockPanel.Dock. In this demonstration we learn how to use DockPanel control in WPF.

A XAML code snippet representing DockPanel control
<DockPanel x:Name="dockPanel1">
        <Button x:Name="topButton" Content="Top Button" DockPanel.Dock="Top" />
        <Button x:Name="bottomButton" Content="Bottom Button" DockPanel.Dock="Bottom" />
        <Button x:Name="leftButton" Content="Left Button" DockPanel.Dock="Left" />
        <Button x:Name="rightButton" Content="Right Button" DockPanel.Dock="Right" />
        <Button x:Name="centerButton" Content="Center Button" />
Output of the following code snippet is as follows

DockPanel control in WPF


  Modified On Mar-22-2018 06:02:27 AM

Leave Comment