See the question and my original answer on StackOverflow

Let's suppose I have this XAML layout:

  <Grid Name="MyGrid">
      <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition Height="Auto" />
          <RowDefinition />
      </Grid.RowDefinitions>
      <MyControl1 ... Grid.Row="0" />
      <GridSplitter Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowsPreview="True" Height="5" />
      <MyControl2 ... Grid.Row="2" />
  </Grid>

Then I can hide the second control (collapse the splitter down) with this code (equivalent of setting Height="0" in XAML):

  MyGrid.RowDefinitions[2].Height = new GridLength(0);

And uncollapse it with this code (equivalent of setting Height="1*" in XAML, which is the default for a RowDefinition):

  MyGrid.RowDefinitions[2].Height = new GridLength(1, GridUnitType.Star);

This is what the splitter does undercovers when the user moves it.