我正在打印一个FlowDocument,它由一个ItemsControl组成。如果有必要的话,我想在多个页面上自动拆分它。目前,我不知道为什么它会输出一个空白页。我试着查找类似的问题,尽管他们没有多少我可以利用的信息。
我的FlowDocument看起来是这样的:
<FlowDocument x:Class="PrintFlowDocument.Views.GoWithTheFlow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PrintFlowDocument.Views">
<Paragraph>
<ItemsControl ItemsSource="{Binding StringList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" TextWrapping="Wrap"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Paragraph>
</FlowDocument>在实例化时设置FlowDocument的FlowDocument,在VM的构造函数中(当前)初始化StringList属性。
GoWithTheFlow1 flow = new GoWithTheFlow1() { DataContext = new FlowVM() };
flow.PageHeight = 1122.5196850393702;
flow.PageWidth = 793.70078740157476;
//---
ObservableCollection<string> _StringList;
public ObservableCollection<string> StringList
{
get { return _StringList; }
set { if (_StringList != value) { _StringList = value; NotifyPropertyChanged(() => StringList); } }
}为了打印文档,我使用XpsDocumentWriter并将其打印到XPS打印机进行测试。
var writer = PrintQueue.CreateXpsDocumentWriter(XPSPrinter);
writer.Write(doc); //IDocumentPaginatorSource...我做错什么了吗?为什么它不显示ItemsControl +内容?
发布于 2017-04-03 14:28:43
显然,不支持数据绑定。在FlowDocument。
我现在放弃这个解决方案/尝试使用一个现有的解决方案(DocumentPaginator)。
https://stackoverflow.com/questions/43134264
复制相似问题