c# - Cannot convert my UserControl to Windows.Forms.Control -


I try to use Acrobat PDF Reader in a WPF app but I found that WindowsFormsHost is a WinForm control. This is the source of the issue ... I have received a message that can be converted to "offlinebox.pdf reader in windows .forms control". Thanks

I have made a mix of these 2 tutorials:

My page to display my usercontrol

  public partial class DidactielPage: window {public DidactielPage () {InitializeComponent (); Var ucPdfReader = New PDF Reader ("/ Resources / Data / Dedicated Offsetlocks PDF"); This.WindowsFormHost1.Child = ucPdfReader; // error message shows here}}  

my user control class

  public partial class PdfReader: UserControl {Public PdfReader (string filename) {InitializeComponent (); AcroPDF acro = new AcroPDF (); Acro.setShowToolbar (wrong); Acro.setview ("FitH"); Acro.loadFile (filename); Acro.src = filename; Acro.setViewScroll ("FITH", 0); }}  

Element host requires Windows form integration.

1) Add a reference to WindowsFormsIntegration, add context to the messages, to find it descriptively, go to NAT and order.

2) Import / Use

  System. Windows.form. use;  

3) Use this sweet little convenience method.

  Private Stable ElementHost createFormHostForWpfElement (UserControl wpfControl) {ElementHost elementHost = New ElementHost (); ElementHost.Child = wpfControl; Return element; }  

4) Now add HostElement to your form.

  this.WindowsFormHost1.Child = createFormHostForWpfElement (ucPdfReader);  

Let me know if it takes care of it for you.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -