locked
Printing a databound grid/table RRS feed

  • Question

  • Hi,

    I need to print a business report from a Win8 App. The report contains a multi-column table filled with some details. I need to create the table (with all the edges just like a grid) and fill out the cells with data.

    I know how to create the report in Win8 App and how to bind data. The question is what control I should use to create the grid-like table? I have tried ListBox and ListView but they do not render well when printed and they do not have the edges.

    Any suggestions?

    Thanks,

    Leszek

     


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Tuesday, August 27, 2013 7:00 PM

Answers

All replies

  • ListBox or ListView with an appropriate template are the closest you'll get to an in-box control which looks like a grid. You can style each row to fill out its columns in a grid-like way, or you can be more freeform if that matches the data better.

    What specific problems do you have with printing them?

    --Rob

    Wednesday, August 28, 2013 12:44 AM
    Moderator
  • There are two main problems with the ListBox and ListView:

    - Paging - the ListBox and ListView span multiple pages. In order to calculate the number of pages and create a print preview I need to have more control over what is rendered.

    - ListBox and ListView are UI controls designed for touch - the items have wide padding and margins. I tried to customize the list items using templates but the padding and margins remain.

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Wednesday, August 28, 2013 4:35 AM
  • This is a real-life project. I had to proceed and I found a solution on the Internet.

    - Paging: this great article has a solution: http://blogs.u2u.be/diederik/post/2013/05/21/Printing-a-XAML-ItemsControl-from-a-Windows-8-Store-app.aspx

    - ListBox/ListView formatting: use the ItemsControl instead.

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com


    • Edited by ata6502 Wednesday, August 28, 2013 7:18 PM
    • Marked as answer by Anne Jing Tuesday, September 3, 2013 1:25 PM
    Wednesday, August 28, 2013 7:17 PM