I’d like to add a “Loading”-Image on the top of my ListView while all items are loading, if there are a lot of items being loaded, I still want a nice user experience.
So therefore I want a floating Image ( Animated GIF ? ) on top of my ListView.
How would one solve this and once you have the floating image or control, how do you make the GIF animated?
Here’s some XAML that I use to create an AJAX-like wait spinner for WPF. I uses geometry and animation rather than an animated GIF, and you can control the size and rate by tweaking the XAML:
You use it like this (specify the colour if you want to change it):
The above XAML would look like this (you have to imagine them spinning!):
To have a layer appear above your ListBox, wrap it in a Grid like this:
Using a Grid means that the Border will appear on top of the ListBox. In this case, the layer will appear greyed out, and will steal any mouse actions, effectively disabling the underlying ListBox.
Note that the binding here to
IsLoadedconnects to my view model. I set it tofalsewhen I start loading, then again totruewhen the loading completes. Note that I load my items off the dispatcher thread (on a worker thread) so that the UI updates while I’m doing this work.