title: Multiple page printing in Silverlight 4 using Custom Printing Template (a User Control)
body: <p>I need some help on printing multiple pages with custom printing template. The printing template (a Silverlight User Control) consists of two Text-block's (Title and Content which displays and later prints the respective text). The problem I am having is its only able to print 1 page, how can I extend it to print multiple pages. This is the work flow - </p>
  
  <ul>
  <li>The content (to be printed which can be very large) is first displayed on text block embedded in Child Window (kind of customized message box).</li>
  <li>This content needs to be printed, so I created a custom printing template which will print title and the content separately.</li>
  <li>Now, I am not sure how can I extend it to print multiple pages.</li>
  </ul>
  
  <p>Here's my xaml - </p>
  
  <pre><code>&lt;StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,10,10,10" &gt;
          &lt;Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="10" BorderThickness="5" Background="White" Height="50" &gt;
              &lt;TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2" TextWrapping="Wrap" Name="TitleTextBlock" FontSize="16" 
                         TextAlignment="Center" FontFamily="Times New Roman" FontStyle="Italic" FontWeight="SemiBold" &gt;
              &lt;/TextBlock&gt;
          &lt;/Border&gt;
          &lt;Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="10" Margin="0,10,0,0" BorderThickness="5" Background="White" Height="950" &gt;
              &lt;TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" TextWrapping="Wrap" Name="ContentTextBlock" FontSize="14"
                         FontFamily="Times New Roman" FontWeight="Normal" &gt;
              &lt;/TextBlock&gt;
          &lt;/Border&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>and my code -</p>
  
  <pre><code>Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
      printDoc.Print("MyTest")
  End Sub
  
  Private Sub printDoc_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
  
      Dim printPage As New PrintingPageTemplate
  
      'printPage.PageTitle = Me.Title.ToString
      'printPage.PageContent = Me.txtMessage.Text
      printPage.TitleTextBlock.Text = Me.Title.ToString
      printPage.ContentTextBlock.Text = Me.txtMessage.Text 'The txtMessage is a text block which consists of data to be printed and it can have very large content
  
      e.PageVisual = printPage
      'e.HasMorePages = True ' This doesn't work
  End Sub
  </code></pre>
  
  <p>Need some logic which will check the total size of TitleTextBlock and create new instance of PrintingTemplate. Can someone please throw some pointers on how can I achieve this? (I hope I was able to provide enough information for my problem).</p>