How to download image in WPF Image control?

aluzi liu 486 Reputation points
2022-09-14T13:39:50.037+00:00

The Image control's "Source" prpoerty, if pass it a url address, Image control can auto download image from web server and display it, that's pretty cool.
But in real world, my web server require authentication, in this case, Image control can not download image it'self.

So my question is, how to pass the authentication data to Image control?
If can't do this, I want to create custom "Image" inherit from Image control, how to override it's download process?

And, if ListBox contains thousands item, how to detect a ListBoxItem is visible or not(out of current ListBox viewport)?
Beacuse I don't want to download all item's image at the samtime.
I want download the image only when the item is visible(like the user scroll ListBox, the item below became visible to user).

XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
765 questions
{count} votes