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 Jeremy Hutchinson. 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
) to WaitAdorner
and the LoadingWait
UserControl
to RotatingDotsWaitAdorner
. I felt these were more descriptive names.
- In the sample included a
ToggleButton
in AdornerContent
for the WaitAdorner
which will clear the wait. The IsChecked
property is is bound to an IsWaiting
property in a ViewModel
that is also bound to a ToggleButton
to initialize the wait, and the IsAdornerVisible
property fo the WaitAdorner
.
- The "Start/Stop Waiting"
ToggleButton
is renamed "Start Waiting" and included within the WaitAdorner
. The way to stop the waiting is the "Cancel" ToggleButton
in the AdornerContent
. ToggleButton
controls are used to simplify the ViewModel
. In actuality would probably use a Button
in the AdornerContent
, and use a Binding
to an ICommand
.
- Did some refactoring, and included use of features available in C# 6.0.
History
2016-12-05: Initial Version