title: WPF: Printing DataGrid in multiple pages
body: <p>I have DataGrid that needs to be printed in multiple pages both horizontally and vertically.  Based on exhaustive searching the closest solution i have is the one found @<a href="http://www.codeproject.com/Articles/138233/Custom-Data-Grid-Document-Paginator" rel="nofollow">http://www.codeproject.com/Articles/138233/Custom-Data-Grid-Document-Paginator</a>.  However, if DataGridTemplateColumn having ComboBox as its content is printed, the resultant print output is blank combobox.  Below is the screenshot of the print,</p>
  
  <p><a href="http://www.filedropper.com/datagridprint" rel="nofollow">http://www.filedropper.com/datagridprint</a></p>
  
  <p>Below is the code used to create a template column while printing,</p>
  
  <pre><code>private FrameworkElement GetTableCell(Grid grid, DataGridColumn column, object item, int columnIndex, int rowIndex)
      {
          FrameworkElement visualElement = null;
          if (column is DataGridTemplateColumn)
          {
              DataGridTemplateColumn templateColumn = column as DataGridTemplateColumn;
              ContentControl contentControl = new ContentControl();
              contentControl.Focusable = true;
              contentControl.ContentTemplate = templateColumn.CellTemplate;
              contentControl.Content = item;
  
              contentControl.SetValue(Grid.ColumnProperty, columnIndex);
              contentControl.SetValue(Grid.RowProperty, rowIndex);
  
              visualElement = contentControl;
          }
  </code></pre>
  
  <p>The above code basically creates new content control and adds the CellTemplate associated with the grid to the newly created content, which does not work.  I would like to know if there is a fix for the above code, if not, is there a working solution that would print DataGrid into multiple pages (WYSIWYG).</p>
  
  <p>Thanks for your help.</p>