WPF - FlowDocument - 将表拉伸到整个宽度?
我有一个包含任意数量的列和行的数据表,我正在尝试打印它们。到目前为止,我所拥有的最好的运气是将数据放入表中,然后将该表添加到 FlowDocument 中。
到目前为止,一切都很好。我现在遇到的问题是表格只“想要”占据文档宽度的大约一半。我已经为 FlowDocument 的 PageWidth 和 ColumnWidth 属性设置了适当的值,但表似乎不想拉伸以填充分配的空间?
I have a DataTable containing an arbitrary number of columns and rows which I am trying to print out. The best luck I've had so far is by putting the data into a Table and then adding the table to a FlowDocument.
So far so good. The problem I have right now is that the Table only "wants" to take up about half of the document's width. I've already set the appropriate values for the FlowDocument's PageWidth and ColumnWidth properties, but the Table doesn't seem to want to stretch to fill up the allotted space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了将 FlowDocument 内容设置为完整可用宽度,您必须首先知道页面的宽度。您需要设置的用于处理内容长度的属性是 FlowDocument 上的 ColumnWidth 属性。
我通常创建一个“PrintLayout”帮助程序类来保留页面宽度/高度和填充的已知预设。您可以从 Ms Word 中嗅探预设并填充更多。
PrintLayout 类
设置预设
接下来,您可以在 FlowDocument 上在 Xaml 上
通过代码
In order to set your FlowDocument contents to the full available widh you must first know the width of the page. The property you need to set that takes care of the content length is the ColumnWidth prop on the FlowDocument.
I usualy create a "PrintLayout" helper class to keep known presets for the Page width/hight and Padding. Wou can snif presets from Ms Word and fill more.
The class for PrintLayout
next on your FlowDocument you can set the presets
On Xaml
By code
我对此很幸运:如何设置原始内容WPF FlowDocument 的宽度,尽管它只占用了大约 90% 的空间。
I had some luck with this: How to set the original width of a WPF FlowDocument, although it only took up about 90% of the space.