首页 > 解决方案 > 如何在 Android 上的 Xamarin.Forms.Shell 应用程序中的 TabBar 更改后防止 WebView 重新加载?

问题描述

我在一个Xamarin.Forms.Shell包含 4 个标签的应用程序上工作。其中一个选项卡包含WebView允许用户通过提供者提供的 URL 安排约会。

AppShell.xaml看起来像这样(所有图标都用 设置)FontImageSource

<TabBar x:Name="appTabBar">
    <ShellContent x:Name="tabBarHome" Title="Home" Route="HomePage" ContentTemplate="{DataTemplate local:HomePage}" />
    <ShellContent Title="News" ContentTemplate="{DataTemplate local:NewsPage}" />
    <ShellContent Title="Booking" Route="BookingPage" ContentTemplate="{DataTemplate local:BookingPage}" >
        <ShellContent.Icon>
            <FontImageSource Glyph="{StaticResource FalIconCalendar}" FontFamily="FontAwesomeLight" />
        </ShellContent.Icon>
    </ShellContent>
    <ShellContent Title="About" Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</TabBar>

BookingPage看起来像这样:

<ContentPage.Content>
    <Grid>                
        <ctrl:CustomWebView x:Name="webView"
                            Source="{Binding UrlBooking}"                                 
                            WidthRequest="1000" HeightRequest="1000"
                            IsVisible="{Binding ShowWebView}">
    </Grid
</ContentPage.Content>

BookingPage首次显示时,WebView正在按预期加载。但是,如果用户更改选项卡并返回到,BookingPage则取决于平台有 2 种行为:

我想知道是否有办法防止WebView在 Android 上重新加载?

我已经搜索过类似的主题,例如如何在标签栏选择后防止 webview 重新加载?但没有答案。

标签: androidxamarin.formswebviewtabbarxamarin.forms.shell

解决方案


推荐阅读