Please, help me with following.
I have a WPF application. There are ListView with Images as items and one Image - DisplayedImage. When item clicked - its image displayed in the DisplayedImage Image Control.
When Image Control have some transformations I need to save them to source file.
How I can to free needed file, if it uses as source for ListView items and DisplayedImage Image Control?
Exception
The process cannot access the file "<Path>" because it is being used by another process XAML
<Image x:Name="DisplayedImage" Source="{Binding Path=TheImageViewItem.DisplayedPath, IsAsync=True, Mode=OneWay}"/> <ListView x:Name="listView" ItemsSource="{Binding Path=Images, IsAsync=True}" /> C#
JpegBitmapEncoder jpegBitmapEncoder = new JpegBitmapEncoder(); jpegBitmapEncoder.QualityLevel = 100; jpegBitmapEncoder.Frames.Add(BitmapFrame.Create(DisplayedImage.Source as BitmapSource)); if (File.Exists(file)) File.Delete(file); FileStream fileStream = new FileStream(file, FileMode.CreateNew); jpegBitmapEncoder.Save(fileStream); fileStream.Close(); THANKS TO ALL