How to print Formatted Page which contain ListBox or GridView

别等时光非礼了梦想. 提交于 2020-01-13 03:44:25

问题


Printing Document using WinRT :

1) To Keep tracking if there are more data Or text data to print in a formatted page.

This can be done using RichTextBlock and RichTextBlockOverflow like below:


<RichTextBlock Foreground="Black" x:Name="textContent" FontSize="18" Grid.Row="1"  Grid.ColumnSpan="2" OverflowContentTarget="{Binding ElementName=firstLinkedContainer}" 
IsTextSelectionEnabled="True" TextAlignment="Left" FontFamily="Segoe UI" VerticalAlignment="Top" HorizontalAlignment="Left">

</RichTextBlok>

<RichTextBlockOverflow x:Name="firstLinkedContainer" OverflowContentTarget="{Binding ElementName=continuationPageLinkedContainer}" Grid.Row="2" Grid.Column="0"/>



But How to keep track the ListBox that it may contain a few pages of data for printing in a formatted page?

Suppose this formatted XAML Page contain with Grid.Row="0" and Grid.row="1":

1) Grid.Row ="0" : Header for customer info
2) Grid.Row ="1" : Body for Order transaction

The ListBox will be added into Canvas object with Opacity="0"
The ListBox will be populated with data from Local Database.

Questions :

What control is required to keep track if ListBox has more data to print?


<StackPanel x:Name="header" Grid.Row="0" Grid.ColumnSpan="2" Height="60"  Visibility="Collapsed">
       <StackPanel Orientation="Horizontal" >
         <RichTextBlock Foreground="Black" FontSize="20" TextAlignment="Left" FontFamily="Segoe UI">
          <Paragraph>Order- Printing test
          </RichTextBlock>
       </StackPanel>
 </StackPanel>

<StackPanel x:Name="Body" Grid.Row="1" Margin="100,30,106,148">

   <ListBox Height="500" x:Name="Lbx1" Margin="30,3,84,0">
      <ListBox.ItemTemplate>
         <DataTemplate>
             <StackPanel Orientation="Horizontal">

                   <TextBlock FontSize="20" Margin="10,10,30,10">
                    <Run Text="name : "/><Run Text="{Binding ItemName}" />
                   </TextBlock>

                   <TextBlock FontSize="20" Margin="30,10,10,10">
                    <Run Text="code : "/> <Run Text="{Binding ItemCode}" />
                    </TextBlock>

                    <TextBlock FontSize="20" Margin="10">
                     <Run Text="Price : "/> <Run Text="{Binding Price}" />
                    </TextBlock>

                   <TextBlock FontSize="20" Margin="10">
                    <Run Text="Quantity : "/> <Run Text="{Binding Quantity}" />
                   </TextBlock>
              </StackPanel>

            </DataTemplate>
        </ListBox.ItemTemplate>
     </ListBox>            

</StackPanel>

来源:https://stackoverflow.com/questions/18694979/how-to-print-formatted-page-which-contain-listbox-or-gridview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!