【发布时间】:2020-01-06 12:39:18
【问题描述】:
在示例 Xamarin Forms Prism 应用程序中,我使用以下代码从 MainPage 导航到 Page2:
await NavigationService.NavigateAsync("Page2");
如果Page2 包含一个 Syncfusion 控件(例如,选项卡视图之类的东西),我注意到在页面转换发生之前有相当长的延迟。这在旧硬件上肯定更明显。我还注意到导航栏中的标题会在页面呈现之前立即更改。
是什么导致了这种延迟?有没有办法让我在页面准备好呈现之前抛出某种类型的 loading 消息?
更新
这是一些代码...
MainPage.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="StackOverflow.Views.MainPage" Title="{Binding Title}">
<StackLayout>
<Button Command="{Binding NavigateToPage2Command}" Text="Navigate to Page 2" />
</StackLayout>
</ContentPage>
MainPageViewModel.cs
using Prism.Commands;
using Prism.Navigation;
namespace StackOverflow.ViewModels
{
public class MainPageViewModel : ViewModelBase
{
public MainPageViewModel(INavigationService navigationService) : base(navigationService)
{
Title = "Main Page";
NavigateToPage2Command = new DelegateCommand(NavigateToPage2CommandExecute);
}
public DelegateCommand NavigateToPage2Command
{
get;
set;
}
public async void NavigateToPage2CommandExecute()
{
await NavigationService.NavigateAsync("Page2");
return;
}
}
}
Page2.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:sf="clr- namespace:Syncfusion.XForms.TabView;assembly=Syncfusion.SfTabView.XForms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="StackOverflow.Views.Page2" Title="{Binding Title}">
<sf:SfTabView>
<sf:SfTabItem Title="Tab 1" />
<sf:SfTabItem Title="Tab 2" />
<sf:SfTabItem Title="Tab 3" />
<sf:SfTabItem Title="Tab 4" />
<sf:SfTabItem Title="Tab 5" />
</sf:SfTabView>
</ContentPage>
Page2ViewModel.cs
using Prism.Navigation;
namespace StackOverflow.ViewModels
{
public class Page2ViewModel : ViewModelBase
{
public Page2ViewModel(INavigationService navigationService) : base(navigationService)
{
Title = "Page 2";
}
}
}
【问题讨论】:
标签: xamarin.forms prism syncfusion