Silverlight ComboBox bound to IEnumerable <BitmapImage>, where images are downloaded from the server

I had a problem linking ComboBox to IEnumerable<BitmapImage>where the images are stored on the server and downloaded on demand. While the binding actually takes place, most of the images have not yet been loaded and forces the ComboBox to display empty selections in their place. Is there an easy way to get related images to update as they load. I would like to do this asynchronously; that is, I do not want to wait until they are loaded before binding the list to the ComboBox.

All suggestions are welcome, including suggestions for alternative approaches.

+3
source share
2 answers

I have the same problem. My hacked solution is to set each Image bitmap to a dummy image management source. While the control image is visible, it works. Then I just destroy the image after each "BitmapImage".

+1
source

I am working on a similar solution. The way to display images in combobox and load them on demand is that I define Image-Control as a DataTemplate and bind the Source Image-Control to the URL of the corresponding image file.

Thus, using the Image control, you can load an image on demand (when it is displayed)

XAML:

<ComboBox Items="{Binding Images}">
  <ComboBox.ItemTemplate>
    <DataTemplate>
      <Image Source="{Binding ImageUrl}"/>
    </DataTemplate>
  </ComboBox.ItemTemplate>
</ComboBox>

WITH#

public class ImageViewModel{
   public string ImageUrl {get; set;}
}
0
source

Source: https://habr.com/ru/post/1781041/


All Articles