Search code examples
c#wpfgeckofx

Add a GeckoFX WPF browser to a grid's children


The plan is to render some exported 3D Marmoset viewer scene using geckofx that was downloaded as a nu-get package in VS. I coded it like this:

var targetGrid = (parent as BrowseWares).ViewerGrid;

var viewer = new GeckoWebBrowser();
viewer.LoadHtml("dumbbell.html",
       "C:\\Users\\agoston\\Documents\\Visual Studio 2015\\Projects\\HP_hf_shop\\HP_hf_shop\\HTML\\dumbbell.html");
targetGrid.Children.Add(viewer);

But the problem is that GeckWebBrowser is not a UIElement. How to correctly use the URL and how to put it inside of that grid?


Solution

  • Probably GeckoWebBrowser is a Windows Form component. Host it in a WindowsFormsHost.

    Something like:

    WindowsFormsHost whost = new WindowsFormsHost(); 
    GeckoWebBrowser browser = new GeckoWebBrowser();
    whost.Child = browser; 
    targetGrid.Children.Add(whost);