ResourceHandler can help you to determine whether resources such as HTML, Images, JavaScript & CSS files, favicon, etc. should be loaded or not. By default all resources are loaded. To modify default behavior you need to register your own ResourceHandler implementation. For example:

C#

class SampleResourceHandler : ResourceHandler
{
    public bool CanLoadResource(ResourceParams parameters)
    {
        Console.WriteLine("URL: " + parameters.URL);
        Console.WriteLine("Type: " + parameters.ResourceType);
        bool isImageType = parameters.ResourceType != ResourceType.IMAGE;
        if (isImageType)
        {
            return true; // Cancel loading of all images
        }

        return false;
    }
}

VB.NET

Class SampleResourceHandler
    Implements ResourceHandler

    Public Function CanLoadResource(ByVal parameters As ResourceParams) As Boolean _
        Implements ResourceHandler.CanLoadResource
        Console.WriteLine("URL: " & parameters.URL)
        Console.WriteLine("Type: " & parameters.ResourceType)
        Dim isImageType As Boolean = parameters.ResourceType <> ResourceType.IMAGE

        If isImageType Then
            Return True
        End If

        Return False
    End Function
End Class


This implementation cancels loading of all images. Using same technique you can implement and register your own ResourceHandler where you can cancel loading of required resources.


Example

MainWindow.xaml

<Window x:Class="WPF.ResourceLoading.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" Closing="Window_Closing">
    <Grid Name="mainLayout">

    </Grid>
</Window>


C#

MainWindow.xaml.cs

using System;
using System.IO;
using DotNetBrowser;
using DotNetBrowser.WPF;
using System.Windows;

namespace WPFResourceLoading
{
    public partial class MainWindow : Window
    {
        Browser browser;
        WPFBrowserView browserView;

        public MainWindow()
        {
            InitializeComponent();

            browser = BrowserFactory.Create();
            browserView = new WPFBrowserView(browser);
            mainLayout.Children.Add(browserView);

            NetworkService networkService = browser.Context.NetworkService;
            networkService.ResourceHandler = new SampleResourceHandler();

            browserView.Browser.LoadURL("http://www.teamdev.com");
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Dispose BrowserView when close app window.
            browserView.Dispose();
            browser.Dispose();
        }
    }


    class SampleResourceHandler : ResourceHandler {

        public bool CanLoadResource(ResourceParams parameters) {
            Console.WriteLine("URL: " + parameters.URL);
            Console.WriteLine("Type: " + parameters.ResourceType);
            bool isImageType = parameters.ResourceType != ResourceType.IMAGE;
            if (isImageType) {
                return true;    // Cancel loading of all images
            }
            return false;
        }
    }
}


VB.NET

MainWindow.xaml.vb

Imports DotNetBrowser
Imports DotNetBrowser.WPF

Namespace WPF.ResourceLoading
    Class MainWindow
        Dim browser As Browser
        Dim browserView As WPFBrowserView

        Public Sub New()
            InitializeComponent()
            browser = BrowserFactory.Create()
            browserView = New WPFBrowserView(browser)
            mainLayout.Children.Add(browserView)
            Dim networkService As NetworkService = browser.Context.NetworkService
            networkService.ResourceHandler = New SampleResourceHandler()
            browserView.Browser.LoadURL("http://www.teamdev.com")
        End Sub

        Private Sub Window_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
            browserView.Dispose()
            browser.Dispose()
        End Sub
    End Class

    Class SampleResourceHandler
        Implements ResourceHandler

        Public Function CanLoadResource(ByVal parameters As ResourceParams) As Boolean _
            Implements ResourceHandler.CanLoadResource
            Console.WriteLine("URL: " & parameters.URL)
            Console.WriteLine("Type: " & parameters.ResourceType)
            Dim isImageType As Boolean = parameters.ResourceType <> ResourceType.IMAGE

            If isImageType Then
                Return True
            End If

            Return False
        End Function
    End Class
End Namespace