Events in Xamarin ProgressBar (Progress Bar)
17 May 20212 minutes to read
ValueChanged
This event is triggered when the progress value is changed. This event contains the following event argument.
-
Progress
: Represents the progress value.
The following code sample demonstrates how to customize the color of a progress indicator based on progress using this event.
<progressBar:SfLinearProgressBar Progress="100" x:Name="LinearProgressBar" ValueChanged="ProgressBarBase_OnValueChanged">
</progressBar:SfLinearProgressBar>
private void ProgressBarBase_OnValueChanged(object sender, ProgressValueEventArgs e)
{
if (e.Progress < 50)
{
this.LinearProgressBar.ProgressColor = Color.Red;
}
else if (e.Progress >= 50)
{
this.LinearProgressBar.ProgressColor = Color.Green;
}
}
ProgressCompleted
This event is triggered when the progress attains the Maximum
value. This event contains the following argument.
-
Progress
: Represents the progress value.
The following code sample demonstrates how to customize the progress bar when progress reaches maximum using this event.
<progressBar:SfCircularProgressBar x:Name="CircularProgressBar" Minimum="100" Maximum="500" Progress="500" ProgressCompleted="ProgressBarBase_OnProgressCompleted" >
<progressBar:SfCircularProgressBar.Content>
<Label Text="Start" FontSize="15" x:Name="Label"></Label>
</progressBar:SfCircularProgressBar.Content>
</progressBar:SfCircularProgressBar>
private void ProgressBarBase_OnProgressCompleted(object sender, ProgressValueEventArgs e)
{
if (e.Progress.Equals(this.CircularProgressBar.Maximum))
{
// Changed the label text when progress reaches maximum value.
this.Label.Text = "Completed";
}
}