打印 FlowDocument + 集合
Print FlowDocument + Collection
我正在尝试打印由 ItemsControl
组成的 FlowDocument
。如有必要,我想在多个页面上自动拆分它。目前我不确定它为什么会输出空白页。我试图查找类似的问题,尽管它们没有太多我可以利用的信息。
我的 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
的 DataContext
在实例化时设置,StringList
属性(当前)在 VM 的构造函数中初始化。
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 + 内容?
显然,FlowDocument
中有no support for data-binding。
我要放弃这个 solution/try 并暂时使用现有的解决方案 (DocumentPaginator
)。
我正在尝试打印由 ItemsControl
组成的 FlowDocument
。如有必要,我想在多个页面上自动拆分它。目前我不确定它为什么会输出空白页。我试图查找类似的问题,尽管它们没有太多我可以利用的信息。
我的 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
的 DataContext
在实例化时设置,StringList
属性(当前)在 VM 的构造函数中初始化。
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 + 内容?
显然,FlowDocument
中有no support for data-binding。
我要放弃这个 solution/try 并暂时使用现有的解决方案 (DocumentPaginator
)。