--- title: "How to: Partition Space by Using the DockPanel Element" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "controls [WPF], DockPanel" - "DockPanel control [WPF], partitioning space" - "partitioning space [WPF]" ms.assetid: a219b9e5-b205-4438-89b5-0a137ac463ab --- # How to: Partition Space by Using the DockPanel Element The following example creates a simple [!INCLUDE[TLA#tla_ui](../../../includes/tlasharptla-ui-md.md)] framework using a element. The partitions available space to its child elements. ## Example This example uses the property, which is an attached property, to dock two identical elements at the of the partitioned space. A third element is docked to the , with its width set to 200 pixels. A fourth is docked to the of the screen. The last element automatically fills the remaining space. [!code-cpp[DockPanelOvwSample#1](~/samples/snippets/cpp/VS_Snippets_Wpf/DockPanelOvwSample/CPP/DockPanel_Ovw_Sample.cpp#1)] [!code-csharp[DockPanelOvwSample#1](~/samples/snippets/csharp/VS_Snippets_Wpf/DockPanelOvwSample/CSharp/DockPanel_Ovw_Sample.cs#1)] [!code-vb[DockPanelOvwSample#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/DockPanelOvwSample/VisualBasic/dockpanel_vb.vb#1)] [!code-xaml[DockPanelOvwSample#1](~/samples/snippets/xaml/VS_Snippets_Wpf/DockPanelOvwSample/XAML/default.xaml#1)] > [!NOTE] > By default, the last child of a 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.](./media/panel-intro-dockpanel.PNG "panel_intro_dockpanel") ## See also - - [Panels Overview](panels-overview.md)