Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-partition-space-by-using-the-dockpanel-element.md
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

2.2 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Partition Space by Using the DockPanel Element 03/30/2017
csharp
vb
cpp
controls [WPF], DockPanel
DockPanel control [WPF], partitioning space
partitioning space [WPF]
a219b9e5-b205-4438-89b5-0a137ac463ab

How to: Partition Space by Using the DockPanel Element

The following example creates a simple user interface (UI) framework using a xref:System.Windows.Controls.DockPanel element. The xref:System.Windows.Controls.DockPanel partitions available space to its child elements.

Example

This example uses the xref:System.Windows.Controls.DockPanel.Dock%2A property, which is an attached property, to dock two identical xref:System.Windows.Controls.Border elements at the xref:System.Windows.Controls.Dock.Top of the partitioned space. A third xref:System.Windows.Controls.Border element is docked to the xref:System.Windows.Controls.Dock.Left, with its width set to 200 pixels. A fourth xref:System.Windows.Controls.Border is docked to the xref:System.Windows.Controls.Dock.Bottom of the screen. The last xref:System.Windows.Controls.Border element automatically fills the remaining space.

[!code-cppDockPanelOvwSample#1] [!code-csharpDockPanelOvwSample#1] [!code-vbDockPanelOvwSample#1] [!code-xamlDockPanelOvwSample#1]

Note

By default, the last child of a xref:System.Windows.Controls.DockPanel element fills the remaining unallocated space. If you do not want this behavior, set LastChildFill="False".

The compiled application yields a new UI that looks like this.

A typical DockPanel scenario.

See also