Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the method to set the progress bar in Xamarin XAML language

Shulou Source: shulou.com Published: 2022-06-01 10:20:40 09月24日 Update

This article will explain in detail how to use the method to set the progress bar in the Xamarin XAML language. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

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

Figure 12.34 the operation effect of Android figure 12.35 iOS operation effect

This is the end of this article on "how to use the method to set the progress bar in the Xamarin XAML language". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Progress effect run method code animation file article usage language more different good practical content parameters internal properties layout developer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi NVidia Huawei Microsoft