<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Everything Silverlight &#187; image</title>
	<atom:link href="http://www.michaelsnow.com/tag/image/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelsnow.com</link>
	<description></description>
	<lastBuildDate>Thu, 28 Apr 2011 21:43:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Silverlight Tip of the Day #16 &#8211; Working with IgnoreImageCache</title>
		<link>http://www.michaelsnow.com/2010/05/07/silverlight-tip-of-the-day-16-working-with-ignoreimagecache/</link>
		<comments>http://www.michaelsnow.com/2010/05/07/silverlight-tip-of-the-day-16-working-with-ignoreimagecache/#comments</comments>
		<pubDate>Fri, 07 May 2010 22:32:43 +0000</pubDate>
		<dc:creator>Snowman</dc:creator>
				<category><![CDATA[images]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://www.silverlightdev.net/2010/05/07/silverlight-tip-of-the-day-16-working-with-ignoreimagecache/</guid>
		<description><![CDATA[If you have ever tried to work with the property IgnoreImageCache you might have noticed it does not work as you might expect it to. In MSDN this property is stated to have the following purpose: Loads images without using an existing image cache. This option should only be selected when images in a cache [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever tried to work with the property <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapcreateoptions.aspx">IgnoreImageCache</a> you might have noticed it does not work as you might expect it to.</p>
<p>In <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapcreateoptions.aspx">MSDN</a> this property is stated to have the following purpose:</p>
<p><em>Loads images without using an existing image cache. This option should only be selected when images in a cache need to be refreshed.</em></p>
<p>What’s not clear is while this will cause Silverlight to ignore its internal cache the same can not be said for your browsers cache. So, if your browser has decided to cache the image by its URI it may return the same file to Silverlight even if the file was changed on the server.</p>
<p>One way to get around this is to try to manipulate the URI in order to get past the browser’s rules for caching files. Check out this blog for an example on how to implement this:</p>
<p><a href="http://developers.de/blogs/damir_dobric/archive/2009/11/30/how-to-prevent-caching-of-images-in-silverlight.aspx">http://developers.de/blogs/damir_dobric/archive/2009/11/30/how-to-prevent-caching-of-images-in-silverlight.aspx</a></p>
<p>If you are not familiar with how to use IgnoreImageCache I have include a code snippet below that shows you to change the Silverlight caching to ignore the cache when a bitmap is loaded:</p>
<p>MainPage.xaml:</p>
<div class="csharpcode">
<pre class="alt">&lt;Button Click=<span class="str">&quot;Button_Click&quot;</span> Content=<span class="str">&quot;Load Image&quot;</span>/&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">&lt;Image x:Name=<span class="str">&quot;MyImage&quot;</span>/&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><span style="color: blue"></span><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>MainPage.xaml.cs:<br />
  </p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">private</span> <span class="kwrd">void</span> Button_Click(<span class="kwrd">object</span> sender, RoutedEventArgs e) </pre>
<pre>{ </pre>
<pre class="alt">    MyImage.Source = <span class="kwrd">null</span>; </pre>
<pre>    Uri uri = <span class="kwrd">new</span> </pre>
<pre>Uri(<span class="str"><a href="http://www.arcticstockimages.com/wp-content/uploads/2009/10/iceberg_1920x1200.jpg">http://www.arcticstockimages.com/wp-content/uploads/2009/10/iceberg_1920x1200.jpg</a></span>, </pre>
<pre>UriKind.Absolute); </pre>
<pre class="alt">    BitmapImage bi = <span class="kwrd">new</span> BitmapImage(uri); </pre>
<pre>    bi.CreateOptions = BitmapCreateOptions.IgnoreImageCache; </pre>
<pre class="alt">    MyImage.Source = bi; </pre>
<pre>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>
  </p>
<p>Thank you,<br />
  <br />&#8211;Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelsnow.com/2010/05/07/silverlight-tip-of-the-day-16-working-with-ignoreimagecache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

