protected override void OnElementChanged(ElementChangedEventArgs <HybridWebView> e) { if (Control == null) { Chromium.Initialize(); Forms.Context.Terminated += (sender, args) => Chromium.Shutdown(); var webView = new WebView(Forms.NativeParent); webView.GetSettings().JavaScriptEnabled = true; webView.LoadFinished += OnWebLoadCompleted; SetNativeControl(webView); } if (e.OldElement != null) { var hybridWebView = e.OldElement as HybridWebView; hybridWebView.Cleanup(); } if (e.NewElement != null) { Control.AddJavaScriptMessageHandler("jsBridge", OnScriptMessage); Control.LoadUrl($"file://{ResourcePath.GetPath(Element.Uri)}"); } base.OnElementChanged(e); }
protected override void OnTerminate() { Chromium.Shutdown(); base.OnTerminate(); }