0
votes

I have a search page that have a Button to navigate to another page . When I click on that Button it takes about 4 seconds to navigate .

SearchPage Command :

Device.BeginInvokeOnMainThread(async () =>
{
    await (Application.Current.MainPage as NavigationPage).PushAsync(new OtherPage());
});

OtherPage Code Behind :

[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class OtherPage : ContentPage
    {
        SearchStateViewModel Model;
        public SearchEstatePage()
        {
            InitializeComponent();

            Model = new SearchStateViewModel();

            Layout.BindingContext = Model;
        }

         protected override void OnAppearing()
        {
            base.OnAppearing();

            Model.GetCities();
        }
    }

What is the problem ?

1
So have you commented out GetCities and tested it also why are you using BeginInvokeOnMainThread ? - TheGeneral
@MichaelRandall I comment out GetCities and delete BeginInvokeOnMainThread for the first time it takes 3 seconds and when i press back button and again press navigation button it navigate fast . only first time is slow - mm sh
My gut feeling says there maybe more going on do you have any slow code in the constructor to SearchStateViewModel ? - TheGeneral
@MichaelRandall I have commented out all code in SearchStateViewModel's constructor and still it takes about 3 seconds to navigate for first time . Is there any way to navigate to otherpage and after completely show that run some code ? - mm sh
@MichaelRandall Let us continue this discussion in chat. - mm sh

1 Answers

0
votes

As @MichaelRandall advice I have checked OtherPage's XAML and finde that the Syncfusion's components in XAML slows down the navigation .

But what what is the replacement ?