.NET MAUI ProgressBar Events
The ProgressBar for .NET MAUI exposes the following events:
-
ProgressChanged
event is raised when progress is changed. TheProgressChanged
event handler receives two parameters:- A
ProgressChangedEventArgs
which has aProgress
(double
) property. Using this property you can get the current progress of the ProgressBar control.
- A
ProgressCompleted
event is raised when the Value of the ProgressBar reaches theMaximum
value.
Example with ProgressChanged
and ProgressCompleted
events
A simple RadLinearProgressBar
definition:
<VerticalStackLayout Margin="20"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Spacing="20">
<HorizontalStackLayout>
<Label Text="{Binding Value, Source={x:Reference progressBar}}"
VerticalTextAlignment="Center" />
<Stepper Minimum="0"
Maximum="180"
Increment="20"
Value="{Binding Value, Source={x:Reference progressBar}}" />
</HorizontalStackLayout>
<HorizontalStackLayout>
<Label Text="Events: " />
<Label x:Name="statusLabel" />
</HorizontalStackLayout>
<telerik:RadLinearProgressBar x:Name="progressBar"
Minimum="0"
Maximum="180"
Value="20"
ProgressChanged="OnProgressChanged"
ProgressCompleted="OnProgressCompleted" />
</VerticalStackLayout>
Add the following namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
ProgressChanged
event in code behind. The Label text is updated with the current Progress
value:
private void OnProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.statusLabel.Text = e.Progress.ToString();
}
ProgressCompleted
event in code behind. The Label text is updated with Text = "Completed"
when the progress reaches the Maximum
value:
private void OnProgressCompleted(object sender, EventArgs e)
{
this.statusLabel.Text = "Completed";
}
The final result when using the ProgressChanged
and ProgressCompleted
events on Android:
And on WinUI:
For the ProgressBar Events example refer to the SDKBrowser Demo Application.