In this Quick Start Guide you will learn how to download the DotNetBrowser library, get an evaluation licence, and create, configure and run your first .NET WPF Application which loads and displays the www.google.com web page.


Environment: 

Windows 7, Microsoft Visual Studio 2013, .NET Framework 4.5.


The sample solution that demonstrates how to embed lightweight or heavyweight controls into WPF applications can be downloaded here. The projects in this solution have NuGet dependencies, which will be resolved automatically during build.


1. Download the Library


To download DotNetBrowser library go to http://www.teamdev.com/dotnetbrowser and click the Download button. Extract the downloaded dotnetbrowser.zip archive into the D:\Projects\DotNetBrowser\ directory


2. Download the Licence


To get a free 30-day evaluation licence please fill the web form and click the Evaluate button. You will receive an email with a link. Use this link to download your evaluation licence (teamdev.licenses). Save the licence file in the D:\Projects\DotNetBrowser\Library\ directory.


3. Create a WPF Application


Create a new WPF.DotNetBrowser WPF Application C# Project or WPF Application Visual Basic Project in the D:\Projects\DotNetBrowser directory:


DotNetBrowser – Create WPF Application


4. Add DotNetBrowser.dll


In Solution Explorer right-click References and select the Add References... menu item:




In the opened Reference Manager dialog click the Browse... button:




Select the D:\Projects\DotNetBrowser\Library\DotNetBrowser.dll file and click Add :




Click OK:



DotNetBrowser.Chromium.dll is found automatically if it is located in the same folder, near DotNetBrowser.dll. But you may add it to your references too, especially if the project deployment is done using Visual Studio means. Both of these assemblies are required to be present.


5. Add your Licence


In Solution Explorer right-click WPF.DotNetBrowser and select Add — Existing Item...:




In the File Open dialog select the D:\Projects\DotNetBrowser\Library\teamdev.licenses file and click Add:




In Solution Explorer right-click teamdev.licenses and select Properties:




In the Properties panel change Build Action to Embedded Resource:



6. Change the Source Code


Insert the following code into the MainWindow.xaml file:

 

<Window x:Class="WPF.DotNetBrowser.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid Name="mainLayout">

    </Grid>
</Window>

  

7.a C# .NET


MainWindow.xaml.cs

    

using DotNetBrowser;
using DotNetBrowser.WPF;

namespace WPF.DotNetBrowser
{
    public partial class MainWindow : Window
    {
        BrowserView webView;

        public MainWindow()
        {
            InitializeComponent();

            webView = new WPFBrowserView();
            mainLayout.Children.Add((UIElement)webView.GetComponent());
            webView.Browser.LoadURL("http://www.google.com");
        }
    }
}

    

7.b Visual Basic .NET


MainWindow.xaml.vb

  

Imports DotNetBrowser
Imports DotNetBrowser.WPF

Class MainWindow
    Private webView As BrowserView

    Public Sub New()

        InitializeComponent()

        webView = New WPFBrowserView()
        mainLayout.Children.Add(webView.GetComponent())
        webView.Browser.LoadURL("http://www.google.com")

    End Sub
End Class

   

8. Run the Application


To run the application press F5 or click the Start button in the toolbar. If you have done everything correctly then you will see the following: