【问题标题】:Xamarin Forms Webview Navigated EventXamarin Forms Webview 导航事件
【发布时间】:2018-02-19 18:33:45
【问题描述】:

我有一个 PCL 项目,最近将 Xamarin 表单更新到版本 2.3.4.270,但似乎在更新到此版本后,webview.navigated() 事件不会触发。

var browser = new BaseUrlWebView (); 
var htmlSource = new HtmlWebViewSource ();

    htmlSource.Html = @"<html>
        <head>
        <link rel=""stylesheet"" href=""default.css"">
        </head>
        <body>
        <h1>Xamarin.Forms</h1>
        <p>The CSS and image are loaded from local files!</p>
        <img src='XamarinLogo.png'/>
        <p><a href=""local.html"">next page</a></p>
        </body>
        </html>";

    htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();

    browser.Navigated += (sender, e) => {
        this.DisplayAlert("Navigated", "Navigated the page", "Cancel");
    };

    browser.Source = htmlSource;


    Content = browser;

【问题讨论】:

    标签: xamarin xamarin.forms


    【解决方案1】:
    var browser = new BaseUrlWebView ();
    var htmlSource = new HtmlWebViewSource ();
    
    htmlSource.Html = @"Some HTML";
    htmlSource.BaseUrl = DependencyService.Get<IBaseUrl> ().Get ();
    browser.Source = htmlSource;
    browser.Navigated += WebViewOnNavigated;
    Content = browser;
    
    private async void WebViewOnNavigated(object sender, WebNavigatedEventArgs e){
    
         await DisplayAlert("Navigated", "Navigated the page", "Cancel");
    }
    

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 2018-07-22
      • 1970-01-01
      • 2018-12-01
      • 2020-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      相关资源
      最近更新 更多