System.Windows.Controls Nam ...


.NET Framework Class Library for Silverlight
ProgressBar Class

Represents a control that indicates the progress of an operation.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
Syntax

Visual Basic (Declaration)
<TemplatePartAttribute(Name := "ProgressBarTrack", Type := GetType(FrameworkElement))> _
<TemplatePartAttribute(Name := "ProgressBarIndicator", Type := GetType(FrameworkElement))> _
<TemplateVisualStateAttribute(Name := "Determinate", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Indeterminate", GroupName := "CommonStates")> _
Public Class ProgressBar _
    Inherits RangeBase
Visual Basic (Usage)
Dim instance As ProgressBar
C#
[TemplatePartAttribute(Name = "ProgressBarTrack", Type = typeof(FrameworkElement))]
[TemplatePartAttribute(Name = "ProgressBarIndicator", Type = typeof(FrameworkElement))]
[TemplateVisualStateAttribute(Name = "Determinate", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Indeterminate", GroupName = "CommonStates")]
public class ProgressBar : RangeBase
XAML Object Element Usage
<ProgressBar .../>
Remarks

A ProgressBar control visually indicates progress of a lengthy operation with one of two styles.

  • A bar that displays a repeating pattern.

  • A bar that fills based on a value.

The following illustration shows a progress bar indicating continuous progress and a progress bar indicating value-based progress.

ProgressBar Control

Silverlight Progress Bar Control

Customizing the ProgressBar Control

To apply the same property settings to multiple ProgressBar controls, use the Style property. To change the visual structure and visual behavior of a ProgressBar, copy and modify its default style and template. For more information, see Control Customization.

If a dependency property for a ProgressBar is set by its default style, the property might change from its default value when the ProgressBar appears in the application. For more information, see Dependency Property Value Precedence. You can get the default style and template for ProgressBar from ProgressBar Styles and Templates.

NoteNote:

Setting a visual property will only have an effect if that property is both present in ProgressBar control's default template and is set by using a TemplateBinding. You can find a list of visual properties in the "Changing the Visual Structure of a Control" section of Customizing the Appearance of an Existing Control by Using a ControlTemplate.

Examples

The following example demonstrates a value-based ProgressBar and an indeterminate ProgressBar.

Run this sample

XAML
<StackPanel x:Name="LayoutRoot" Background="White">
   <Border BorderThickness="5" BorderBrush="Black">
    <StackPanel Background="LightGray">
        <TextBlock HorizontalAlignment="Center" Margin="10" 
            Text="Value-Based Progress Bar" />
        <ProgressBar x:Name="pg1" Value="100"  Margin="10" Maximum="200" 
            Height="15" IsIndeterminate="False" />
    </StackPanel>
</Border>
    <Border BorderThickness="5" BorderBrush="Black">
        <StackPanel Background="LightGray">
            <TextBlock HorizontalAlignment="Center" 
                Margin="10" Text="Indeterminate Progress Bar" />
            <ProgressBar x:Name="pg2" Margin="10" Height="15" 
                IsIndeterminate="True"   />
        </StackPanel>
    </Border>
</StackPanel>
Inheritance Hierarchy

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows..::.UIElement
      System.Windows..::.FrameworkElement
        System.Windows.Controls..::.Control
          System.Windows.Controls.Primitives..::.RangeBase
            System.Windows.Controls..::.ProgressBar
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources

Tags :


Page view tracker