title: Print Grid which generated dynamically in wpf
body: <p>i want to print a grid which is generated dynamically. </p>
  
  <p>Means, in the click event of the Print Button, i m generating a grid and then i want to print that grid.</p>
  
  <p>here is my code,</p>
  
  <pre><code>private void btnPrint_Click(object sender, RoutedEventArgs e)
      {
          PrintDialog Objprint = new System.Windows.Controls.PrintDialog();
          if (Objprint.ShowDialog() == true)
          {
  
              System.Printing.PrintCapabilities capabilities = Objprint.PrintQueue.GetPrintCapabilities(Objprint.PrintTicket);
  
              double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / this.ActualWidth, capabilities.PageImageableArea.ExtentHeight / this.ActualHeight);
  
              #region "Make a grid For Printing"
              Grid objgrid = new Grid();
              objgrid.Name = "GridForPrinting";
              objgrid.Width = 1000;
              objgrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
              objgrid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
  
              objgrid.RowDefinitions.Add(new RowDefinition());
  
              TextBlock objtext = new TextBlock();
              objtext.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
              objtext.VerticalAlignment = System.Windows.VerticalAlignment.Center;
              objtext.Text = "SUPERIOR COURT OF CALIF COUNTY OF SAN BERNARDINO";
              Grid.SetRow(objtext, 0);
              objgrid.Children.Add(objtext);
  
              #endregion
  
              Objprint.PrintVisual(objgrid, "Case Summary");
          }
      }
  </code></pre>
  
  <p>this code give me blank page to print.</p>
  
  <p>how can i do that?</p>