Xamarin.forms Xamarin形成WebView多次触发导航事件

Xamarin.forms Xamarin形成WebView多次触发导航事件,xamarin.forms,android-webview,Xamarin.forms,Android Webview,我有一个带有WebView的简单ContentPage。WebView源已手动设置为“”。结果,我看到导航事件被触发一次,而导航事件被触发三次。我尝试了不同的网站,获得了不同网站的不同数量的导航事件。我试图比较触发的导航事件,以找出中间事件和最终事件之间的任何差异,但没有成功。 我需要捕捉一个事件,当一个网站真的完全加载。如何捕获最终导航事件? MainPage.xaml: <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

我有一个带有WebView的简单ContentPage。WebView源已手动设置为“”。结果,我看到导航事件被触发一次,而导航事件被触发三次。我尝试了不同的网站,获得了不同网站的不同数量的导航事件。我试图比较触发的导航事件,以找出中间事件和最终事件之间的任何差异,但没有成功。 我需要捕捉一个事件,当一个网站真的完全加载。如何捕获最终导航事件? MainPage.xaml:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:d="http://xamarin.com/schemas/2014/forms/design"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         mc:Ignorable="d"
         x:Class="WebTest.MainPage">

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Label HorizontalOptions="Center" x:Name="NavCounterLabel"/>
    <WebView x:Name="WebV"
                HorizontalOptions="FillAndExpand"
                VerticalOptions="FillAndExpand"
                Grid.Row="1"/>
    <ActivityIndicator x:Name="BusyIndicator"
                        HorizontalOptions="Center"
                        VerticalOptions="Center"
                        Color="Red"
                        HeightRequest="50"
                        WidthRequest="50"
                        Grid.Row="1"/>
</Grid>
</ContentPage>

这是我的WebViewPage.xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="IntentoAssociates.WebViewPage">
    <Grid>
        <!-- Place new controls here -->
        <WebView x:Name="WebV"
                 HorizontalOptions="FillAndExpand"
                 VerticalOptions="FillAndExpand" />
        <ActivityIndicator x:Name="BusyIndicator"
                           HorizontalOptions="Center"
                           VerticalOptions="Center"
                           Color="Red"
                           HeightRequest="50"
                           WidthRequest="50" />
    </Grid>
</ContentPage>

我在所有项目中都使用Xamarin Forms 4.1.555618,在加载页面时,它只会启动一次导航

我做了一个和你一样的新项目。我使用的Xamarin版本是4.2.0.709249。当我在WebV_Navigated上设置断点时,我看到它仍然被触发了三次。我尝试将Xamarin.Forms降级到4.1.555618,并得到了相同的结果。在App.xaml.cs中,您是否分配MainPage=new WebViewPage()?我已将WebView添加到主页。在App.xaml.cs中,我有MainPage=newmainpage();
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="IntentoAssociates.WebViewPage">
    <Grid>
        <!-- Place new controls here -->
        <WebView x:Name="WebV"
                 HorizontalOptions="FillAndExpand"
                 VerticalOptions="FillAndExpand" />
        <ActivityIndicator x:Name="BusyIndicator"
                           HorizontalOptions="Center"
                           VerticalOptions="Center"
                           Color="Red"
                           HeightRequest="50"
                           WidthRequest="50" />
    </Grid>
</ContentPage>
using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace IntentoAssociates
{
    public partial class WebViewPage : ContentPage
    {
        public WebViewPage()
        {
            InitializeComponent();
            Title = "Intento Associates";
            BusyIndicator.IsRunning = BusyIndicator.IsVisible = true;
            WebV.Source = "https://www.turkishairlines.com/";
            WebV.Navigating += WebV_Navigating;
            WebV.Navigated += WebV_Navigated;
        }

        private void WebV_Navigated(object sender, WebNavigatedEventArgs e)
        {
            BusyIndicator.IsRunning = BusyIndicator.IsVisible = false;
        }

        private void WebV_Navigating(object sender, WebNavigatingEventArgs e)
        {
            BusyIndicator.IsRunning = BusyIndicator.IsVisible = true;
        }
    }
}