c# - How to remove FixedPage from FixedDocument? -
i using documentviewer display fixeddocument user before allowing user print or save document. have edited documentviewer panel have checkbox allows user select if want chart in document or not.
i able event of checkbox being checked , value cannot figure out way remove chart fixeddocument , not leave blank page @ end. have on checkbox click hide , show chart again leaves blank page.
if (value) barchart.visibility = visibility.visible; else barchart.visibility = visibility.collapsed;
i have tried rebuilding fixeddocument on checkbox event , use checkbox value decide whether or not include graph page. document renders fine first time, after unchecking checkbox chart page disappears, when rechecking checkbox graph page shows graph has no data (series missing).
any ideas?
could problem data binding of chart or issue fixeddocument?
note: building chart in code behind , adding so:
// add other pages reportdocument here if (includegraphpage) { // add graph page pagecontent chartdocumentpagecontent = new pagecontent(); fixedpage chartdocumentpage = new fixedpage(); chartdocumentpage.margin = new thickness(20); chartdocumentpage.children.add(barchart); ((iaddchild)chartdocumentpagecontent).addchild(chartdocumentpage); reportdocument.pages.add(chartdocumentpagecontent); } // set document viewer content documentviewer.document = reportdocument;
i have checked out other questions no solutions have worked me yet.
i able figure out way rebuild fixeddocument without making chart series disappear. key add chart visualbrush so:
visualbrush chartbrush = new visualbrush(barchart) { stretch = stretch.uniform }; rectangle chartrectangle = new rectangle { width = (1056-2*96), height = (816 - 2*96), fill = chartbrush }; chartdocumentpage.children.add(chartrectangle);
Comments
Post a Comment