Set grid rectangle template for ProgressBar : ProgressBar « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="120" Width="300">
    <Window.Resources>
        <Style
            TargetType="{x:Type ProgressBar}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate 
                        TargetType="{x:Type ProgressBar}">
                        <Grid MinHeight="20" MinWidth="240">
                            <Rectangle Name="PART_Track" 
                                       Fill="Gainsboro" Stroke="Gray" StrokeThickness="1" />
                            <Rectangle Name="PART_Indicator" 
                                       Fill="DarkGray" Stroke="Gray" StrokeThickness="1" HorizontalAlignment="Left" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

    <StackPanel>
        <ProgressBar x:Name="progress" Value="30" HorizontalAlignment="Center" Margin="10"/>
    </StackPanel>

</Window>
WPF Set Grid Rectangle Template For Progress Bar








24.28.ProgressBar
24.28.1.Adding ProgressBar to WrapPanelAdding ProgressBar to WrapPanel
24.28.2.ProgressBar and AnimationProgressBar and Animation
24.28.3.Set grid rectangle template for ProgressBarSet grid rectangle template for ProgressBar
24.28.4.ProgressBar with five iterationsProgressBar with five iterations
24.28.5.ProgressBar with infinite iterationsProgressBar with infinite iterations
24.28.6.Indeterminate ProgressBarIndeterminate ProgressBar