Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-partition-space-by-using-the-dockpanel-element.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07: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 [!INCLUDETLA#tla_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