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.
<Image Source="{Binding ...,
Converter={StaticResource local:StringToImageConverter}}"/>
The converter:
public class StringToImageConverter : IValueConverter
{
public object Convert(
object value, Type targetType, object parameter, CultureInfo culture)
{
object result = null;
var path = value as string;
if (!string.IsNullOrEmpty(path))
{
var image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = new Uri(path);
image.EndInit();
result = image;
}
return result;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
Even better, load the BitmapImage directly from a FileStream:
public object Convert(
object value, Type targetType, object parameter, CultureInfo culture)
{
object result = null;
var path = value as string;
if (!string.IsNullOrEmpty(path) && File.Exists(path))
{
using (var stream = File.OpenRead(path))
{
var image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.StreamSource = stream;
image.EndInit();
result = image;
}
}
return result;
}