Getting CEFSharp to work in WPF using XAML

I had a request for how to get CEFSharp working by calling it straight from XAML. This post assumes that you have read my other post. In order to get the XAML component working you need to add the files as before to your output “Debug” and “Release” directories (see other post for how to do this).

Once you have done this then follow the steps below:

1/ Add in the references (as in previous project) by Right-Clicking on the “References” section of the project and then “Add Reference…”. You will also need to add in the “locales” folder to your output directories or you will get an error (mine was a VSHost.exe crash but yours may differ)

2/ Select the “Browse” tab and select the two CEFSharp files you have just added:

Adding Reference to CEFSharp

Adding a reference to CEFSharp using the “Add Reference” dialog

3/Goto the XAML page you wish to add a CEFSharp browser to and insert a reference to the name space (NB. I did get an error appear in the “Error List” at this point and I suspect you will to. Ignore this for now.):


How to add the CEFSharp namespace to the XAML file.


4/ To instantiate an actual control simply add the following:


How to add in an instance of the CEFSharp control to XAML

 <cefSharp:WebView Grid.Row=”0″

I got errors listed in the output window but if you hit Run it should load up a window like this:


The results of the smallest possible code to add CEFSharp via XAML

From here you should be able to use it with all the usual commands. For more information on CEFSharp please visit the CEFSharp GitHub page. If you have any requests please contact me in the comments.

Posted in CEFSharp, Software Tagged with: , ,

Leave a Reply

Phil's Tweets