title: Add a PDF viewer to a WPF application
body: <p>I am new to WPF, and am trying to add a PDF viewer to my WPF application, but can't seem to work out how to do it... I have tried following a couple of tutorials/ examples that I have found online, but they don't seem to work for me for varying reasons...</p>
  <p>For example, I tried following the tutorial at: <a href="https://documentation.devexpress.com/#WPF/CustomDocument114328" rel="noreferrer">https://documentation.devexpress.com/#WPF/CustomDocument114328</a>
  to add a PDF Viewer at Design Time- it says to</p>
  <blockquote>
  <p>drag the PdfViewerControl from the DX.15.2: Data &amp; Analytics Toolbox tab and drop it onto the main window</p>
  </blockquote>
  <p>However, I don't seem to have a <code>Data &amp; Analytics</code> tab in the toolbox... there's a <code>Data</code> tab, but that just has items like Pointer, Chart, ListView, etc. Is there something I need to do to add/ enable the  <code>Data &amp; Analytics</code> toolbar in Visual Studio?</p>
  <p>I tried following the tutorial at:
  <a href="https://documentation.devexpress.com/#WPF/CustomDocument114329" rel="noreferrer">https://documentation.devexpress.com/#WPF/CustomDocument114329</a> to add a PDF Viewer via code- it says to</p>
  <blockquote>
  <p>Open the Solution Explorer, right-click References and choose Add Reference... to add the PDF Viewer Library.</p>
  <p>Then, locate the DevExpress.Data.v15.2, DevExpress.Pdf.v15.2.Core, DevExpress.Xpf.DocumentViewer.v15.2.Core, and DevExpress.Xpf.PdfViewer.v15.2 assemblies and activate their check boxes.</p>
  </blockquote>
  <p>But when I go to <code>Add Reference</code>, I can't find the assemblies it mentions anywhere, and if I 'search' for them, no items are found...</p>
  <p>Am I missing an <code>include</code>, or do I need to import some libraries from somewhere or something in order to use these?</p>
  <p>Another one I have tried is: <a href="http://www.codeproject.com/Articles/380019/Using-Adobe-Reader-in-a-WPF-app" rel="noreferrer">http://www.codeproject.com/Articles/380019/Using-Adobe-Reader-in-a-WPF-app</a> which says:</p>
  <blockquote>
  <p>Once this control is added to the project, the Windows Forms Designer should be open with a blank canvas. You will need to open the tool box (CTRL + W, X). As a first step it is a good idea to add a new tab for custom controls- this is an option from the context menu on the toolbox. With this new tab expanded, select “choose items” from the context menu. When the Choose Toolbox Items dialog appears, select the COM Components tab and select Adobe PDF Reader (this will add the AcroPDF.DLL to the toolbox).</p>
  </blockquote>
  <p>But I can't seem to find the <code>Choose Toolbox Items</code> or <code>COM Components</code> it talks about...</p>
  <p>Can anyone point me to a clearer tutorial, or explain how I would add a PDF viewer to my WPF application? I am using Visual Studio 2015.</p>
  <p><strong>Edit</strong></p>
  <p>I have tried to display the PDF file inside my application window, by doing the following:</p>
  <p>Adding a <code>&lt;Grid&gt;</code> to display the PDF to the GUI in the XAML:</p>
  <pre><code>&lt;StackPanel&gt;
      &lt;Grid x:Name=&quot;browserHost&quot; Height=&quot;300&quot; Width=&quot;525&quot; Margin=&quot;0,0,0,0&quot;&gt;&lt;/Grid&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  <p>Adding a <code>WebBrowser</code> to the <code>&lt;Grid&gt;</code> in the C#, and pointing that to the location of the PDF I want to display:</p>
  <pre><code>        System.Windows.Controls.WebBrowser browser = new System.Windows.Controls.WebBrowser();
  
  public MainWindow()
      {
          InitializeComponent();
  
          try
          {
              //browser.Navigate(&quot;C:\\...\\sample.pdf&quot;);
              browserHost.Children.Add(browser);
  
              //browser.Visible = true;
              browser.Navigate(&quot;C:\\...\\sample.pdf&quot;);
              browserHost.Opacity = 200;
          }catch(Exception e)
          {
              Console.WriteLine(&quot;browser is visible/ not: &quot; + browserHost.Visibility);
          }
      }
  
      private void Window_Loaded_1(object sender, RoutedEventArgs e)
      {
          /*Create the interop host control */
          //System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowFormsHost();
  
          /*Create the MaskedTextBox control */
          //browser.Navigate(&quot;C:\\...\\sample.pdf&quot;);
          //host.Child = browser;
          browserHost.Children.Add(browser);
      }
  </code></pre>
  <p>But currently, when I run my application, as soon as it loads, the <code>browser</code> that I've added to it displays a page that says:</p>
  <blockquote>
  <p>Navigation to the webpage was canceled</p>
  </blockquote>
  <p>and a dialog box pops up asking me if I want to open or save the file (<code>sample.pdf</code> - the one I'm trying to display in the browser)...</p>
  <p>Why is it trying to download the file, rather than display it? How can I get the <code>browser</code> to display the file instead of trying to download it? Or should I be using something other than a <code>System.Windows.Controls.WebBrowser</code> here?</p>