开发者

Silverlight 4 datagrid printing

开发者 https://www.devze.com 2023-02-07 11:54 出处:网络
I have a Silverlight 4 app with RIA services. It\'s based on Tim Heuer\'s video and I have pretty much the same setup.

I have a Silverlight 4 app with RIA services. It's based on Tim Heuer's video and I have pretty much the same setup.

I have a DomainDataSource, a set of DomainDataSource.FilterDescriptors, a Datagrid which display 15 items per page with the help of a DataPager. When the user enters their filtering options, the datagrid updates accordingly but is still multiple pages which is okay for viewing on screen. I want to implement a print function that essentially prints the datagrid but all items at once and on multiple pages, if need be.

I have played around with printing basics and I can print the datagrid as it is exactly displayed on screen but I want to be able to print all items.

I'm not finding any good examples开发者_如何学Go on the web. Can anyone suggest an approach to tackle this?

Thanks

Edit: Not sure how helpful it's going to be but here's the XAML outline.

Silverlight 4 datagrid printing


So one problem will be that when the user says they want to print, you'll presumably then want to ensure all the data is on the client (by executing some larger query), but let's assume you've taken care of that and have all the data on the clien and just want to focus on printing now.

In that case, I'd point you to David Poll's excellent additional printing helpers ( blog post here : http://www.davidpoll.com/2010/04/16/making-printing-easier-in-silverlight-4/ ). He provides a library (with full source) that basically takes an ItemsControl (or lots of other things, but ItemsControl is particularly relevant here) and paginates it automatically.

So you'd create a separate UserControl that has a "print view" of your data, which contains a DataGrid not limited to 15 items, removes paging UI, and basically gets everything "print-ready" (sort of like a print CSS sheet if you're familiar with that concept). Just point his library at that print view of your data, with all the data already on the client, and you should be just about all set.

0

精彩评论

暂无评论...
验证码 换一张
取 消