The following sample code demonstrates how to create WPF Browser instance, embed it into a Window and load http://www.google.com URL. More details about configuring the sample can be found in the Quick Start Guide.


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




Pure XAML Approach


The following sample code inserts a BrowserView that will be working in the lightweight rendering mode and specifies the initial URL for it:


<Window x:Class="DotnetBrowserTransparencySample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DotnetBrowserTransparencySample"
        xmlns:wpf="clr-namespace:DotNetBrowser.WPF;assembly=DotNetBrowser"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" >
    <Grid>
        <wpf:WPFBrowserView Name="Browser" URL="google.com" BrowserType="LIGHTWEIGHT"/>
    </Grid>
</Window>


Embedding from the Code

MainWindow.xaml

<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>

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(BrowserFactory.Create());
            mainLayout.Children.Add((UIElement)webView.GetComponent());
            webView.Browser.LoadURL("http://www.google.com");
        }
    }
}

VB.NET

MainWindow.xaml.vb

Imports DotNetBrowser
Imports DotNetBrowser.WPF

Class MainWindow
    Private webView As BrowserView

    Public Sub New()

        InitializeComponent()

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

    End Sub
End Class