当我执行我的打印功能时,它只打印一页信息,第二页是空的。如果我一次打印一个用户控件,它可以工作。请问如何获取第二个用户控件打印信息呢?
单一控制(工作)
<ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Visibility="{Binding FedNorReportVisibility, Mode=TwoWay}">
<StackPanel>
<panes:PerformanceReportPage1 x:Name="FedNorReportGrid"></panes:PerformanceReportPage1>
</StackPanel>
</ScrollViewer>
两个控制器(不起作用)
<ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Visibility="{Binding FedNorReportVisibility, Mode=TwoWay}">
<StackPanel>
<panes:PerformanceReportPage1 x:Name="FedNorReportGrid"></panes:PerformanceReportPage1>
<panes:PerformanceReportPage2 x:Name="FedNorReportGrid2"></panes:PerformanceReportPage2>
</StackPanel>
</ScrollViewer>
打印功能:
using (var doc = new XpsDocument("C:\\Users/UNKNOWN/Test2.xps", FileAccess.Write))
{
var writer = XpsDocument.CreateXpsDocumentWriter(doc);
var collator = writer.CreateVisualsCollator();
collator.BeginBatchWrite();
collator.Write(FedNorReportGrid);
collator.Write(FedNorReportGrid2);
collator.EndBatchWrite();
}
var doc2 = new XpsDocument("C:\\Users/UNKNOWN/Test2.xps", FileAccess.Read);
var seq = doc2.GetFixedDocumentSequence();
var window = new Window();
window.Content = new DocumentViewer {Document = seq};
window.ShowDialog();
有点奇怪。我可以打印第一个“Pane”的两页。第二个窗格不会显示我尝试的任何内容。使用
collator.Write(FedNorReportGrid);
collator.Write(FedNorReportGrid);
答案 0 :(得分:0)
这有多愚蠢....如果我将每个窗格封装在他们自己的StackPanel中,它就可以工作....
<StackPanel>
<StackPanel>
<panes:PerformanceReportPage1 x:Name="FedNorReportGrid"></panes:PerformanceReportPage1>
</StackPanel>
<StackPanel>
<panes:PerformanceReportPage2 x:Name="FedNorReportGrid2"></panes:PerformanceReportPage2>
</StackPanel>
</StackPanel>