ProgressBar Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a control that indicates the progress of an operation.
This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).
/// [Microsoft.UI.Xaml.CustomAttributes.MUXContractProperty(version=0)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Version(1)]
class ProgressBar : RangeBase
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.XamlContract, 65536)]
class ProgressBar : RangeBase
[Microsoft.UI.Xaml.CustomAttributes.MUXContractProperty(version=0)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Version(1)]
public class ProgressBar : RangeBase
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.XamlContract), 65536)]
public class ProgressBar : RangeBase
Public Class ProgressBar
Inherits RangeBase
- Inheritance
-
ProgressBar
- Attributes
-
Microsoft.UI.Xaml.CustomAttributes.MUXContractPropertyAttribute Marshaling
Behavior ThreadingAttribute Attribute VersionAttribute ContractVersion Attribute
Tip
For more info, design guidance, and code examples, see Progress controls.
The WinUI 2 Gallery app includes interactive examples of most WinUI 2 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.
The following shows how to set up an indeterminate ProgressBar and a basic determinate ProgressBar where the value is dependent on a RepeatButton click.
<!-- xmlns:muxc="using:Microsoft.UI.Xaml.Controls" -->
<StackPanel x:Name="LayoutRoot">
<StackPanel BorderThickness="4" BorderBrush="Black" Padding="12">
<TextBlock Text="Indeterminate Progress Bar"/>
<muxc:ProgressBar IsIndeterminate="True" Margin="0,12"/>
</StackPanel>
<StackPanel BorderBrush="Black" BorderThickness="4" Padding="12">
<TextBlock Text="Value-Based Progress Bar"/>
<muxc:ProgressBar x:Name="progressBar1" Value="0" Maximum="200" Margin="0,12"/>
<RepeatButton Content="Press and hold" Click="RepeatButton_Click"/>
</StackPanel>
</StackPanel>
private static int _clicks = 0;
private void RepeatButton_Click(object sender, RoutedEventArgs e)
{
_clicks += 1;
progressBar1.Value = _clicks;
if (_clicks >= progressBar1.Maximum) _clicks = 0;
}
A ProgressBar control visually indicates progress of an operation with one of two styles: a bar that displays a repeating pattern, or a bar that fills based on a value.
The IsIndeterminate property determines the appearance of a ProgressBar.
- Set IsIndeterminate to true to display a repeating pattern. An alternative control to use for indeterminate progress is a ProgressRing.
- Set IsIndeterminate to false to fill the bar based on a value. (This is the default.) When IsIndeterminate is false, you specify the range with the Minimum and Maximum properties. By default Minimum is 0 and Maximum is 100. To specify the progress value, you set the Value property.
You can modify the default Style and ControlTemplate to give the control a unique appearance. For information about modifying a control's style and template, see XAML styles. The default style, template, and resources that define the look of the control are included in the generic.xaml
file. For design purposes, generic.xaml
is installed with the WinUI (Microsoft.UI.Xaml) NuGet package. By default, this location is \Users\<username>\.nuget\packages\microsoft.ui.xaml\<version>\lib\uap10.0\Microsoft.UI.Xaml\Themes\generic.xaml
. Styles and resources from different versions of WinUI might have different values.
XAML also includes resources that you can use to modify the colors of a control in different visual states without modifying the control template (modifying these resources is preferred to setting properties). For more info, see the Light-weight styling section of the XAML styles article.
Progress |
Initializes a new instance of the ProgressBar class. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Is |
Gets or sets a value that indicates whether the progress bar reports generic progress with a repeating pattern or reports progress based on the Value property. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Is |
Identifies the IsIndeterminate dependency property. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Show |
Gets or sets a value that indicates whether the progress bar should use visual states that communicate an Error state to the user. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Show |
Identifies the ShowError dependency property. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Show |
Gets or sets a value that indicates whether the progress bar should use visual states that communicate a Paused state to the user. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Show |
Identifies the ShowPaused dependency property. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Template |
Gets an object that provides calculated values that can be referenced as TemplateBinding sources when defining templates for a ProgressBar control. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Template |
Identifies the TemplateSettings dependency property. This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces). |
Product | Versions |
---|---|
WinUI 2 | 2.3, 2.4, 2.5-prerelease, 2.5, 2.6-prerelease, 2.6, 2.7-prerelease, 2.7, 2.8-prerelease, 2.8 |