我嘗試在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