Click here to Skip to main content
12,066,952 members (57,920 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


106 bookmarked

WPF Loading Wait Adorner

, 10 Feb 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Easily add a "Loading" overlay that "grays out" the form and adds a circular progress bar to any form.


First, let me give credit where credit is clearly due as I am standing on the shoulders of better developers with this one. It's basically a combination of two articles written by others to create something I've always wanted in my WPF toolkit.

The whole AdornedControl project which allows you to define your Adorners in XAML came from Ashley Davis. I'm fairly green when it comes to adorners, and could not have completed my article without his.

The other article I pulled from was Sacha Barber's circular progressbar article. I am not a designer by any stretch of the imagination, and wouldn't have known where to start on an animated circular progress bar.

Using the code

The first thing I did was put together a simple form with a button to simulate starting and stopping loading and a simple ListBox. Then, I wrapped the ListBox with an AdornedControl and created an AdornedControl.AdornerContent which contains the UserControl that will display when the adorner is visible.

    <Button Click="Button_Click">Start/Stop Waiting</Button>
    <ac:AdornedControl Name="LoadingAdorner">
        <ListBox Name="ListBox1">
            <ListBoxItem>Item 1</ListBoxItem>
            <ListBoxItem>Item 2</ListBoxItem>
            <ListBoxItem>Item 3</ListBoxItem>

The Button_Click event calls a method that flips LoadingAdorner.IsAdornerVisible and ListBox1.IsEnabled. In production, those will be bound to the IsEnabled and IsBusy properties on the ViewModel.

private void StartStopWait()
    LoadingAdorner.IsAdornerVisible = !LoadingAdorner.IsAdornerVisible;
    ListBox1.IsEnabled = !ListBox1.IsEnabled;

<local:LoadingWait> is the UserControl that both "grays out" the adorned area and displays the ring of progress. This is essentially Sacha's code, I just added a brush to the UserControl to do the "graying", and added a brush as a resource so I could easily change the colors of all the dots at once.


I can now go through my existing application and add this little adornment around any area that takes more than an instant to load its data. All I'll have to do is paste the adornment code into the XAML, bind the IsAdornerVisible to an IsBusy property, and set the IsBusy property from code.

As you can see, I didn't add a lot to Ashley and Sacha's previous works, and I would like to thank them again.


  • Feb 10th 2010 - Article posted.


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


About the Author

Jeremy Hutchinson
Software Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Questionwork 100% but i need help Pin
Mico Perez9-Jul-13 19:46
memberMico Perez9-Jul-13 19:46 
AnswerRe: work 100% but i need help Pin
Jeremy Hutchinson10-Jul-13 5:48
memberJeremy Hutchinson10-Jul-13 5:48 
GeneralRe: work 100% but i need help Pin
Mico Perez10-Jul-13 16:47
memberMico Perez10-Jul-13 16:47 
GeneralRe: work 100% but i need help Pin
Mico Perez11-Jul-13 1:23
memberMico Perez11-Jul-13 1:23 
QuestionAwesome! - Instead of 100% Screen Coverage Pin
stan_mcginnis26-Oct-12 6:39
memberstan_mcginnis26-Oct-12 6:39 
AnswerRe: Awesome! - Instead of 100% Screen Coverage Pin
Jeremy Hutchinson26-Oct-12 6:58
memberJeremy Hutchinson26-Oct-12 6:58 
QuestionHow to make loading wait adorner visible while a window is created and showed? Pin
mary4wpf3-Oct-12 7:23
membermary4wpf3-Oct-12 7:23 
AnswerRe: How to make loading wait adorner visible while a window is created and showed? Pin
Jeremy Hutchinson4-Oct-12 8:43
memberJeremy Hutchinson4-Oct-12 8:43 
Suggestionabout the libraries Pin
Pinocs1-Jun-12 6:30
memberPinocs1-Jun-12 6:30 
GeneralRe: about the libraries Pin
Jeremy Hutchinson1-Jun-12 6:34
memberJeremy Hutchinson1-Jun-12 6:34 
QuestionIts not working with asynchronous call Pin
Member 34620802-Mar-12 21:22
memberMember 34620802-Mar-12 21:22 
AnswerRe: Its not working with asynchronous call Pin
Jeremy Hutchinson5-Mar-12 10:26
memberJeremy Hutchinson5-Mar-12 10:26 
QuestionDispatcherPriority.ContextIdle cause unnormal! Pin
walker_ck18-Aug-11 23:36
memberwalker_ck18-Aug-11 23:36 
GeneralLoadingWait and BackgroundWorker Pin
lmhf00428-Sep-10 16:38
memberlmhf00428-Sep-10 16:38 
GeneralRe: LoadingWait and BackgroundWorker Pin
Jeremy Hutchinson29-Sep-10 2:59
memberJeremy Hutchinson29-Sep-10 2:59 
GeneralRe: LoadingWait and BackgroundWorker Pin
Member 173204230-May-11 8:25
memberMember 173204230-May-11 8:25 
GeneralUsing this with a tab control interface Pin
Timothy Lin Zheng Tian30-Jun-10 22:45
memberTimothy Lin Zheng Tian30-Jun-10 22:45 
GeneralRe: Using this with a tab control interface Pin
Jeremy Hutchinson1-Jul-10 3:30
memberJeremy Hutchinson1-Jul-10 3:30 
GeneralRe: Using this with a tab control interface Pin
Member 1006582925-Dec-14 7:08
memberMember 1006582925-Dec-14 7:08 
GeneralNice article Pin
Ashley Davis17-Feb-10 23:37
memberAshley Davis17-Feb-10 23:37 
GeneralRe: Nice article Pin
Jeremy Hutchinson18-Feb-10 5:02
memberJeremy Hutchinson18-Feb-10 5:02 
QuestionWhat a good combination Pin
Bill Seddon16-Feb-10 0:51
memberBill Seddon16-Feb-10 0:51 
GeneralCool Pin
Sacha Barber11-Feb-10 4:19
mvpSacha Barber11-Feb-10 4:19 
GeneralRe: Cool Pin
Jeremy Hutchinson11-Feb-10 4:33
memberJeremy Hutchinson11-Feb-10 4:33 
GeneralRe: Cool Pin
Sacha Barber11-Feb-10 5:20
mvpSacha Barber11-Feb-10 5:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.160208.1 | Last Updated 10 Feb 2010
Article Copyright 2010 by Jeremy Hutchinson
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid