c# - Telerik PdfViewer - Binding to a PDF source -
i've tried samples on telerik's website well, , no avail. have code:
public icommand emailpopupcmd { get; set; } private void emailpopup(object sender) { //todo: pdf viewer pop selecteddatarow = (datarow)sender; var window = new window(); window.content = new emailview() { datacontext = this}; //shares same data context memorystream str = new memorystream();//= new memorystream(pdfasbytearray);//new system.uri(@"pack://application:,,,/resources/testpdf.pdf", system.urikind.relativeorabsolute); using(filestream fs = file.openread(@"c:\source\ui.mailviewer\resources\testpdf.pdf")) { str.setlength(fs.length); fs.read(str.getbuffer(),0, (int)fs.length); } attachmentpath = new pdfdocumentsource(str); if (window.showdialog() == true) { //from child parent } }
c:\source\ui.mailviewer\resources\testpdf.pdf pdf located , bind ui follow:
telerik:radpdfviewer x:name="pdfemailviewer" grid.row="2" documentsource="{binding attachmentpath,converter={staticresource debugconverter}}">
now using this, object not set instance error. idea why? using debug converter, value of pdf document created null, why happening?
okay other users, found on telerik forums: (telerik forum link)
there 1 additional thing in order make radpdfviewer work in winforms application: should ensure application.current property initialized before user control initialized, example adding code in constructor of user control:
public pdfviewercontrol() { if (application.current == null) new application(); initializecomponent(); }
this worked me in wpf well.
Comments
Post a Comment