Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
GridSplitter Class
Other versions are also available for the following:
.NET Framework Class Library for Silverlight
GridSplitter Class

Represents a control that redistributes space between the rows of columns of a Grid control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls (in System.Windows.Controls.dll)
Visual Basic (Declaration)
<TemplateVisualStateAttribute(Name := "Disabled", GroupName := "CommonStates")> _
<TemplatePartAttribute(Name := "HorizontalTemplate", Type := GetType(FrameworkElement))> _
<TemplatePartAttribute(Name := "VerticalTemplate", Type := GetType(FrameworkElement))> _
<TemplateVisualStateAttribute(Name := "Normal", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "MouseOver", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Focused", GroupName := "FocusStates")> _
<TemplateVisualStateAttribute(Name := "Unfocused", GroupName := "FocusStates")> _
Public Class GridSplitter _
    Inherits Control
Visual Basic (Usage)
Dim instance As GridSplitter
C#
[TemplateVisualStateAttribute(Name = "Disabled", GroupName = "CommonStates")]
[TemplatePartAttribute(Name = "HorizontalTemplate", Type = typeof(FrameworkElement))]
[TemplatePartAttribute(Name = "VerticalTemplate", Type = typeof(FrameworkElement))]
[TemplateVisualStateAttribute(Name = "Normal", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "MouseOver", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Focused", GroupName = "FocusStates")]
[TemplateVisualStateAttribute(Name = "Unfocused", GroupName = "FocusStates")]
public class GridSplitter : Control
XAML Object Element Usage
<swc:GridSplitter .../>
XAML Values
swc:

A prefix that is defined to map the XML namespace for the System.Windows.Controls assembly and the System.Windows.Controls CLR namespace.

The precise manner in which space in the Grid is redistributed when you use a GridSplitter is controlled by the properties of the grid columns. For more information, see Grid.

Once a GridSplitter is put into a cell on a Grid, it can be used to resize rows or columns either vertically or horizontally. To specify whether a GridSplitter resizes rows or columns, use the HorizontalAlignment and VerticalAlignment attached properties. One of these two properties should always be set to Stretch. The following table summarizes the possibilities:

HorizontalAlignment

VerticalAlignment

Result

Stretch

Other

Resizes rows.

Other

Stretch

Resizes columns.

Stretch

Stretch

Resizes columns if ActualHeight is greater than or equal to ActualWidth; otherwise, resizes rows.

The following XAML creates two GridSplitter controls, one vertical and one horizontal. The horizontal control shows a preview, whereas the vertical one does not.

XAML
<UserControl x:Class="GridSplitterExample.Page"
        xmlns="http://schemas.microsoft.com/client/2007" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:swc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"             
        Width="450"
        Height="500"
        >

    <Canvas x:Name="LayoutRoot" Background="White" >
        <TextBlock Text="GridSplitter Demonstration" Margin="0,20,10,20"
            FontFamily="Verdana" FontSize="18" FontWeight="Bold"
            Foreground="#FF5C9AC9" Canvas.Top="0" Canvas.Left="20"/>
        <Grid ShowGridLines="True" Canvas.Top="60" Canvas.Left="20" Width="400" Height="400">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>



            <TextBlock Text="One!" Grid.Row="0" Grid.Column="0" />
            <TextBlock Text="Two!" Grid.Row="1" Grid.Column="1" />
            <TextBlock Text="Three!" Grid.Row="2" Grid.Column="2" />
            <TextBlock Text="Four!" Grid.Row="3" Grid.Column="3" />
            <swc:GridSplitter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4"
                               Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                               ShowsPreview="True"
                                />
            <swc:GridSplitter Grid.Row="2" Grid.Column="1" Grid.RowSpan="2"
                               Width="5" HorizontalAlignment="Left" VerticalAlignment="Stretch"
                                />
       </Grid>


    </Canvas>
</UserControl>

Run this sample

The previous example produces output that is similar to the following illustration. A grid is shown before and after a GridSplitter is used to redistribute space.

Silverlight GridSplitter control
System..::.Object
  System.Windows..::.DependencyObject
    System.Windows..::.UIElement
      System.Windows..::.FrameworkElement
        System.Windows.Controls..::.Control
          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.

For information on the operating systems and browsers supported by Silverlight, see "Supported Operating Systems and Browsers" in Silverlight Architecture.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker