Click here to Skip to main content
16,020,261 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi, I am trying to put activity indicator before navigating to next page, code is running fine but can not see activity indicator after clicking the button. trying to resolve this issue since last week but have not yet figured it out.

What I have tried:

XAML
        <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

                <ActivityIndicator x:Name="acti" IsRunning="True"/>
</VerticalStackLayout>

C#
private void OnInfinixClicked(object sender,EventArgs e)
{
    Brands MyBrands = new Brands { name = "infinix" };
    acti.IsVisible = true;
    await Task.Delay(500);
    try
    {
        await Navigation.PushAsync(new details { BindingContext = MyBrands },true);
    }
    finally
    {
        acti.IsVisible = false;
    }
    }
Posted
Comments
Richard Deeming 10-Jul-23 3:45am    
The code you've tried won't even compile - you can't use await in a non-async method.

And just adding async to the method would be a bad idea:
Avoid async void methods | You’ve Been Haacked[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900