New to CefSharp I created a class library project and referenced the CefSharp library to display a web browser. However, I have to face some issues showing a web browser. Please find the exact code.
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"; } } }
and I reference this library (dll) in another project
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; } }
Now, by clicking on the "I" button, I will open a child widget (WebBrowser_test1), in which I will show a web browser. When the window opens, it will be empty.
Please let me know if I missed something.
source share