Comments are closed for this post.
Posted by
GioGio
@
19 Nov 2008
02:41
hey there,
that's exactly, what I needed. Thx for that.
Now, I have a question:
I added the Class UriToCachedImageConverter to my project, but how can I add a "static resource" of this class?
Posted by
Josh
@
19 Nov 2008
12:05
Check out this post, Xaml. Using Resources:
http://www.thejoyofcode.com/Xaml._Using_Resources.aspx
Posted by
Ryan O'Neill
@
04 Feb 2009
02:41
Brilliant, I kind of thought it was doing something like that but I just could not track it down. Now I can delete my images after I remove them from a ListView.
Thanks for post, it was very helpful.
Ryan
Posted by
Patrik Fatoric
@
10 Feb 2009
16:06
Hi,
I have a similar problem, but my image is part of control template in a Button which is situated in a DataTemplate of WPF DataGrid.
The DataTemplate is loaded dynamically as resource dictionary.
My problem is that I cannot use local resurces statically linked to my DataTemplate so I cannot
use the DataConverter.
What could I do ?
I find out, when I intentional chage the ImageSource to another existing image on disk the system release the first one. After that the first image is free to delete or chage.
Is there a better solution ?
My code ...
<Button x:Name="Img1" Width="35" Height="35">
<Button.Template>
<ControlTemplate>
<Image x:Name="img" Source="{Binding Path=Slika}" width="32" Height="32"/></ControlTemplate> </Button.Template>
Posted by
Robert
@
06 Sep 2010
15:29
I was having this problem with an app I am building. Someone suggested I use bitmatcacheoption.onload. It took a lot of Googling but I finally found this post and your suggestion worked like a champ. Thank you for posting it.
Posted by
Igor
@
06 Dec 2010
08:52
You rock!
btw: It so bad, that we can put converter's code in xaml. I hate writing these two line classes.
Posted by
Josh
@
06 Dec 2010
18:40
Thanks Igor,
Have you seen this:
http://www.thejoyofcode.com/The_Binding_you_wanted_from_day_one_in_WPF.aspx?
Posted by
David Haglund
@
01 Jan 2011
01:21
Thanks Josh, just what I was looking for! :)
Posted by
Stuart
@
28 Mar 2011
11:49
Thanks for the Bitmap image code. My app wouldn't let me delete a file as it was still being used and this was the solution for that problem.
Thanks again.
Posted by
Eric
@
02 Aug 2011
10:15
Ignore last comment - sorted out the static resource stuff.
Worth noting that, if like the situation I have where image may change (updates) but may also be deleted occasionally and so not always guranteed to be present.
In this situation a try catch is needed in the example code e.g.
try
{
if (!string.IsNullOrEmpty(value.ToString()))
{
var bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(value.ToString());
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.EndInit();
return bi;
}
}
catch (Exception) {}
Posted by
Øyvind Knobloch-Bråthen
@
20 Oct 2011
11:23
This helped a lot. Had a hard time replacing images that was bound to the WPF GUI, but this did the trick. Thanks a lot.