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);
        }
Exemple #2
0
 protected override void OnCreate()
 {
     base.OnCreate();
     Chromium.Initialize();
     // Create webview and toolbox
     CreateUI();
 }