So I’ve created a slideshow. The slideshow uses two overlapping media elements which display pictures. A transition simply means decrementing opacity of the foreground element and incrementing the opacity of the background element.
The problem is a picture is not loaded into the media element fast enough. This causes stuttering and generally looks bad. I got the idea that I could just create a tight loop that looks at the MediaElement.IsLoaded property until it becomes true. It turns out that isLoaded is always true because IsLoaded considers the media element, not the source.
I also thought about MediaElement.DownloadProgress, but it lies too.
Thoughts?
The
Loadedevent and theIsLoadedproperty are general features of all WPF controls derived fromFrameworkElement. TheIsLoadedproperty becomestrueand theLoadedevent is raised when the element is added to the visual tree, not when the content of the element has been displayed. SoIsLoadedis the wrong property for what you are trying to detect.The
Loadedevent is described like this:On the other hand,
MediaElementhas an event that might meet your needs:which is described like this:
This sounds like the correct event for your application.