Click here to Skip to main content
6,595,854 members and growing! (18,738 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Windows Presentation Foundation » Controls     Advanced License: The Code Project Open License (CPOL)

Waiting Control / IE 7 Progressbar Control using WPF

By jebarson

Timeless or non-progress based waiting / progress control using WPF
VB (VB 7.x, VB 8.0, VB 9.0, VB 6), .NET (.NET 3.5), WPF, Architect, Dev
Posted:5 May 2008
Updated:13 May 2008
Views:15,037
Bookmarked:15 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
8 votes for this article.
Popularity: 2.39 Rating: 2.65 out of 5
4 votes, 50.0%
1
1 vote, 12.5%
2

3
1 vote, 12.5%
4
2 votes, 25.0%
5

Introduction

This article deals with the full coding and implementation of a waiting control in WPF.

waiting2.png

Download WaitingControl.zip - 302.64 KB

Background

Gone are those days when we used hour glass to show a busy status; we live in the arena of WPF. I wanted to implement a UI which looks like a progress bar in IE 7. This is particularly very useful when we can't estimate the progress. eg) A search page which pulls the data from the database can be never estimated that the result will be returned in 1 sec or 10 sec.

I googled a lot to get some help on this. Being my whole effort in vain, I finally settled down in building my own. I am sure that this code should help a few developers.

Using the code

The code is straight forward which has two circles filled with gradient color and a story board which runs endless, unless stopped. You can change the color, gradient etc as you wish.

The attached project comes with a Control library (the control itself) and a sample application which implements the control.

<UserControl.Resources> 
    <Storyboard x:Key="Spin" x:Name="Spin"> 
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
        RepeatBehavior="Forever" Storyboard.TargetName="path" 
        Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"> 
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/> 
            <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="360"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</UserControl.Resources> 

The above storyboard rotates the doughnut shaped control by 360° in .7 seconds and repeats the animation forever.

<Path.Fill>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
        <GradientStop Color="#FF000000" Offset="0"/> 
        <GradientStop Color="#FFC5D1F9" Offset="1"/> 
    </LinearGradientBrush> 
</Path.Fill> 

The above XAML should be your part of interest if you want to change the color. I would recommend using Microsoft Expression Blends for this.

13 routed events are implemented for the control which triggers on the 4 actions namely Start, End, Pause, Resume. The State property gives the state of the control.

ThrowsErrorOnInvalidOperation property gets / sets whether an invalid operation error is to be thrown eg) resume operation is invalid unless the control is paused.

Points of Interest

I struggled a lot before I could implement the routed events. I guess that this project should be a perfect one to learn on "Implementing routed events in your control".

Please feel free to write me in case of any support needed on this context. I would also like to hear from you, if this code was useful.

History

Version 1.0.0.0 : Control released with Start, End methods with its events

Version 2.0.0.0 :

  • Control released with Start, End, Pause, Resume methods and corresponding events.
  • State property implemented.
  • Invalid operation errors are introduced.

Version 2.1.0.0 :

  • Bugs fixed with the newly added methods.
  • Event names changed as per microsoft standards.
  • ThrowsErrorOnInvalidOperation property added.

Download WaitingControl.zip - 302.64 KB

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

jebarson


Member
Working as Technical Lead in Photon Infotech Inc., MA, USA. I love programming and that too exploring into new things.

I Started my first program by building a game on GW BASIC when I was 14. The release of the game made me addicted to fame. I fell in love with programming. I will program even on the last day of my life Smile
Occupation: Architect
Location: United States United States

Other popular Windows Presentation Foundation articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 5 of 5 (Total in Forum: 5) (Refresh)FirstPrevNext
QuestionToolstrip PinmemberTehtom1:52 4 Aug '09  
GeneralVery nice! Pinmember-=Deriven18:35 6 Dec '08  
GeneralYes! It is useful to me. PinmemberMember 328886119:28 6 May '08  
GeneralRe: Yes! It is useful to me. Pinmemberjebarson12:16 7 May '08  
NewsRe: Yes! It is useful to me. Pinmemberjebarson7:32 19 May '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 13 May 2008
Editor:
Copyright 2008 by jebarson
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project