简体   繁体   中英

xamarin.forms shell tabbar is very slow

I'm using the shell tab bar for navigation in my application. 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:

<?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 .

Change

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

into

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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