I have a WPF ListBox that displays images loaded from a local folder,
usually somewhere between 1- 300).
I’m using a converter in my imageTemplate to make sure and show thumbnails of the images,
and not the images in their full size. Even while doing this, it still
can take several seconds to load initially.
My question is, how do I know in my ListBox when the loading of ListBoxItems
Begins/Ends, so that I can set the Mouse Cursor to a waiting status? I’m looking
for a way to notify that user that something is happening..
Here is what my ListBox looks like in XAML:
<ListBox SelectionMode="Extended"
ItemsSource="{Binding Path=ImageFiles}"
ItemTemplate="{StaticResource imageTemplate}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.IsDeferredScrollingEnabled="False"
VirtualizingStackPanel.VirtualizationMode="Recycling"
x:Name="images">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
Thanks!
I answered a similar question, here.
If you don’t want to do a pop-up, you could also do something similar by attaching a translucent rectangle (or some other filling control), with a message/animation in front of it, to the listbox or its parent control that gets closed asynchronously like the popup in the linked answer does. I did something like that for Silverlight back before the BusyIndicator was available, and it worked quite well. I set it up as a user control with a property for the control it should cover, so it was easily re-used.