Updated: February 2009
Represents the control that redistributes space between columns or rows of a Grid control.
Namespace:
System.Windows.Controls
Assembly:
PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Visual Basic (Declaration)
<StyleTypedPropertyAttribute(Property := "PreviewStyle", StyleTargetType := GetType(Control))> _
Public Class GridSplitter _
Inherits Thumb
Dim instance As GridSplitter
[StyleTypedPropertyAttribute(Property = "PreviewStyle", StyleTargetType = typeof(Control))]
public class GridSplitter : Thumb
[StyleTypedPropertyAttribute(Property = L"PreviewStyle", StyleTargetType = typeof(Control))]
public ref class GridSplitter : public Thumb
public class GridSplitter extends Thumb
XAML Object Element Usage
The GridSplitter control redistributes space between rows or columns in a Grid, without changing the dimensions of the Grid. For example, when a GridSplitter resizes two columns, the ActualWidth property of one column is increased while at the same time the ActualWidth property of the other column is decreased by the same amount.
The following table shows how to define a horizontal or vertical GridSplitter by setting the HorizontalAlignment and VerticalAlignment properties and by leaving the ResizeDirection and ResizeBehavior properties set to their default values.
How to create vertical and horizontal GridSplitter controls
A GridSplitter can overlap a row or column that contains other content, or it can occupy a row or column by itself. For more information about how to define a GridSplitter, see How to: Resize Rows with a GridSplitter and How to: Resize Columns with a GridSplitter.
If the HorizontalAlignment and VerticalAlignment property settings do not achieve the desired GridSplitter behavior, you can change the ResizeDirection and ResizeBehavior property settings.
A GridSplitter may be obscured by other objects that are contained in the Children collection of the Grid. For information about how to prevent this situation, see How to: Make Sure That a GridSplitter Is Visible.
Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.
The following example shows how to define a GridSplitter that resizes columns in a Grid by overlaying the edge of a column.
GridSplitter mySimpleGridSplitter = new GridSplitter();
Grid.SetColumn(mySimpleGridSplitter, 0);
mySimpleGridSplitter.Background = Brushes.Blue;
mySimpleGridSplitter.HorizontalAlignment = HorizontalAlignment.Right;
mySimpleGridSplitter.VerticalAlignment = VerticalAlignment.Stretch;
mySimpleGridSplitter.Width = 5;
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<GridSplitter Grid.Column ="0" Background="Blue" Width="5"
HorizontalAlignment="Right" VerticalAlignment="Stretch"/>
</Grid>
The following example shows how to define a GridSplitter that resizes columns in a Grid and that occupies a column in the Grid.
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
...
<GridSplitter Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Background="Black"
ShowsPreview="True"
Width="5"
/>
More Code
System..::.Object
System.Windows.Threading..::.DispatcherObject
System.Windows..::.DependencyObject
System.Windows.Media..::.Visual
System.Windows..::.UIElement
System.Windows..::.FrameworkElement
System.Windows.Controls..::.Control
System.Windows.Controls.Primitives..::.Thumb
System.Windows.Controls..::.GridSplitter
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0
Reference
Other Resources
Date | History | Reason |
|---|
February 2009
| Described how default styles change dependency properties. |
Customer feedback.
|