UWP app webview获取url并在导航开始时附加params

时间:2017-11-11 12:50:17

标签: c# uwp

我正在使用onCreate()网络应用。我只显示recyclerViewExibirPosts = (RecyclerView)view.findViewById(R.id.listViewExibirPosts); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); recyclerViewExibirPosts.setLayoutManager(layoutManager); recyclerViewExibirPosts.setHasFixedSize(true); 。我想要的是每当有转换/导航时我想在Universal Windows Platform内附加一些带有URL的参数或者附加参数的位置。感谢帮助

1 个答案:

答案 0 :(得分:1)

这已经解决,可以检查URL是否具有指定的参数。然后取消导航并提供新的URL

 private void OnNavigationStaring(WebView sender, WebViewNavigationStartingEventArgs args)
    {
        if(!workingProgressRing.IsActive && (workingProgressRing.Visibility != Visibility.Visible)){
            this.ShowHideUiControls(true);
        }

        if (!args.Uri.ToString().Contains("yourcheck"))
        {
            args.Cancel = true;
            string url_new = args.Uri.ToString() + "&" + myDetails[0] + "&" + myDetails[1] + "&" + myDetails[2];

            webView.Navigate(new Uri(url_new, UriKind.Absolute));
        }
        Debug.WriteLine("Navigation Starting",args.Uri.ToString());
    }