title: WPF: How to freeze column header in datagrid
body: <p>How can I freeze my column header in a <code>DataGrid</code> in my <code>WPF</code> Window so that when I scroll down, the header is still visible.</p>
  
  <p>[<strong>Edit</strong>]</p>
  
  <p>Here's my <code>XAML</code>:</p>
  
  <pre><code>&lt;ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Visible"&gt;
      &lt;DataGrid Name="ModelsGrid" Background="Transparent" Foreground="Black"  RowHeight="30" ColumnWidth="100"  AutoGenerateColumns="False" ItemsSource="{Binding}"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Header="Property ID" Binding="{Binding Path=Id}" /&gt;
              &lt;DataGridTextColumn Header="Name" Width="Auto" Binding="{Binding Path=PropertyName}" /&gt;
              &lt;DataGridTextColumn Header="Description" Width="Auto" Binding="{Binding Path=Description}" /&gt;
              &lt;DataGridTextColumn Header="Access" Width="Auto" Binding="{Binding Path=Accessibility}" /&gt;
              &lt;DataGridTextColumn Header="Type" Width="Auto" Binding="{Binding Path=Type}" /&gt;
              &lt;DataGridTextColumn Header="Category" Width="Auto" Binding="{Binding Path=Category}" /&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  &lt;/ScrollViewer&gt;
  </code></pre>
  
  <p>[<strong>Edit</strong>]</p>
  
  <p>I just had to get rid of the <code>ScrollViewer</code> and it's solved. </p>