我在更多的迭代中创建FixedDocument (每次迭代一个页面),如下所示:
PrintDialog pr = new PrintDialog();
FixedDocument doc = new FixedDocument();
foreach(var i in a)
{
// some changes of MaingGrid here
...
//
VisualBrush vb = new VisualBrush(this.MainGrid);
FixedPage page = new FixedPage();
page.Width = doc.DocumentPaginator.PageSize.Width;
page.Height = doc.DocumentPaginator.PageSize.Height;
Rectangle rec = new Rectangle();
rec.Width = this.MainGrid.ActualWidth;
rec.Height = this.MainGrid.ActualHeight;
rec.Fill = vb;
page.Children.Add(rec);
PageContent content = new PageContent();
((IAddChild)content).AddChild(page);
doc.Pages.Add(content);
}
pr.PrintDocument(doc.DocumentPaginator, "test");在每次迭代中,我都会稍微修改一下MainGrid。因此,每个页面都应该包含MainGrid的实际状态。但打印的文档包含具有上次迭代相同内容的页面(换句话说,文档中的所有页面都处于最后状态)。对VisualBrush有什么“懒惰的评估”吗?
发布于 2011-11-07 23:06:47
在每次迭代中对VisualBrush调用.Freeze()。否则,它将始终是您指向的任何视觉的实时视图。
编辑:冻结不起作用,但您可以将画笔渲染为静态位图。请参阅http://blog.avanadeadvisor.com/blogs/markti/archive/2008/04/14/10888.aspx
https://stackoverflow.com/questions/8038049
复制相似问题