CefSharp ChromiumWebBrowser - not displayed/rendered

久未见 提交于 2019-12-12 03:38:05

问题


I have a simple application, a Grid with a ChromiumWebBrowser inside. When I create the ChromiumWebBrowser in XAML, it works. But when I create it from the code-behind and add it to the grid, it doesn't show up - I just get the Grid's black background.

<!--This works-->
<Grid Name="gRight" Background="Black">
    <cefSharp:ChromiumWebBrowser x:Name="cefBrowser" Margin="0,20,0,0"  Address="http://www.google.com" />
</Grid>

The code that doesn't work :

public Window1()
{
     InitializeComponent();
     bool status =CefSharp.Cef.Initialize();
     ChromiumWebBrowser browse = new ChromiumWebBrowser();
     browse.Load("http://www.google.com");
     browse.Width = 500;
     browse.Height = 500;
     browse.Margin = new Thickness(0,20,0,0);
     gRight.Children.Add(browse); // adding to Grid, it doesn't show up    
}

Does anyone know why adding from the code-behind doesn't work in this case ?

来源:https://stackoverflow.com/questions/38278187/cefsharp-chromiumwebbrowser-not-displayed-rendered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!