首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打印FlowDocument +集合

打印FlowDocument +集合
EN

Stack Overflow用户
提问于 2017-03-31 06:51:35
回答 1查看 311关注 0票数 1

我正在打印一个FlowDocument,它由一个ItemsControl组成。如果有必要的话,我想在多个页面上自动拆分它。目前,我不知道为什么它会输出一个空白页。我试着查找类似的问题,尽管他们没有多少我可以利用的信息。

我的FlowDocument看起来是这样的:

代码语言:javascript
复制
<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>

在实例化时设置FlowDocumentFlowDocument,在VM的构造函数中(当前)初始化StringList属性。

代码语言:javascript
复制
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打印机进行测试。

代码语言:javascript
复制
var writer = PrintQueue.CreateXpsDocumentWriter(XPSPrinter);
writer.Write(doc); //IDocumentPaginatorSource...

我做错什么了吗?为什么它不显示ItemsControl +内容?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-03 14:28:43

显然,不支持数据绑定。FlowDocument

我现在放弃这个解决方案/尝试使用一个现有的解决方案(DocumentPaginator)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43134264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档