如何让 FixedDocument 自动分页?我有以下代码可用于将美化面板放入 DocViewer。当面板超出单个页面时会出现问题。现在,我们只是剪辑。基本上,我想创建一种相当通用的方式来打印用户正在查看的内容。我的做法合理吗?
public void CreateReport(Panel details)
{
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
fixedPage.DataContext = this.DataContext;
fixedPage.Margin = new Thickness(10);
fixedPage.Children.Add(details);
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
// This makes the array of controls invisibile, then climbs the details structure
// and makes the controls within details appropriate for the DocumentViewwer (i.e. TextBoxes are
// non-editable, no borders, no scroll bars, etc).
prePrintPrepare(details, fixedPage, new FrameworkElement[] { controlToMakeInvisible });
_dv = new DocViewer();
_dv.documentViewer1.Document = fixedDoc;
_dv.Show();
}