WPF Loading Wait Adorner






4.70/5 (10 votes)
This is an alternative for "WPF Loading Wait Adorner"
Introduction
I was looking for a control to display a wait condition, and discovered https://www.codeproject.com/Articles/57984/WPF-Loading-Wait-Adorner by The control provided the basic capabilities I was looking for, but I found a few things that could be improved upon. The initial problem I had was that the sample used code behind, and I thought that I would have to create a DependencyProperty
, but he actaully had created a DependencyProperty
, he just did not use this capability in the sample, Hard to understand how to use a Control
iwth the MVVM design pattern if you do not show use of the DependencyProperty
in the sample. Another serious problem was the naming for the Control
and its content.
Changes
- In the sample, binding is not used to make the control visible. I updated the sample so that it uses binding.
- Renamed the wait adorner (
AdornedControl
) toWaitAdorner
and theLoadingWait
UserControl
toRotatingDotsWaitAdorner
. I felt these were more descriptive names. - In the sample included a
ToggleButton
inAdornerContent
for theWaitAdorner
which will clear the wait. TheIsChecked
property is is bound to anIsWaiting
property in aViewModel
that is also bound to aToggleButton
to initialize the wait, and theIsAdornerVisible
property fo theWaitAdorner
. - The "Start/Stop Waiting"
ToggleButton
is renamed "Start Waiting" and included within theWaitAdorner
. The way to stop the waiting is the "Cancel"ToggleButton
in theAdornerContent
.ToggleButton
controls are used to simplify theViewModel
. In actuality would probably use aButton
in theAdornerContent
, and use aBinding
to anICommand
. - Did some refactoring, and included use of features available in C# 6.0.
History
2016-12-05: Initial Version