xamarin.forms shell 标签栏很慢
xamarin.forms shell tabbar is very slow
我在我的应用程序中使用 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>
您正在使用 DataTemplate
这意味着它只会在需要时加载您的页面(当您导航到它时),如果您希望它加载得更快(它将在应用程序启动期间加载),那么当您这样做时导航到它,您的页面将已经加载并准备好显示,然后将其设置为直接内容,但它在 您的应用程序启动时间上有价格,这将增加 .
改变
<ShellContent ContentTemplate="{DataTemplate views:HomeView}"/>
进入
<ShellContent>
<views:HomeView/>
</ShellContent>
我在我的应用程序中使用 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>
您正在使用 DataTemplate
这意味着它只会在需要时加载您的页面(当您导航到它时),如果您希望它加载得更快(它将在应用程序启动期间加载),那么当您这样做时导航到它,您的页面将已经加载并准备好显示,然后将其设置为直接内容,但它在 您的应用程序启动时间上有价格,这将增加 .
改变
<ShellContent ContentTemplate="{DataTemplate views:HomeView}"/>
进入
<ShellContent>
<views:HomeView/>
</ShellContent>