title: Expand row in WPF datagrid
body: <p>I am using a DataGrid to display some log files, where each cell contains a TextBlock. I need help creating a method to expand a user selected row like this:</p>
  
  <p><img src="https://i.stack.imgur.com/skTEE.png" alt="http://dl.dropbox.com/u/5649690/StackOverflow%20-%20Do%20not%20delete/Expand%20row%20in%20wpf%20datagrid/Do%20want.png"></p>
  
  <p>This is my code right now. It is based on the index of the clicked row:</p>
  
  <pre><code>DataGridRow testrow = (DataGridRow)logBrowserDataGrid.ItemContainerGenerator.ContainerFromIndex(index);
  
  logBrowserDataGrid.UpdateLayout();
  logBrowserDataGrid.ScrollIntoView(logBrowserDataGrid.Items[index]);
  
  testrow = (DataGridRow)logBrowserDataGrid.ItemContainerGenerator.ContainerFromIndex(index);
  testrow.Height = 100;
  </code></pre>
  
  <p>However this creates a weird result:</p>
  
  <p><img src="https://i.stack.imgur.com/caYOV.png" alt="http://dl.dropbox.com/u/5649690/StackOverflow%20-%20Do%20not%20delete/Expand%20row%20in%20wpf%20datagrid/Do%20not%20want%20.png"></p>
  
  <p>Do you know a god way to expand a row based on the index?</p>
  
  <p>Do you know what happens in the weird result i get? It looks like i am expanding a part of the row, and the rest does stretch out. I have also studied it in runtime, and can see that its height is the correct 100, but the ActuallyHeight is still 20. </p>
  
  <p>Additional info:
  The default size of the rows are set by the .RowHeight property on the DataGrid. 
  I am using the AutoGenerateColumns feature, plus catching the AutogeneratingColumn event to replace the column with a DataGridTemplateColumn.</p>