【发布时间】:2017-10-24 13:11:52
【问题描述】:
我有一个用户控件,我在其中显示地图和数据网格中的数据。
我尝试了以下代码,但它不起作用。
PrintDialog printDialog = new PrintDialog();
// if user clicks on cancel button of print dialog box then no need to print the map control
if (!(bool)printDialog.ShowDialog())
{
return;
}
else // this means that user click on the print button
{
// do nothing
}
this.Measure(new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight));
this.Arrange(new Rect(new Point(20, 20), new Size(this.ActualWidth, this.ActualHeight)));
// print the map control
printDialog.PrintVisual(this, "Karte drucken");
问题:当数据网格有大量记录时,用户控件获得滚动条,但打印用户控件后,只打印用户控件的可见部分,而不是我们向下滚动后可以看到的数据存在.我想打印用户控件的全部内容。
有什么解决办法吗,我们如何在 wpf 中看到打印预览?
【问题讨论】:
标签: c# wpf printing user-controls