简体   繁体   English

xamarin.forms shell 标签栏很慢

[英]xamarin.forms shell tabbar is very slow

I'm using the shell tab bar for navigation in my application.我在我的应用程序中使用 shell 选项卡栏进行导航。 In the beginning, it worked perfectly, but when my application grew - it started to work slowly.一开始,它运行良好,但当我的应用程序增长时 - 它开始运行缓慢。

Is there an opportunity to solve the problem?有机会解决问题吗?

Here is my shell:这是我的 shell:

<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:views="clr-namespace:Anime.Views"
       x:Class="Anime.Views.ShellView"
       Shell.NavBarIsVisible="False"
       StyleClass="shellStyle">
    <TabBar >
        <Tab Icon="ic_home.png">
            <ShellContent ContentTemplate="{DataTemplate views:HomeView}"/>
        </Tab>
        <Tab Icon="ic_search.png">
            <ShellContent ContentTemplate="{DataTemplate views:SearchView}"/>
        </Tab>
        <Tab Icon="ic_person.png">
            <ShellContent ContentTemplate="{DataTemplate views:ProfileView}"/>
        </Tab>
    </TabBar>
</Shell>

You are using DataTemplate which means it will load your page only when required (when you navigate into it), if you want it to load faster (it will load during application startup) that way when you navigate into it, your page will be already loaded and ready to be displayed, then set it as a direct content, but it has a price on your application starting time which will increase .您正在使用DataTemplate这意味着它只会在需要时加载您的页面(当您导航到它时),如果您希望它更快地加载(它将在应用程序启动期间加载),那么当您导航到它时,您的页面将已经加载并准备好显示,然后将其设置为直接内容,但它对您的应用程序启动时间有一个代价,这将增加

Change改变

<ShellContent ContentTemplate="{DataTemplate views:HomeView}"/>

into进入

<ShellContent>
    <views:HomeView/>
</ShellContent>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM