c# - Can't see complete stackpanel in printout -
i've been trying print out data column headers using stackpanels working , printout. problem stackpanel gets cut off after fixed width , i'm not sure property responsible it. it's printer sees rectangular limit on stackpanel has width shorter stackpanel , prints in rectangle. can't explain without picture don't have scanner.
heres code it:
private void btnprint_click(object sender, routedeventargs e) { printdialog dialog = new printdialog(); if (dialog.showdialog().getvalueordefault()) { list<result> results = vm.obsresults.orderbydescending(r => convert.todouble(r.schedulingrate)).tolist(); var proplist = typeof(result).getproperties().tolist(); int maxrowsperpage = 42; var pgcnt = results.count / maxrowsperpage; xpsdocumentwriter docwriter = printqueue.createxpsdocumentwriter(dialog.printqueue); printticket ticket = new printticket(); ticket.pageorientation = pageorientation.landscape; (int pgnum = 0; pgnum <= pgcnt; pgnum++) { //title canvas c = new canvas(); c.width = 1024; c.height = 768; textblock tbtitle = new textblock(); tbtitle.text = " results " + vm.obsdate.tostring("mm/dd/yyyy"); tbtitle.fontsize = 16; canvas.setleft(tbtitle, 20); canvas.settop(tbtitle, 10); c.children.add(tbtitle); //column headers stackpanel sp = new stackpanel() { orientation = orientation.horizontal , width = 885}; sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "unit name", width = 150, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "unit id", width = 65, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "schedule", width = 65, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "tps", width = 25, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "tts", width = 35, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "min run", width = 50, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "schd rt", width = 50, background = new solidcolorbrush(colors.lightblue) }}); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "mw", width = 35, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "00", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "01", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "02", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "03", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "04", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "05", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "06", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "07", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "08", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "09", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "10", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "11", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "12", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "13", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "14", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "15", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "16", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "17", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "18", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "19", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "20", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "21", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "22", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 0, 1), child = new textblock() { text = "23", width = 15, textalignment = textalignment.center, background = new solidcolorbrush(colors.lightblue) } }); sp.children.add(new border() { borderbrush = new solidcolorbrush(colors.lightgray), borderthickness = new thickness(1, 1, 1, 1), child = new textblock() { text = "constraint", width = 100, background = new solidcolorbrush(colors.lightblue) } }); canvas.setleft(sp, 20); canvas.settop(sp, 35); c.children.add(sp); int idxstart = pgnum * maxrowsperpage; int idxend = math.min(results.count, idxstart + maxrowsperpage); int topmargin = 3; } c.measure(new size(int32.maxvalue, int32.maxvalue)); c.arrange(new rect(new point(0, 0), c.desiredsize)); fixedpage fxdpg = new fixedpage(); fxdpg.children.add(c); pagecontent pgcontent = new pagecontent(); ((iaddchild)pgcontent).addchild(fxdpg); fxddoc.pages.add(pgcontent); } docwriter.writeasync(fxddoc, ticket); } }
it looks gets cut off:
00 | 01 | 02 | ... |18 | 19 | 2/ <cut off.
no 21, 22, 23, headers.