问题
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