I have an image on my wpf page which opens an image file form hard disk. The XAML for defining the image is:
<Image Canvas.Left="65" Canvas.Top="5" Width="510" Height="255" Source="{Binding Path=ImageFileName}" />
I am using Caliburn Micro and ImageFileName is updated with the name of file that image control should show.
When the image is opend by image control, I need to change the file. But the file is locked by image control and I can not delete or copy any mage over it. How can I force Image to close the file after it opened it or when I need to copy another file over it?
I checked and there is no CashOptio for image so I can not use it.
You could use a binding converter like below that loads an image directly to memory cache by setting BitmapCacheOption.OnLoad. The file is loaded immediately and not locked afterwards.
The converter: