Embedded Web Browser in a WPF Window using webview2

Embedded Web Browser in a WPF Window using webview2

jessewjames.2412
Explorer Explorer
881 Views
6 Replies
Message 1 of 7

Embedded Web Browser in a WPF Window using webview2

jessewjames.2412
Explorer
Explorer

Hi there,

I am trying to create an Addin for Revit which will simply show a WPF window with an embedded web browser.

I'm using webview2 to try and achieve this however I'm encountering an error when testing it in Revit the window displays but is blank and empty. When debugging it does show the web browser to be there  all though its not.

 

When I run the exact same code to create the window with the embedded browser by itself it works it just doesn't work when inside Revit. I've debugged them both at the same time comparing properties to see if theres a difference and there isn't they line up to be the exact same.

 

I've also tried CEFsharp which doesn't work either.


I'm lost for ideas on what to do, try and/or fix to make this work. Any ideas?

 

Cheers,

Jesse

882 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

   The Building Coder just discussed a similar issue:

  

https://thebuildingcoder.typepad.com/blog/2022/10/webview2-landxml-refplane-and-revision.html

  

That discussion includes a working webview2 sample.

  

Other, previous articles on The Building Coder shared working Cefsharp samples.

  

I would suggest using one of the working samples as a basis for your development.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 7

jessewjames.2412
Explorer
Explorer

Hey @jeremy_tammik

 

Thanks for the reply. I've attempted that example previously but its a bit more complicated then what I'm trying to do. I simply want a window in Revit to show google.com

 

My code consists of the base command cs which runs when the button is clicked in Revit that shows my wpf xaml file that holds a WebView element when. When I debug in Revit, I receive no errors and the code even says the WebView element is there however the window only shows a blank window.

jessewjames2412_0-1668140169606.png

 

Cheers, Jesse

0 Likes
Message 4 of 7

jeremy_tammik
Alumni
Alumni

So, there seems to be a choice between getting the complicated sample to work and simplifying it until it meets your needs, or debugging your simple sample until it works. Unfortunately, I have no experience with WPF, so I cannot be of much help in making this choice.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 7

jessewjames.2412
Explorer
Explorer

Thanks for the help anyways!

0 Likes
Message 6 of 7

andrea.tassera
Contributor
Contributor

@jeremy_tammik would it make a difference if we were doing it in WinForm instead? Would it be easier to help us?

0 Likes
Message 7 of 7

jeremy_tammik
Alumni
Alumni

What need is there for help? There is Alexander's working sample out there. Does that not help?

  

https://thebuildingcoder.typepad.com/blog/2022/10/webview2-landxml-refplane-and-revision.html#2.1

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes