Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-resize-rows-with-a-gridsplitter.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

3.5 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Resize Rows with a GridSplitter 03/30/2017
resizing grid rows [WPF]
grid rows [WPF], resizing
GridSplitter control [WPF], resizing grid rows
2413a9f2-1d81-46ed-95cb-95ec8233eea2

How to: Resize Rows with a GridSplitter

This example shows how to use a horizontal xref:System.Windows.Controls.GridSplitter to redistribute the space between two rows in a xref:System.Windows.Controls.Grid without changing the dimensions of the xref:System.Windows.Controls.Grid.

Example

How to create a GridSplitter that overlays the edge of a row

To specify a xref:System.Windows.Controls.GridSplitter that resizes adjacent rows in a xref:System.Windows.Controls.Grid, set the xref:System.Windows.Controls.Grid.Row%2A attached property to one of the rows that you want to resize. If your xref:System.Windows.Controls.Grid has more than one column, set the xref:System.Windows.Controls.Grid.ColumnSpan%2A attached property to specify the number of columns. Then set the xref:System.Windows.FrameworkElement.VerticalAlignment%2A to xref:System.Windows.VerticalAlignment.Top or xref:System.Windows.VerticalAlignment.Bottom (which alignment you set depends on which two rows you want to resize). Finally, set the xref:System.Windows.FrameworkElement.HorizontalAlignment%2A property to xref:System.Windows.HorizontalAlignment.Stretch.

The following example shows how to define a horizontal xref:System.Windows.Controls.GridSplitter that resizes adjacent rows.

[!code-xamlGridSplitterRowColumn#GridSplitterRowOverlay]

A xref:System.Windows.Controls.GridSplitter that does not occupy its own row may be obscured by other controls in the xref:System.Windows.Controls.Grid. For more information about how to prevent this issue, see Make Sure That a GridSplitter Is Visible.

How to create a GridSplitter that occupies a row

To specify a xref:System.Windows.Controls.GridSplitter that occupies a row in a xref:System.Windows.Controls.Grid, set the xref:System.Windows.Controls.Grid.Row%2A attached property to one of the rows that you want to resize. If your xref:System.Windows.Controls.Grid has more than one column, set the xref:System.Windows.Controls.Grid.ColumnSpan%2A attached property to the number of columns. Then set the xref:System.Windows.FrameworkElement.VerticalAlignment%2A to xref:System.Windows.VerticalAlignment.Center, set the xref:System.Windows.FrameworkElement.HorizontalAlignment%2A property to xref:System.Windows.HorizontalAlignment.Stretch, and set the xref:System.Windows.Controls.RowDefinition.Height%2A of the row that contains the xref:System.Windows.Controls.GridSplitter to xref:System.Windows.GridLength.Auto%2A.

The following example shows how to define a horizontal xref:System.Windows.Controls.GridSplitter that occupies a row and resizes the rows on either side of it.

[!code-xamlGridSplitterRowColumn#GridSplitterEntireRowPart1]
[!code-xamlGridSplitterRowColumn#GridSplitterEntireRowPart2]

See also