是CefSharp的新手
我创建了一个类库项目并引用了CefSharp库来呈现Web浏览器,但是我面临一些显示Web浏览器的问题.请找到确切的代码
WebBrowser_test1:
public partial class ChildWidget : Window
{
public CefSharp.Wpf.ChromiumWebBrowser webView;
public Widget()
{
InitializeComponent();
CefSharp.CefSettings settings = new CefSharp.CefSettings();
settings.PackLoadingDisabled = true;
if (CefSharp.Cef.Initialize(settings))
{
webView = new CefSharp.Wpf.ChromiumWebBrowser();
main_grid.Children.Add(webView);
webView.Address = "http://www.google.co.uk";
}
}
}
我在另一个项目中引用这个库(dll)
public MainWindow()
{
InitializeComponent();
Button newbutton = new Button();
newbutton.Width = 50;
main_grid.Children.Add(newbutton);
newbutton.Click += ButtonClick;
}
private void ButtonClick(object sender, RoutedEventArgs e)
{
try
{
Webbrowser_test1.ChildWidget childWidget = new Widget();
childWidget.Show();
}
catch (Exception)
{
throw;
}
}
现在点击按钮,我将打开(WebBrowser_test1)子窗口小部件,我将在其中显示Web浏览器..当窗口打开时,它显示为空白.
如果我遗漏任何东西,请告诉我