How to: Make Sure That a GridSplitter Is Visible

This example shows how to make sure a GridSplitter control is not hidden by the other controls in a Grid.

Example

The Children of a Grid control are rendered in the order that they are defined in markup or code. GridSplitter controls can be hidden by other controls if you do not define them as the last elements in the Children collection or if you give other controls a higher ZIndexProperty.

To prevent hidden GridSplitter controls, do one of the following.

<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition/>
  </Grid.ColumnDefinitions>
  <Button Grid.Column="0"/>
  <GridSplitter Grid.Column ="0" Background="Blue"/>
</Grid>
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition/>
  </Grid.ColumnDefinitions>
  <GridSplitter Grid.Column="0" Background="Blue"
                Panel.ZIndex="1"/>
  <Button Grid.Column="0"/>
</Grid>
  • Set margins on the control that would otherwise hide the GridSplitter so that the GridSplitter is exposed. The following example sets margins on a control that would otherwise overlay and hide the GridSplitter.
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition/>
  </Grid.ColumnDefinitions>
  <GridSplitter Grid.Column ="0" Background="Blue"/>
  <Button Grid.Column="0" Margin="0,0,5,0"/>
</Grid>

See also