Jump to content
Aerosol

WPF Windows XP Style ProgressBar

Recommended Posts

Posted

This is a simple progressbar which will show the percentage. It will change the text color according to the progress color.

Introduction

This is a basic WPF progress bar control. It looks like XP style progressbar which will show the progress value and text.

WPF progressbar doesn't show the progress text. I have a project which needs to show the progress value to the user. So I decided to develop a ProgressBar which will show the progress value on the progressbar.

<Style x:Key="{x:Type local:YagnaProgressBar}" 
TargetType="{x:Type local:YagnaProgressBar}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:YagnaProgressBar}">
<Grid x:Name="PART_ProgressbarGrid"
Background="Transparent">
<Canvas x:Name="PART_ProgressBarCanvas"
Background="Transparent" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<TextBox x:Name="PART_ProgressBarBorder"
Background="Green" IsReadOnly="True"
Canvas.Left="0" Canvas.Top="0" IsEnabled="False"/>
<Border x:Name="PART_ProgressBarRectangle"
Background="Blue" BorderThickness="0"
Canvas.Left="0" Canvas.Top="0"/>
<TextBlock x:Name="PART_ProgressBarWhiteText"
Text="0%" FontFamily="Arial" FontSize="12"
Foreground="Blue" Background="Transparent"
Canvas.Left="0" Canvas.Top="0" VerticalAlignment="Center"/>
</Canvas>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Points of Interest

I am new to WPF. I found it very interesting.

History

4th January, 2015: Initial version

Source

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...