Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-choose-between-stackpanel-and-dockpanel.md
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.0 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Choose Between StackPanel and DockPanel 03/30/2017
csharp
vb
cpp
controls [WPF], DockPanel
DockPanel control [WPF], StackPanel control compared to
StackPanel control [WPF], DockPanel control compared to
controls [WPF], StackPanel
f9239086-451f-42e6-81f7-ef89ef349742

How to: Choose Between StackPanel and DockPanel

This example shows how to choose between using a xref:System.Windows.Controls.StackPanel or a xref:System.Windows.Controls.DockPanel when you stack content in a xref:System.Windows.Controls.Panel.

Example

Although you can use either xref:System.Windows.Controls.DockPanel or xref:System.Windows.Controls.StackPanel to stack child elements, the two controls do not always produce the same results. For example, the order that you place child elements can affect the size of child elements in a xref:System.Windows.Controls.DockPanel but not in a xref:System.Windows.Controls.StackPanel. This different behavior occurs because xref:System.Windows.Controls.StackPanel measures in the direction of stacking at Double.PositiveInfinity; however, xref:System.Windows.Controls.DockPanel measures only the available size.

The following example demonstrates this key difference between xref:System.Windows.Controls.DockPanel and xref:System.Windows.Controls.StackPanel.

[!code-cppStackPanelOvw4#1] [!code-csharpStackPanelOvw4#1] [!code-vbStackPanelOvw4#1] [!code-xamlStackPanelOvw4#1]

See also