Forum Xamarin Xamarin.Forms

How ProgressBar ProgressTo to make work?

Hi,

when i press button it just goes instantly without 1500 second.

<?xml version="1.0" encoding="utf-8" ?>

<StackLayout  VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
    <ContentView x:Name="overlay" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" IsVisible="False" BackgroundColor="#C0808080" Padding="10, 0">
        <ProgressBar x:Name="MyProgress" WidthRequest="500"
                 VerticalOptions="CenterAndExpand"
                 HorizontalOptions="Fill"/>
    </ContentView>
    <Button Text="MY TASKS"  Clicked="Button_Clicked"    />

</StackLayout>

using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace ProgressBar
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : ContentPage
{
float progress = 0f;
public MainPage()
{
InitializeComponent();
}

    async void Button_Clicked(object sender, EventArgs e)
    {

        progress += 0.2f;

        if (progress > 1)
        {
            progress = 0;
        }


        await MyProgress.ProgressTo(progress, 1500, Easing.Linear);

    }
}

}

What is wrong?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Which platform did you test on? Which version of Xamarin Forms did you use?
    I tested the code above however got the effect as expected:

    Did it only occur on a particular device? It's best to offer a sample to help us reproduce this issue.

Sign In or Register to comment.