我尝试在WPF应用程序中使用Acrobat PDF阅读器,但发现WindowsFormsHost是WinForm控件...因此它可能是问题的根源... I在指定的行中收到消息“无法将OphtalBox.PDFReader转换为Windows.Forms.control”。由于无法将我的UserControl转换为Windows.Forms.Control
我做这2个教程的混合:
http://www.codeproject.com/Articles/380019/Using-Adobe-Reader-in-a-WPF-app
我的页面,以显示我的用户
public partial class DidactielPage : Window
{
public DidactielPage()
{
InitializeComponent();
var ucPdfReader = new PdfReader("/Resource/Data/DidacticielOphtalBoX.pdf");
this.WindowsFormHost1.Child = ucPdfReader;// the error message shows here
}
}
我的用户
类public partial class PdfReader : UserControl
{
public PdfReader(string filename)
{
InitializeComponent();
AcroPDF acro = new AcroPDF();
acro.setShowToolbar(false);
acro.setView("FitH");
acro.LoadFile(filename);
acro.src = filename;
acro.setViewScroll("FitH", 0);
}
}
当您的PdfReader是WPF UserControl时,为什么要使用WindowsFormsHost?这没有意义。 – Clemens 2014-10-17 11:35:59
那么有什么意义?因为这是在WPF教程中完成的工作:http://www.screencast.com/t/JXRhGvzvB – 2014-10-17 11:39:10
将PdfReader直接放入其中一个常用的WPF面板中,例如,一个网格? – Clemens 2014-10-17 11:49:08