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.

  • Make sure that GridSplitter controls are the last Children added to the Grid. The following example shows the GridSplitter as the last element in the Children collection of the Grid.
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition/>
  </Grid.ColumnDefinitions>
  <Button Grid.Column="0"/>
  <GridSplitter Grid.Column ="0" Background="Blue"/>
</Grid>
  • Set the ZIndexProperty on the GridSplitter to be higher than a control that would otherwise hide it. The following example gives the GridSplitter control a higher ZIndexProperty than the Button control.
<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

Reference

GridSplitter

Other Resources

GridSplitter Samples
GridSplitter How-to Topics