I've got a ListView
containing a GridView
with an ObservableCollection
as its ItemsSource
. One column displays an image from a bound property containing the path. There are multiple entries with the same image path. Now I'm trying to replace one image file and reload the displayed image for all associated entries.
Here's what my cell template looks like so far (the CacheOption
is needed so the image file isn't in use when replacing it):
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image RenderOptions.BitmapScalingMode="HighQuality">
<Image.Source>
<BitmapImage UriSource="{Binding Image}" CacheOption="OnLoad" />
</Image.Source>
</Image>
</DataTemplate>
</GridViewColumn.CellTemplate>
The usual way to reload an image seems be to create a new BitmapImage
with BitmapCreateOptions.IgnoreImageCache
and assign it to the corresponding Image.Source
, replacing the old BitmapImage
.
Obviously, it isn't very practical do to this manually for hundreds of ListView
entries. I guess I could refresh the ItemsSource
property if I use CreateOptions="IgnoreImageCache"
for the BitmapImage
inside my cell template, but I'm unsure about the side effects (e. g. bypassing the cache when using the same image multiple times).
What would be the proper way to reload these images?