title: Select whole column by clicking ColumnHeader. WPF DATAGRID
body: <p>I have a data grid which has disabled sorting. What I want to achieve is - by clicking a column header I want to select all cells in this column(select whole column). I've added <code>EventSetter</code> to my <code>DataGridColumnHeader</code> to bind some method to <code>Click</code> event, but I have no idea how this method should be written. Any ideas?</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>private void columnHeaderClick(object sender, RoutedEventArgs e)
  {
          var columnHeader = sender as DataGridColumnHeader;
          if (columnHeader != null)
          {
              if (dgDane.SelectedCells != null)
              {
                  dgDane.SelectedCells.Clear();
              }
              foreach (var item in dgDane.Items)
              {
                  dgDane.SelectedCells.Add(new DataGridCellInfo(item, columnHeader.Column));                  
              }
              dgDane.Focus();
          }
      }
  </code></pre>
  
  <p>I Edited the code, this one above works fine(thanks to @nit). I've added focus to <code>DataGrid</code> because it was necessary.</p>