Table of Contents
With WPF Project

Follow these steps to use EO.WebBrowser in a Windows Form application in Visual Studio:

  1. Open your WPF project;
  2. Add reference to EO dlls;
  3. If you use .NET Core (including .NET 6 and newer), then add reference to nuget package System.Drawing.Common;
  4. Open a Window in XAML view;
  5. Add "eo" namespace prefix in your XAML file. Simply add the following attribute to your Window or UserControl

    XAML
    xmlns:eo="http://schemas.essentialobjects.com/wpf/"

    For example, your Window element may look like this:

    XAML
    <Window x:Class="Test.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="250" Width="350">

    After adding the "eo" namespace prefix it becomes this:

    XAML
    <Window x:Class="Test.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:eo="http://schemas.essentialobjects.com/wpf/"
            Title="MainWindow" Height="250" Width="350">

    Note the additional "eo" prefix added to the Window element.

  6. Add an "eo:WebControl" element to your Window:

    XAML
    <eo:WebControl>
            <eo:WebControl.WebView>
            <eo:WebView Url="www.google.com">
            </eo:WebView>
        </eo:WebControl.WebView>
    </eo:WebControl>

    Note that the WebControl element must have its WebView property set to a WebView object.

    Alternatively, you can set Url from code:

    XAML
    <eo:WebControl>
            <eo:WebControl.WebView>
            <eo:WebView x:Name="webView1">
            </eo:WebView>
        </eo:WebControl.WebView>
    </eo:WebControl>

    Then you can use webView1 in your code:

    //Load Google's homepage into the WebView
    WebView1.Url = "www.google.com";

Now you can use all EO.WebBrowser features through the WebView object.