WPF 工具包数据网格
我想在 XPS 文档中显示数据网格内容(行、列)。我有 20 列。 当我使用 XPSDocumentWriter.Write 方法将 datagrid 发送到 XPS 时,它只显示一些列而不是全部。我如何在 xps 中显示所有列和行(如 Xceed datagrid xps 导出)
谢谢
I want to show datagrid content (rows,columns) in XPS document.I have 20 columns. When i sent datagrid to XPS with XPSDocumentWriter.Write method ,it just show some columns not all of them.How can i show all columns and rows in xps(like Xceed datagrid xps exporting)
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可能在于网格宽度与 XPSDocumentWriter 页面大小的关系。
WPF 将按原样将您提供的元素写入文档中。 这意味着它不会以任何方式缩放以适应页面的内容。
假设您的文档大小正确(假设是字母),您需要确定文档的可打印区域,并在将其写入 XPSDocumentWriter 之前将 RenderTransform 应用于网格。
执行此操作的代码如下所示:
编辑:更改了代码,以便 ScaleX 和 ScaleY 都指向使网格完全适合 XpsDocument 所需的量
The problem is probably with the width of your grid in relation of the XPSDocumentWriter's pagesize.
WPF will write in the Document the element you provide as is. That means that it will not be scaled in any way to fit the content of the page.
Assuming your document is the correct size (lets suppose letter), you need to determine the printable area of the document and apply a RenderTransform to the grid before you write it into the XPSDocumentWriter
The code to do it would be something like:
EDIT: Changed the code so that both the ScaleX, and ScaleY point to the amount required to make the grid fit completely in the XpsDocument