Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to set the progress bar by ProgressTo method in Xamarin XAML language

Shulou Source: shulou.com Published: 2022-06-01 10:11:40 10月13日 Update

This article mainly introduces how to set the progress bar through the ProgressTo method in the Xamarin XAML language, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

A ProgressTo method is defined in ProgressBar, which can also be used to set the current progress bar. The difference between ProgressTo and Progress properties is that ProgressTo provides animation. The ProgressTo method must be used in the code file, not in the XAML file. Its grammatical form is as follows:

ProgressBarObject. ProgressTo (value, length, easing)

The parameters are described as follows:

Value: indicates the current progress of the setting.

Length: indicates how long it takes to reach the set value (milliseconds).

Easing: represents the animation effect.

[example 12-9:ProgressBarProgressThree] the following will use the ProgressTo method to set the current progress of the progress bar. The specific steps are as follows:

(1) MainPage.xaml file, write code, layout the content page. The code is as follows:

(2) Open the MainPage.xaml.cs file, write code, and set the current progress of the progress bar. The code is as follows:

Using System

Using System.Collections.Generic

Using System.Linq

Using System.Text

Using System.Threading.Tasks

Using Xamarin.Forms

Namespace ProgressBarProgressThree

{

Public partial class MainPage: ContentPage

{

Public MainPage ()

{

InitializeComponent ()

}

/ / set the current progress of the progress bar

Void SetProgresse (object sender, EventArgs args)

{

ProgressBar.ProgressTo (1.0,2500, Easing.Linear)

}

}

}

When you run the program at this point, you will see the effect shown in figure 12.32-12.33. When the developer taps the PlayProgressAnimate button, the progress bar implements the loaded animation, similar to the one shown in figure 12.34-12.35. The loading animation is completed after 2.5 seconds, and the current progress of the progress bar will be 1.

Figure 12.32 Android running effect figure 12.33 iOS running effect

Thank you for reading this article carefully. I hope the article "how to set the progress bar through the ProgressTo method in Xamarin XAML language" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Progress effects methods code animation files articles runs languages differences values interests parameters at the same time internal properties layout developers forms buttons Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Apple Linux MariaDB NVidia