Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

WPF : A True WPF Browser Control That Can Bend It Like Beckham

, 18 Nov 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
A while ago I wanted to use the new .NET 3.5 SP1 WebBrowser control is a small demo WPF app that I was using to display streamed YouTube videos. And guess what, I was way disappointed the supposedly new rad control, was a con and it was actually no better than using a WPF Frame [...]

A while ago I wanted to use the new .NET 3.5 SP1 WebBrowser control is a small demo WPF app that I was using to display streamed YouTube videos. And guess what, I was way disappointed the supposedly new rad control, was a con and it was actually no better than using a WPF Frame object or even hosting the WinForms  WebBrowser control. The reason being that all of these internally are HWnd (therefor different graphics rendering pipeline) controls.

So no matter what you do they will always be square and appear on top of WPF content, which sucks really.

Luckily some clever fellas out there didn’t like this either and came up with some cool C++ dll called Awesomium which you can get over at

http://princeofcode.com/awesomium.php#download

And then to top that off Chris Cavanagh (Physics genius) wrapped it to make it WPF like. He calls this

WPF 3D Chromium Browser

Which you can find over at Chris Cavanaghs site using this Url

http://chriscavanagh.wordpress.com/2009/08/27/wpf-3d-chromium-browser/

Here is a screen shot of it working, You can get a better sample over at Chris’s site

image_thumb1.png

The entire XAML looks like this

<Window x:Class="BrowserApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="500" Width="500"
        xmlns:chr="clr-namespace:Cjc.ChromiumBrowser;assembly=Cjc.ChromiumBrowser">

    <Grid>

    <chr:WebBrowser x:Name="browser" IsEnabled="False"
                Width="300" Height="300"
                EnableAsyncRendering="False"
                RenderTransformOrigin="0.5,0.5">
            <chr:WebBrowser.RenderTransform>
                <TransformGroup>
                    <ScaleTransform CenterX="0.5" CenterY="0.5"
                                    ScaleX="0.75" ScaleY="0.75"/>
                    <SkewTransform AngleX="15" AngleY="15"/>
                </TransformGroup>
            </chr:WebBrowser.RenderTransform>

        </chr:WebBrowser>

    </Grid>
</Window>

As usual here is a small demo app .

http://sachabarber.net/wp-content/uploads/2009/11/Browser.zip

I should point out that it is Visual Studio 2010 and as such I had to set the following up in my App.Config to get it to work:

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
 
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
 
Both of these at Sussex University UK.
 
Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

Comments and Discussions

 
QuestionUsing wpf chromium browser in VS 2012 .net framework 4.5 Pinmemberchirag_gupta28-Jun-13 3:21 
QuestionAnything new ? PinmemberBizounours19-Aug-10 6:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411019.1 | Last Updated 18 Nov 2009
Article Copyright 2009 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid