在允许用户打印或保存文档之前,我使用DocumentViewer向用户显示FixedDocument。我已经编辑了DocumentViewer面板,使其有一个复选框,允许用户选择是否需要文档中的图表。
我能够得到选中复选框的事件及其值,但我想不出一种方法从FixedDocument中删除图表,而不是在最后留下一个空白页。我目前有它,以便在复选框上单击,我隐藏并显示图表,但这再次留下一个空白页。
if (value) BarChart.Visibility = Visibility.Visible;
else BarChart.Visibility = Visibility.Collapsed;我还尝试在复选框事件上重新构建FixedDocument,并使用复选框值来决定是否包含图形页。文档第一次呈现良好,然后取消选中复选框后图表页消失,然后在重新检查复选框时显示图形页,但图形没有数据(序列丢失)。
有什么想法吗?
这是图表的数据绑定问题还是FixedDocument的问题?
注意:我正在后面的代码中构建图表,并将其添加如下:
// Add other pages to ReportDocument here
if (IncludeGraphPage)
{
// Add graph page
PageContent ChartDocumentPageContent = new PageContent();
FixedPage ChartDocumentPage = new FixedPage();
ChartDocumentPage.Margin = new Thickness(20);
ChartDocumentPage.Children.Add(BarChart);
((IAddChild)ChartDocumentPageContent).AddChild(ChartDocumentPage);
ReportDocument.Pages.Add(ChartDocumentPageContent);
}
// Set the document viewer content
DocumentViewer.Document = ReportDocument;我检查了其他问题,但还没有解决办法。
发布于 2017-09-20 16:54:36
我想出了一种重建FixedDocument的方法,而不让图表系列消失。关键是将图表添加为VisualBrush,如下所示:
VisualBrush chartBrush = new VisualBrush(BarChart) { Stretch = Stretch.Uniform };
Rectangle ChartRectangle = new Rectangle { Width = (1056-2*96), Height = (816 - 2*96), Fill = chartBrush };
ChartDocumentPage.Children.Add(ChartRectangle);https://stackoverflow.com/questions/46180456
复制相似问题