UWP 解决Webview在Pivot里面无法左右滑动的问题

                //为了解决webview在PivotItem里面,阻止pivot左右滑动。
                if (webView != null)
                {
                    rootGrid.Children.Remove(webView);
                    webView.NavigationCompleted -= webView_NavigationCompleted;
                    webView.NavigationFailed -= webView_NavigationFailed;
                    webView.NavigationStarting -= webView_NavigationStarting;
                    webView.DOMContentLoaded -= webView_DOMContentLoaded;
                    webView.ScriptNotify -= webView_ScriptNotify;
                }

                webView = new WebView(WebViewExecutionMode.SameThread);
                webView.SetValue(Grid.RowProperty, 2);
                webView.Visibility = Visibility.Collapsed;
                webView.NavigationCompleted += webView_NavigationCompleted;
                webView.NavigationFailed += webView_NavigationFailed;
                webView.NavigationStarting += webView_NavigationStarting;
                webView.DOMContentLoaded += webView_DOMContentLoaded;
                webView.ScriptNotify += webView_ScriptNotify;
                rootGrid.Children.Add(webView);

标红的部分是必须的。解决方案就是手动加入webview并且使用

WebViewExecutionMode.SameThread
posted @ 2016-03-23 15:35  法的空间  阅读(536)  评论(3编辑  收藏  举报