title: WPF resizing, * vs Auto
body: <p>I have a XAML with 2 columns in a Grid and I have a button that when I click it, in the code behind, I set the visibility to collapse, and want to resize the other half of the screen to try to take up the whole screen.  The collapsing part works, and the RHS then shifts over to the LHS, but it does not take up the entire screen.  I tried using both the Auto and Star to resize in HidePlots, but it never takes the full screen.  I thought if I collapsed the LHS, and set the column to * for the RHS, it would take up the whole screen.  Any thoughts?  Thanks.</p>
  
  <p>Here's some code to make it more clear:</p>
  
  <pre><code>&lt;Grid Grid.Row="1" x:Name="ExpandableGrid"&gt;            
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
          &lt;ColumnDefinition Width="1.5*"&gt;&lt;/ColumnDefinition&gt;
      &lt;/Grid.ColumnDefinitions&gt;
  
      &lt;Grid Grid.Column="0" x:Name="TableGrid"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;               
  
          &lt;GroupBox Grid.Row="0" Grid.Column="0" x:Name="SampleViewGroupBox" Header="SampleView" HorizontalAlignment="Stretch" FontFamily="Arial" FontSize="12"  Margin="5,0,5,0" &gt;
              &lt;ContentControl Content="{Binding LayoutManager.SampleView}" Height="Auto" Width="Auto"/&gt;
          &lt;/GroupBox&gt;
  
          &lt;Button x:Name="TableButton" HorizontalAlignment="Right" Content="Button" Width="15" Height="15" VerticalAlignment="Top" Margin="0,0,-2,0" Click="MaxButton_Click"  Grid.Column="0" Grid.Row="0"/&gt;
      &lt;/Grid&gt;
  
      &lt;Grid Grid.Column="1" x:Name="BaseViewGrid"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;GroupBox Grid.RowSpan="2" Grid.Column="1" Name="BaseViewGroupBox" Header="PLOTS" Margin="5,0,5,0" &gt;
              &lt;ContentControl Content="{Binding LayoutManager.ConsensusView}" Height="Auto" Width="Auto" /&gt;
          &lt;/GroupBox&gt;
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  
  
  
  private void MaxButton_Click(object sender, RoutedEventArgs e)
  {
      UIElement senderElement = (UIElement)sender;
  
      if (_tableMinimized)
      {
          HideTables(false);
          _tableMinimized = false;
          ((Button)senderElement).Style = (Style)FindResource("DashboardDetailsButton");
      }
      else
      {
          HideTables(true);
          _tableMinimized = true;
          ((Button)senderElement).Style = (Style)FindResource("DashboardDetailsButtonReverse");               
      }
  }
  
  private void HideTables(bool hide)
  {
      if (hide)
      {
          foreach (UIElement child in TableGrid.Children)
              child.Visibility = Visibility.Collapsed;
  
          for (int i = 0; i &lt; ExpandableGrid.ColumnDefinitions.Count; i++)
              ExpandableGrid.ColumnDefinitions[i].Width = GridLength.Auto;
  
          ExpandableGrid.ColumnDefinitions[1].MinWidth = 500;
  
          for (int i = 0; i &lt; ExpandableGrid.RowDefinitions.Count; i++)
              ExpandableGrid.RowDefinitions[i].Height = GridLength.Auto;
  
          TableButton.Visibility = Visibility.Visible;
      }
      else
      {
          foreach (UIElement child in TableGrid.Children)
              child.Visibility = Visibility.Visible;
  
          for (int i = 0; i &lt; ExpandableGrid.ColumnDefinitions.Count; i++)
              ExpandableGrid.ColumnDefinitions[i].Width = new GridLength(1, GridUnitType.Star);
  
          for (int i = 0; i &lt; ExpandableGrid.RowDefinitions.Count; i++)
              ExpandableGrid.RowDefinitions[i].Height = new GridLength(1, GridUnitType.Star);
      }
  }
  </code></pre>
  
  <p><strong>Edit:</strong> I tried to also change one line to:</p>
  
  <pre><code>ExpandableGrid.ColumnDefinitions[1].MinWidth = System.Windows.SystemParameters.PrimaryScreenWidth-20;
  </code></pre>
  
  <p>instead of the hard-coded 500 value, it looks correct.  However, if I try to click the button again to revert back to normal, the RHS takes up the bulk of the screen without getting back to its original position.</p>