<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><!-- generator="wordpress/2.2" --><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Robs Usability Development : Silverlight, ASP.NET, Ajax, Agile, MVC &amp; Volta</title>
	<link>http://www.robertjantuit.nl</link>
	<description>Developing Usability</description>
	<pubDate>Thu, 27 Aug 2009 06:00:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RobsWorld" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>How many GB’s = 6oz?</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/eUW8JqjktM4/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/08/27/how-many-gbs-6oz/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 06:00:21 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/08/27/how-many-gbs-6oz/</guid>
		<description><![CDATA[Some things can just make me smile for a week. It doesn’t happen a lot but when it happens it is like drinking nectar of the gods  
Today I had one of these moments when I received an email from one of my co-workers with in it a link to this forums question on [...]]]></description>
			<content:encoded><![CDATA[<p>Some things can just make me smile for a week. It doesn’t happen a lot but when it happens it is like drinking nectar of the gods <img src='http://www.robertjantuit.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img style="margin: 10px 0px 10px 10px; display: inline" align="right" src="http://clearchoicehi.com/view/resource/images/foundation_hole.jpg" width="173" height="127" />Today I had one of these moments when I received an email from one of my co-workers with in it a link to this forums question on the Microsoft answers forum:</p>
<p><a title="http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605" href="http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605">http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605</a></p>
<p>The questions is from January, but for all of you who missed it, this is an incredibly fun read. Also be sure to read all the replies, with mathematical equations explaining the GB to Pounds ratio’s trough the use of mathematical equations by the XVIIII century scholar Lineus Torvaldus.</p>
<p>And if you have anything to add to the discussion please continue the discussion in the comments below.</p>
<p>Have fun reading!</p>
<p>-Robertjan </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/08/27/how-many-gbs-6oz/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/08/27/how-many-gbs-6oz/</feedburner:origLink></item>
		<item>
		<title>Silverlight &amp; Expression Blend 3</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/WaaqSsgREUU/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/07/11/silverlight-expression-blend-3/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 12:25:43 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Expression Blend]]></category>

		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/07/11/silverlight-expression-blend-3/</guid>
		<description><![CDATA[Yesterday, there was the long awaited release of Silverlight 3 and Expression Blend 3. So now we can finally bring all the new and exciting things onto live environments, and share it with the world: See the Light!
For those of you who haven’t had the time to follow the Beta, Silverlight 3 brings a wealth [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, there was the long awaited release of Silverlight 3 and Expression Blend 3. So now we can finally bring all the new and exciting things onto live environments, and share it with the world: <a href="http://www.microsoft.com/silverlight/seethelight/default.html">See the Light!</a></p>
<p><img style="margin: 20px 0px 20px 20px; display: inline" align="right" src="http://weblogs.asp.net/blogs/lduveau/Silverlight_5EBC47A9.jpg" width="154" height="172" />For those of you who haven’t had the time to follow the Beta, Silverlight 3 brings a wealth of new features features:</p>
<ul>
<li><a href="http://www.silverlightshow.net/items/Perspective-3D-in-Silverlight-3.aspx">Perspective 3D</a> </li>
<li><a href="http://msdn.microsoft.com/en-us/magazine/dd882515.aspx">Out of Browser (OOB)</a> </li>
<li>Enhanced Font Rendering and ClearType support. </li>
<li><a href="http://www.wintellect.com/CS/blogs/jprosise/archive/2009/03/25/silverlight-3-s-new-pixel-shaders.aspx">Pixel Shaders</a> (also check out <a href="http://wpfwonderland.wordpress.com/2008/10/08/shazzam-wpf-pixel-shader-effect-testing-tool-now-available/">Shazzam</a>) </li>
<li>Bitmap API (<a href="http://www.wintellect.com/CS/blogs/jprosise/archive/2009/03/23/silverlight-3-s-new-writeablebitmap.aspx">Link1</a>, <a href="http://labs.boulevart.be/index.php/2009/06/22/silverlight-3-writeable-bitmap-api-plasma/">Link2</a>) </li>
<li><a href="http://www.silverlightshow.net/items/Animation-Easing-in-Silverlight-3.aspx">Organic animation effects</a> </li>
<li><a href="http://www.silverlightshow.net/items/Page-navigation-and-browser-history-in-Silverlight.aspx">Browser history and deep linking</a> </li>
<li><a href="http://dotnetdreamer.com/2009/04/24/silverlight-3-element-to-element-binding/">Element to Element Binding</a> </li>
<li><a href="http://www.wintellect.com/CS/blogs/jprosise/archive/2009/03/29/silverlight-3-s-new-gpu-acceleration.aspx">Hardware Acceleration (GPU)</a> </li>
</ul>
<p>Blend 3 also has gone trough a major update, some of the major improvements are:</p>
<ul>
<li><a href="http://electricbeach.org/?p=145">Sketchflow</a> (A must have tool for every interaction designer) </li>
<li><a href="http://silverzine.com/tutorials/how-to-create-sample-data-in-blend-3/">Sample Data</a> </li>
<li><a href="http://www.andybeaulieu.com/Home/tabid/67/EntryID/150/Default.aspx">Behaviors</a> </li>
</ul>
<p>Over the next few weeks I will write about each of these features, and show how they can impact your development.</p>
<p>All the downloads can be found <a href="http://silverlight.net/GetStarted/">here</a>.</p>
<p>Have fun playing!</p>
<p>-Robertjan Tuit</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3f43b5a3-b832-4c53-9446-fafc755aecb7" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Silverlight+3" rel="tag">Silverlight 3</a>,<a href="http://technorati.com/tags/Expression+Blend" rel="tag">Expression Blend</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/07/11/silverlight-expression-blend-3/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/07/11/silverlight-expression-blend-3/</feedburner:origLink></item>
		<item>
		<title>No Debugging after converting solution to VS 2010 and Silverlight 3</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/_-s8kIwbeqM/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/06/29/no-debugging-after-converting-solution-to-vs-2010-and-silverlight-3/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 14:01:00 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Visual Studio 2010]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/06/29/no-debugging-after-converting-solution-to-vs-2010-and-silverlight-3/</guid>
		<description><![CDATA[Just a quick post to hopefully save a lot of other people the trouble I just went through.
I had a Silverlight 2 and Web solution in VS2008 and converted it to VS2010 and Silverlight 3.
After this conversion a setting is removed from the properties of the Web project: Silverlight Debugging.
&#160; 
This of course disables all [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to hopefully save a lot of other people the trouble I just went through.</p>
<p>I had a Silverlight 2 and Web solution in VS2008 and converted it to VS2010 and Silverlight 3.</p>
<p>After this conversion a setting is removed from the properties of the Web project: Silverlight Debugging.</p>
<p><a href="http://www.robertjantuit.nl/wp-content/uploads/2009/06/image.png" rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.robertjantuit.nl/wp-content/uploads/2009/06/image-thumb.png" width="188" height="244" /></a>&#160;<a href="http://www.robertjantuit.nl/wp-content/uploads/2009/06/image1.png" rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.robertjantuit.nl/wp-content/uploads/2009/06/image-thumb1.png" width="419" height="134" /></a> </p>
<p>This of course disables all debugging with the projects, and sent me on a wild goose chase to all kinds of interesting articles trying to fix debugging with Silverlight.</p>
<p>And of course, all I had to do was enable Silverlight debugging again on the Web project <img src='http://www.robertjantuit.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Hopefully this will save you the day I lost trying to solve this problem.</p>
<p>-Robertjan Tuit</p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dfc50db2-0ce4-4e50-a5e8-9d5dbed6edd8" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Dev10" rel="tag">Dev10</a>,<a href="http://technorati.com/tags/VS2010" rel="tag">VS2010</a>,<a href="http://technorati.com/tags/SL3" rel="tag">SL3</a>,<a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Debugging" rel="tag">Debugging</a></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/06/29/no-debugging-after-converting-solution-to-vs-2010-and-silverlight-3/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/06/29/no-debugging-after-converting-solution-to-vs-2010-and-silverlight-3/</feedburner:origLink></item>
		<item>
		<title>MSDN Redesign</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/2dZWD9S85WU/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/06/06/msdn-redesign/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 04:46:35 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[MSDN]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/06/06/msdn-redesign/</guid>
		<description><![CDATA[Since joining MSDN I have been very busy doing some awesome new stuff. The last couple of months have been like a trip on a high speed train, on the roof while juggling 3 melons and tweeting about it at the same time.
Of course most of the things we are doing we have to keep [...]]]></description>
			<content:encoded><![CDATA[<p>Since joining <a href="http://www.msdn.com">MSDN</a> I have been very busy doing some awesome new stuff. The last couple of months have been like a trip on a high speed train, on the roof while<a href="http://www.hanselman.com/blog/MSDNUpdatesAndRFCForYou.aspx"><img style="margin: 20px 0px 20px 20px; display: inline" title="MSDN_TRAM_HOME" border="0" alt="MSDN_TRAM_HOME" align="right" src="http://www.hanselman.com/blog/content/binary/WindowsLiveWriter/MSDNFeedback_93A3/MSDN_TRAM_HOME_thumb.png" width="147" height="170" /></a> juggling 3 melons and tweeting about it at the same time.</p>
<p>Of course most of the things we are doing we have to keep under wraps, so I have not really had the opportunity to blog about what we are doing.</p>
<p>But there are people at Microsoft who really stand on their own, and try to break some of the public barriers. One of them is <a href="http://www.hanselman.com/blog/">Scott Hanselman</a>, who is working closely with the team on our efforts to bring a new look and feel to <a href="http://www.msdn.com">MSDN</a>. </p>
<p>And a couple of hours ago, he decided to share some of the new ideas with the world. Nice!</p>
<p>So have a look at some of the very early designs, and let us know what you think:</p>
<p><a title="http://www.hanselman.com/blog/MSDNUpdatesAndRFCForYou.aspx" href="http://www.hanselman.com/blog/MSDNUpdatesAndRFCForYou.aspx">http://www.hanselman.com/blog/MSDNUpdatesAndRFCForYou.aspx</a></p>
<p>- Robertjan Tuit</p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:701e63a5-3f05-4510-9206-45409c38f5de" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/MSDN" rel="tag">MSDN</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/06/06/msdn-redesign/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/06/06/msdn-redesign/</feedburner:origLink></item>
		<item>
		<title>Silverlight 2 dynamic assembly loading - Part 2</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/eImFKuRvrHQ/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/03/06/silverlight-2-dynamic-assembly-loading-part-2/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 05:01:50 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/03/06/silverlight-2-dynamic-assembly-loading-part-2/</guid>
		<description><![CDATA[
In this article:      - Unpacking and loading the assemblies.     - Direct &#38; Deferred Loading     - Download Progress     In part 1 (click to open)&#160;:     - Rebuilding the AppManifest.xaml     - (Re)compressing .xap [...]]]></description>
			<content:encoded><![CDATA[<div>
<p style="border-bottom: #eeeeee 1px solid; border-left: #eeeeee 1px solid; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; background: #f4f4f4; float: right; color: #666666; margin-left: 20px; border-top: #eeeeee 1px solid; border-right: #eeeeee 1px solid; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"><strong>In this article:      <br /></strong>- Unpacking and loading the assemblies.     <br />- Direct &amp; Deferred Loading     <br />- Download Progress     <br /><strong><a href="http://www.robertjantuit.nl/index.php/2009/01/30/silverlight-2-dynamic-assembly-loading-part-1/">In part 1 (click to open)</a>&#160;</strong>:     <br />- Rebuilding the AppManifest.xaml     <br />- (Re)compressing .xap files with <a href="http://www.7-zip.org/">7zip</a></p>
<p>A little but later then promised, mostly because I kept building more and more functionality. But here is second part of the Dynamic Assembly Loading. <a href="http://www.robertjantuit.nl/index.php/2009/01/30/silverlight-2-dynamic-assembly-loading-part-1/">Click here for part 1</a>.</p>
<p>In part 1 we rexapped out applications to meet our requirements, now let&#8217;s start loading the application, the custom xaml and the referenced assemblies. We start out with the solutions created in part 1, <a href="http://www.robertjantuit.nl/wp-content/uploads/2009/01/robertjantuitnl-sl2-dynamicassemblyloading.zip">click here to download it</a>.</p>
<h2>ReferencedAssemblies.xaml</h2>
<p>To reference and handle the data while loading we create a ReferencedAssembly class looking like this:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">enum</span> <span style="color: #f0dfaf">ReferencedAssemblyStates</span> { <span style="color: #ffff80">None</span>, <span style="color: #ffff80">Loading</span>, <span style="color: #ffff80">Error</span>, <span style="color: #ffff80">Done</span> };</p>
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">class</span> <span style="color: #80ffff">ReferencedAssembly</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #f0dfaf">ReferencedAssemblyStates</span> <span style="color: #ffff80">State</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">long</span> <span style="color: #ffff80">ByteSize</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">long</span> <span style="color: #ffff80">ByteSizeLoaded</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">PercentLoaded</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">string</span> <span style="color: #ffff80">Name</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ffff">Uri</span> <span style="color: #ffff80">Uri</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #f0dfaf">EventHandler</span> <span style="color: #ffff80">Loaded</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ffff">Exception</span> <span style="color: #ffff80">Error</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ffff">AssemblyPart</span> <span style="color: #ffff80">AssemblyPart</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #f0dfaf">LoadingTypes</span> <span style="color: #ffff80">loadingType</span> = <span style="color: #f0dfaf">LoadingTypes</span>.<span style="color: #ffff80">Direct</span>;</p>
<p style="margin: 0px">}</p>
</p></div>
<p>Then we load our custom created ReferencedAssemblies.xaml from the Application Resource Stream, in the project this is done when you access the getter of the ReferencedAssemblies property:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">xmlReader</span> = <span style="color: #80ffff">XmlReader</span>.<span style="color: #ffff80">Create</span>(</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ffff">Application</span>.<span style="color: #ffff80">GetResourceStream</span>(</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Uri</span>(<span style="color: #c89191">&quot;ReferencedAssemblies.xaml&quot;</span>, <span style="color: #f0dfaf">UriKind</span>.<span style="color: #ffff80">Relative</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; ).<span style="color: #ffff80">Stream</span></p>
<p style="margin: 0px">&#160;&#160;&#160; );</p>
</p></div>
</p>
<p>And use the XamlReader to put the data in our class:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">while</span> (<span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">ReadToFollowing</span>(<span style="color: #c89191">&quot;ReferencedAssembly&quot;</span>))</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// Read Name &amp; Source and Size</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">MoveToAttribute</span>(<span style="color: #c89191">&quot;Name&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">name</span> = <span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">Value</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">MoveToAttribute</span>(<span style="color: #c89191">&quot;Source&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">uri</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Uri</span>(<span style="color: #80ffff">Application</span>.<span style="color: #ffff80">Current</span>.<span style="color: #ffff80">AbsolutePath</span>() + <span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">Value</span>, <span style="color: #f0dfaf">UriKind</span>.<span style="color: #ffff80">Absolute</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">MoveToAttribute</span>(<span style="color: #c89191">&quot;ByteSize&quot;</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">byteSize</span> = <span style="color: #80ff80; font-weight: bold">long</span>.<span style="color: #ffff80">Parse</span>(<span style="color: #ffff80">xmlReader</span>.<span style="color: #ffff80">Value</span>);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// Create a new ReferencedAssembly class and set values</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">referencedAssembly</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">ReferencedAssembly</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">Name</span> = <span style="color: #ffff80">name</span>,</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">Uri</span> = <span style="color: #ffff80">uri</span>,</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">ByteSize</span> = <span style="color: #ffff80">byteSize</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; };</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// Add it to the Dictionary</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ffff">Current</span>.<span style="color: #ffff80">_ReferencedAssemblies</span>.<span style="color: #ffff80">Add</span>(<span style="color: #ffff80">name</span>, <span style="color: #ffff80">referencedAssembly</span>);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>So now we have a list of assemblies, their xap file and their size. (This is a new addition to the ReXapper not done in Part 1). With this list we can load up all our referenced assemblies.</p>
<h2>Direct &amp; Deferred Loading</h2>
<p>As you might have notice by looking at the code above, I added 2 kind of loading methods: Direct and Deferred.</p>
<p>I added these 2 types to make it possible to load assemblies on demand. This can be very useful when you are building bigger applications.</p>
<h2>App.Xaml.cs</h2>
<p>Now lets look at what we have to do in our applications. All other code we did so far is a one of, meaning we can just reference it next time. This piece of code needs to be added to every application we wish to use this type of assembly loading.</p>
<p>By default your app.xaml.cs contains the following to initiate your Page:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">void</span> <span style="color: #ffff80">Application_Startup</span>(<span style="color: #80ff80; font-weight: bold">object</span> <span style="color: #ffff80">sender</span>, <span style="color: #80ffff">StartupEventArgs</span> <span style="color: #ffff80">e</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">this</span>.<span style="color: #ffff80">RootVisual</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Page</span>();</p>
<p style="margin: 0px">}</p>
</p></div>
<p>This should be changed to:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">void</span> <span style="color: #ffff80">Application_Startup</span>(<span style="color: #80ff80; font-weight: bold">object</span> <span style="color: #ffff80">sender</span>, <span style="color: #80ffff">StartupEventArgs</span> <span style="color: #ffff80">e</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">AppAssemblyLoader</span>.<span style="color: #80ffff">Current</span>.<span style="color: #ffff80">LoadReferencedAssemblies</span>(</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ff80; font-weight: bold">string</span>[] { <span style="color: #c89191">&quot;System.Xml.Linq&quot;</span> },</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; () =&gt; <span style="color: #80ff80; font-weight: bold">this</span>.<span style="color: #ffff80">RootVisual</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Page</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160; );</p>
<p style="margin: 0px">}</p>
</p></div>
<p>What we are doing here is loading the referenced assembly System.Xml.Linq and when it is done call the Page creation method.</p>
<p>Because we also have a MyLibrary.dll in our application this will also be loaded, but this happens in the background. I have added a couple of Events to attach to to monitor what is happening:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #f0dfaf">LoadingDoneEventHandler</span> <span style="color: #ffff80">LoadingDone</span>;</p>
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #f0dfaf">LoadingDoneEventHandler</span> <span style="color: #ffff80">LoadingStarted</span>;</p>
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #f0dfaf">DownloadProgressChangedEventHandler</span> <span style="color: #ffff80">DownloadProgressChanged</span>;</p>
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #f0dfaf">AssemblyDownloadProgressEventHandler</span> <span style="color: #ffff80">AssemblyDownloadProgressChanged</span>;</p>
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #f0dfaf">AssemblyStateChangedEventHandler</span> <span style="color: #ffff80">AssemblyStateChanged</span>;</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>If you want to application to start only after every assembly is loaded you just call it like this:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #ffff80">AppAssemblyLoader</span>.<span style="color: #80ffff">Current</span>.<span style="color: #ffff80">LoadReferencedAssemblies</span>(</p>
<p style="margin: 0px">&#160;&#160;&#160; () =&gt; <span style="color: #80ff80; font-weight: bold">this</span>.<span style="color: #ffff80">RootVisual</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Page</span>()</p>
<p style="margin: 0px">);</p>
</p></div>
<h2>Loading the Assembly</h2>
<p>Loading an assembly is pretty straightforward. First we use a WebClient to get a stream to .xap file.</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">wc</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">WebClient</span>();</p>
<p style="margin: 0px"><span style="color: #ffff80">wc</span>.<span style="color: #ffff80">OpenReadCompleted</span> += (<span style="color: #ffff80">sender</span>, <span style="color: #ffff80">e</span>) =&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">LoadAssemblyFromWebResponse</span>(<span style="color: #ffff80">referencedAssembly</span>, <span style="color: #ffff80">e</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; };</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: #ffff80">wc</span>.<span style="color: #ffff80">OpenReadAsync</span>(<span style="color: #ffff80">referencedAssembly</span>.<span style="color: #ffff80">Uri</span>);</p>
</p></div>
<p>Then we take the Result stream and use it load create an AssemblyPart:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #80ff80; font-weight: bold">void</span> <span style="color: #ffff80">LoadAssemblyFromWebResponse</span>(<span style="color: #80ffff">ReferencedAssembly</span> <span style="color: #ffff80">referencedAssembly</span>, <span style="color: #80ffff">OpenReadCompletedEventArgs</span> <span style="color: #ffff80">e</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// Load .xap as StreamResource</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">xap</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">StreamResourceInfo</span>(<span style="color: #ffff80">e</span>.<span style="color: #ffff80">Result</span>, <span style="color: #80ff80; font-weight: bold">null</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// Get the assembly (.dll) from the .xap StreamResource</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">assemblySri</span> = <span style="color: #80ffff">Application</span>.<span style="color: #ffff80">GetResourceStream</span>(<span style="color: #ffff80">xap</span>, <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Uri</span>(<span style="color: #ffff80">referencedAssembly</span>.<span style="color: #ffff80">Name</span> + <span style="color: #c89191">&quot;.dll&quot;</span>, <span style="color: #f0dfaf">UriKind</span>.<span style="color: #ffff80">Relative</span>));</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// Load the stream into a new AssemblyPart</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">assemblyPart</span> = <span style="color: #ffff80">referencedAssembly</span>.<span style="color: #ffff80">AssemblyPart</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">AssemblyPart</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">assemblyPart</span>.<span style="color: #ffff80">Load</span>(<span style="color: #ffff80">assemblySri</span>.<span style="color: #ffff80">Stream</span>);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Luckily Silverlight takes care of everything else. The assembly is added to the Assembly Pool, and when another part of you application requests the assembly it is automatically referenced.</p>
<h2>Managed Download Progress</h2>
<p>You have the possibility to get the download progress for the total and for every separate assembly. If you would load everything deferred, this would enable you to make a Managed Code Loader.</p>
<h2>WrapUp</h2>
<p>The end project contains a lot more&#160; code which I won&#8217;t talk about here, but if you download the source code you can check it out yourself.</p>
<p>It ended up being a lot more that just the Loader I was planning it to become. But the things that were added, make it very useful for a few other scenario&#8217;s as well:</p>
<ul>
<li>Easily separate a Silverlight application into different xap files, making it a good base for bigger applications in SL. </li>
<li>Create a managed loader, which is currently impossible with Silverlight. </li>
</ul>
<p>I hope to have time in the next weeks, to build some demo applications to show off the possibilities.</p>
<p>You can download the finished source code here:    <br /><a href="http://www.robertjantuit.nl/wp-content/uploads/2009/03/robertjan-tuit-dynamicassemblyloading-part-2.zip">Robertjan Tuit - DynamicAssemblyLoading - Part 2 - Source Code.zip</a></p>
<p>Of course if you have any questions, ideas or remarks please let me know!</p>
<p>Stay in the Light!</p>
<p>Robertjan Tuit</p>
<p style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="scid:d7bf807d-7bb0-458a-811f-90c51817d5c2:ca241c10-4cc2-4f88-9a8a-fa109ec397ff" class="wlWriterEditableSmartContent">
<p><span class="TagSite">Technorati:</span> <a href="http://technorati.com/tag/Silverlight" rel="tag" class="tag">Silverlight</a><br /><!-- StartInsertedTags: Silverlight :EndInsertedTags --></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/03/06/silverlight-2-dynamic-assembly-loading-part-2/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/03/06/silverlight-2-dynamic-assembly-loading-part-2/</feedburner:origLink></item>
		<item>
		<title>Silverlight 2 dynamic assembly loading - Part 1</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/qFhh6-PNbT0/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/01/30/silverlight-2-dynamic-assembly-loading-part-1/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 13:01:46 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/01/30/silverlight-2-dynamic-assembly-loading-part-1/</guid>
		<description><![CDATA[In this article:
- Rebuilding the AppManifest.xaml
- (Re)compressing .xap files with 7zip
Coming in part 2 (Click to open):
- Loading the assemblies.
Silverlight 2 by default packages all the referenced assemblies into one big xap file. This is a nice for deployment scenarios, but when you have a lot of Silverlight controls, using the same assemblies over and [...]]]></description>
			<content:encoded><![CDATA[<p style="border: 1px solid #eeeeee; padding: 5px; background: #f4f4f4 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; float: right; color: #666666; margin-left: 20px"><strong>In this article:<br />
</strong>- Rebuilding the AppManifest.xaml<br />
- (Re)compressing .xap files with <a href="http://www.7-zip.org/">7zip</a><br />
<a href="http://www.robertjantuit.nl/index.php/2009/03/06/silverlight-2-dynamic-assembly-loading-part-2/">Coming in part 2 (Click to open):</a><br />
- Loading the assemblies.</p>
<p>Silverlight 2 by default packages all the referenced assemblies into one big xap file. This is a nice for deployment scenarios, but when you have a lot of Silverlight controls, using the same assemblies over and over again, you waste a lot of bandwidth, and user experience drops because of the extra time it takes to load a page.</p>
<h2><a href="http://www.robertjantuit.nl/wp-content/uploads/2009/01/image1.png"><img src="http://www.robertjantuit.nl/wp-content/uploads/2009/01/image-thumb1.png" style="border-width: 0px; margin: 0px 0px 20px 20px" alt="image" align="right" border="0" width="203" height="244" /></a>Do not copy local</h2>
<p>Some of it can be achieved by setting the &#8220;copy local&#8221; property of the referenced assemblies to false. This tells the packager not to add them to the .xap file automatically.</p>
<p>Now when the Silverlight application starts in a browser we will have to resolve the &#8220;missing&#8221; referenced assemblies. I had hoped to use the AppDomain.AssemblyResolve event, but as it seems, this has been marked with the [SECURITY CRITICAL] attribute, which means it can only be used in the .NET framework itself.</p>
<p>Luckily the assemblies are accessed only when needed, so the assembly is only needed when you first access something from the assembly, like a class or method. This means that if we do all the loading in the App.xaml.cs we should be fine. But for this example I will not use this option, so you can put them back to True.</p>
<h2>Because I&#8217;m Lazy</h2>
<p>I am a lazy programmer <img src='http://www.robertjantuit.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> And I do not want to manually load every assembly for every Silverlight project. I&#8217;d rather do some more work now, and save myself (and hopefully you as well) lots of time in the future. And as an added bonus we get some extra compression (+- 20%) in our .xap files, because the normal .xap packager does almost no compression at all. And if you would use the Copy Local option above you would get no compression at all for your referenced assemblies.</p>
<p>To get an idea of what I&#8217;m talking about, take a look at the following diagram:</p>
<p><a href="http://www.robertjantuit.nl/wp-content/uploads/2009/01/image2.png"><img src="http://www.robertjantuit.nl/wp-content/uploads/2009/01/image-thumb2.png" style="border-width: 0px" alt="image" border="0" width="497" height="325" /></a></p>
<p>What you are seeing above, is the default packaging on the left, and the ReXapped packaging on the right. I also added the size in Kb. To make the difference a bit more drastic, I put 2 images in MyLibrary, which is packaged twice on the left and only once on the right. This also goes for the System.Xml.Linq.dll assembly. The rest of the reduction in size is due to the fact that 7Zip just does better compression. And if you have more then 2 Applications, and you have lots of shared code and images , which in my experience is usually the case, the reduction will be even greater.</p>
<h2>ReXapper</h2>
<p>Let met start out by saying that the ReXapper name is one I did not think up myself, I have seen it many times already around the web, but why change a good name, right?</p>
<p>The ReXapper is a Console application, which is run After Build on both MySilverlightApplications. It receives the parameters from the build events, and starts ReXapping the applications.</p>
<p>It should be run with the following parameters:<br />
<em>ReXapper.exe [7ZipLocation] [projectName] [projectTargetDir] [silverlightTargetDir]<br />
</em><br />
When used in the After Build event it would be:<br />
$(SolutionDir)ReXapper\bin\debug\ReXapper.exe<br />
$(SolutionDir)7za.exe<br />
$(ProjectName)<br />
$(TargetDir)<br />
$(SolutionDir)DynamicAssemblyLoading.Web\ClientBin</p>
<p>The code for the Rexapper is a bit too big to completely go over right now, but here are a few higlights. You can download the full source code below.</p>
<h4>Saving AppManifest.xaml from an XDocument</h4>
<p>The AppManifest does not have a xml starting tag. If added, the Silverlight Plugin will fail to load, and of course &lt;?xml is added by default when saving a XDocument <img src='http://www.robertjantuit.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The solution is using the XMLWriter with XmlWritersettings having OmitDeclaration = true. Check the SaveXDocumentWithoutXmlDeclaration method in the code.</p>
<h4>Changing and not creating the AppManifest</h4>
<p>Because I ran into a few problems, creating a new AppManifest from scratch I decided to reuse the ogirinal one and change it to meet the needs.</p>
<h2>Lots of Linq and Lambdas</h2>
<p>I have become such a fan of Linq and Lambdas that you will see me using it wherever I can, probably even in places where it&#8217;s not necessary, I just love to use them <img src='http://www.robertjantuit.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Next</h2>
<p>Now we have the new xap files, we can run the application and see that they work. Of course you cannot yet use the Referenced assemblies like the System.Linq.Xml and MyLibrary, but because they are not yet used in the code, Silverlight will not trow any errors.</p>
<p>In Part 2, ready hopefully somewhere next week, we will read our custom created ReferencedAssemblies.xaml from our xap, load all the referenced assemblies from their respective .xap files, and use resources from MyLibrary in our Applications.</p>
<p><a href="http://www.robertjantuit.nl/wp-content/uploads/2009/01/robertjantuitnl-sl2-dynamicassemblyloading.zip">Click here to download the source code in it&#8217;s current state.</a></p>
<p>Stay in the light!</p>
<p>Robertjan Tuit</p>
<p style="margin: 0px; padding: 0px; display: inline" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3c0b2918-8d6a-4282-b602-d18245e9bfbf" class="wlWriterSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight%202" rel="tag">Silverlight 2</a></p>
<p>*UPDATE: <a href="http://www.robertjantuit.nl/index.php/2009/03/06/silverlight-2-dynamic-assembly-loading-part-2/">Click here to view part 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/01/30/silverlight-2-dynamic-assembly-loading-part-1/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/01/30/silverlight-2-dynamic-assembly-loading-part-1/</feedburner:origLink></item>
		<item>
		<title>Silverlight 2 Image Tiling</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/O5JXBC9FtFQ/</link>
		<comments>http://www.robertjantuit.nl/index.php/2009/01/28/silverlight-2-image-tiling/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 15:07:54 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2009/01/28/silverlight-2-image-tiling/</guid>
		<description><![CDATA[
Silverlight&#8217;s big brother WPF has a lot of functionality that you would like to have in Silverlight 2. One of these features is a Tiling Image Brush.
As many of you have probably already found out, it is impossible to create your own brush in Silverlight, because of internal and sealed base classes.
A couple of months [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Silverlight&#8217;s big brother WPF has a lot of functionality that you would like to have in Silverlight 2. One of these features is a Tiling Image Brush.</p>
<p>As many of you have probably already found out, it is impossible to create your own brush in Silverlight, because of internal and sealed base classes.</p>
<p>A couple of months a go I was working on a project which required images being tiled across the screen, so I decided to create a tiling control, which takes an image and puts as many as fit the screen into a wrap panel (from the <a href="http://www.codeplex.com/Silverlight">silverlight control toolkit</a>).</p>
<p>Since then I have seen a lot of people asking for this functionality, I though I would share this very simple (user) control. Below is the code, let me know if you have any questions or remarks.</p>
<p>There are still a few improvements you could make to this code. For example determining the width and height of the image automatically. But to keep it simple I left that code out.</p>
<p>The image used in this example is a random one I took from Google image search:</p>
<p><img src="http://ecx.images-amazon.com/images/I/51sghWRypwL._SL75_SS50_.jpg" /></p>
<p>When finished it should look like something like this:</p>
<p><a href="http://www.robertjantuit.nl/wp-content/uploads/2009/01/image.png" rel="lightbox"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.robertjantuit.nl/wp-content/uploads/2009/01/image-thumb.png" width="400" height="350" /></a></p>
<p><em>In the application: (local namespace should be added to the top of the xaml)</em></p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px">&lt;l<span style="color: yellow">ocal</span>:<span style="color: yellow">ImageRepeater</span></p>
<p style="margin: 0px">&#160;&#160; <span style="color: #dfdfbf">ImageSource</span>=<span style="color: white; font-weight: bold">&quot;http://ecx.images-amazon.com/images/I/51sghWRypwL._SL75_SS50_.jpg&quot;</span></p>
<p style="margin: 0px">&#160;&#160; <span style="color: #dfdfbf">ImageWidth</span>=<span style="color: white; font-weight: bold">&quot;50&quot;</span></p>
<p style="margin: 0px">&#160;&#160; <span style="color: #dfdfbf">ImageHeight</span>=<span style="color: white; font-weight: bold">&quot;50&quot;</span>/&gt;</p>
<p style="margin: 0px">
</p></div>
<p><em>UserControl: <strong>ImageRepeater.xaml</strong></em></p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px">&lt;<span style="color: yellow">UserControl</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Class</span>=<span style="color: white; font-weight: bold">&quot;ImageRepeater&quot;</span></p>
<p style="margin: 0px">&#160;&#160; <span style="color: #dfdfbf">xmlns</span>=<span style="color: white; font-weight: bold">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></p>
<p style="margin: 0px">&#160;&#160; <span style="color: #dfdfbf">xmlns</span>:<span style="color: #dfdfbf">x</span>=<span style="color: white; font-weight: bold">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></p>
<p style="margin: 0px">&#160;&#160; <span style="color: #dfdfbf">xmlns</span>:<span style="color: #dfdfbf">controls</span>=<span style="color: white; font-weight: bold">&quot;clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls&quot;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; &gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Grid</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;LayoutRoot&quot;</span><span style="color: #dfdfbf"> Background</span>=<span style="color: white; font-weight: bold">&quot;White&quot;</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">controls</span>:<span style="color: yellow">WrapPanel</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;xRepeaterPanel&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;/<span style="color: yellow">Grid</span>&gt;</p>
<p style="margin: 0px">
</p></div>
<p style="margin: 0px">&lt;/<span style="color: yellow">UserControl</span>&gt;</p>
<div>
<p><em>UserControl: </em><em><strong>ImageRepeater.xaml.cs</strong></em></p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">partial</span> <span style="color: #80ff80; font-weight: bold">class</span> <span style="color: #80ffff">ImageRepeater</span> : <span style="color: #80ffff">UserControl</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #ffff80">ImageRepeater</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">InitializeComponent</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: lime">// The brush to paint on the rectangle</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ffff">ImageBrush</span> <span style="color: #ffff80">_BrushToTile</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">ImageBrush</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ffff">ImageSource</span> <span style="color: #ffff80">ImageSource</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">get</span> { <span style="color: #80ff80; font-weight: bold">return</span> <span style="color: #ffff80">_BrushToTile</span>.<span style="color: #ffff80">ImageSource</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">set</span> {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">_BrushToTile</span>.<span style="color: #ffff80">ImageSource</span> = <span style="color: #80ff80; font-weight: bold">value</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">_ImageWidth</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">ImageWidth</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">get</span> { <span style="color: #80ff80; font-weight: bold">return</span> <span style="color: #ffff80">_ImageWidth</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">set</span> { <span style="color: #ffff80">_ImageWidth</span> = <span style="color: #80ff80; font-weight: bold">value</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">_ImageHeight</span>;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">ImageHeight</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">get</span> { <span style="color: #80ff80; font-weight: bold">return</span> <span style="color: #ffff80">_ImageHeight</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">set</span> { <span style="color: #ffff80">_ImageHeight</span> = <span style="color: #80ff80; font-weight: bold">value</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">protected</span> <span style="color: #80ff80; font-weight: bold">override</span> <span style="color: #f0dfaf">Size</span> <span style="color: #ffff80">ArrangeOverride</span>(<span style="color: #f0dfaf">Size</span> <span style="color: #ffff80">finalSize</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: lime">// To make sure that we fill the screen horizontally and vertically, we create negative margins</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">Margin</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #f0dfaf">Thickness</span>(<span style="color: #8acccf">0</span>, <span style="color: #8acccf">0</span>, -<span style="color: #ffff80">ImageHeight</span>, -<span style="color: #ffff80">ImageWidth</span>);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: lime">// Determine how many rectangles we need to add to fill the available screen width</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">itemCount</span> = (<span style="color: #80ff80; font-weight: bold">int</span>)<span style="color: #80ffff">Math</span>.<span style="color: #ffff80">Ceiling</span>(<span style="color: #ffff80">finalSize</span>.<span style="color: #ffff80">Width</span> / <span style="color: #ffff80">ImageWidth</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">itemCount</span> = <span style="color: #ffff80">itemCount</span> * (<span style="color: #80ff80; font-weight: bold">int</span>)<span style="color: #80ffff">Math</span>.<span style="color: #ffff80">Ceiling</span>(<span style="color: #ffff80">finalSize</span>.<span style="color: #ffff80">Height</span> / <span style="color: #ffff80">ImageHeight</span>);</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: lime">// It is done incrementally, so when the control is resized, we add more to it so fill the area again.</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">diff</span> = <span style="color: #ffff80">itemCount</span> - <span style="color: #ffff80">xRepeaterPanel</span>.<span style="color: #ffff80">Children</span>.<span style="color: #ffff80">Count</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">for</span> (<span style="color: #80ff80; font-weight: bold">int</span> <span style="color: #ffff80">i</span> = <span style="color: #8acccf">0</span>; <span style="color: #ffff80">i</span> &lt; <span style="color: #ffff80">diff</span>; <span style="color: #ffff80">i</span>++)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: lime">// Create and add every rectangle</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">rect</span> = <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">Rectangle</span>();</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">rect</span>.<span style="color: #ffff80">Width</span> = <span style="color: #ffff80">ImageWidth</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">rect</span>.<span style="color: #ffff80">Height</span> = <span style="color: #ffff80">ImageHeight</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">rect</span>.<span style="color: #ffff80">Fill</span> = <span style="color: #ffff80">_BrushToTile</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">xRepeaterPanel</span>.<span style="color: #ffff80">Children</span>.<span style="color: #ffff80">Add</span>(<span style="color: #ffff80">rect</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">return</span> <span style="color: #80ff80; font-weight: bold">base</span>.<span style="color: #ffff80">ArrangeOverride</span>(<span style="color: #ffff80">finalSize</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">}</p>
</p></div>
</p></div>
</p></div>
<div>
<p>Stay in the light!</p>
<p>Robertjan Tuit</p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2009/01/28/silverlight-2-image-tiling/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2009/01/28/silverlight-2-image-tiling/</feedburner:origLink></item>
		<item>
		<title>Goodbye Europe, Hello North America!</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/MRRCSpHX-bg/</link>
		<comments>http://www.robertjantuit.nl/index.php/2008/11/02/goodbye-europe-hello-north-america/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 20:52:38 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2008/11/02/goodbye-europe-hello-north-america/</guid>
		<description><![CDATA[I know I have been quiet lately, one of the effect of my move to Vancouver BC, Canada.
As some of you may know, I was asked to come and work for Microsoft, first in Vancouver B.C. Canada, and later to Redmond WA, USA.
So here I finally am, Downtown Vancouver, on the 16th floor&#160; of this [...]]]></description>
			<content:encoded><![CDATA[<p>I know I have been quiet lately, one of the effect of my move to Vancouver BC, Canada.</p>
<p><a href="http://www.robertjantuit.nl/wp-content/uploads/2008/11/img-1171.jpg"><img style="border-right-width: 0px; margin: 0px 0px 20px 20px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="IMG_1171" align="right" src="http://www.robertjantuit.nl/wp-content/uploads/2008/11/img-1171-thumb.jpg" width="185" height="140" /></a>As some of you may know, I was asked to come and work for Microsoft, first in Vancouver B.C. Canada, and later to Redmond WA, USA.</p>
<p>So here I finally am, Downtown Vancouver, on the 16th floor&#160; of this great apartment, finally having the time to get my blog up and running again. Everything went very smooth until now, so I guess all the preparations were worth it.</p>
<p>Just to get something straight, getting the Borg chip implemented will absolutely not stop me from blogging and I hope to blog more than I ever did. About my experiences here and of course to get as many Silverlight 2 info out there as possible.</p>
<p>For the Dutch people reading this, you can view one of my projects on American Election night. A Video player showing and playing Nbc, Fox, Ned 1 and Radio1. Visit <a href="http://amerikakiest.nos.nl">http://amerikakiest.nos.nl</a> on election night. Only viewable from inside the Netherlands.</p>
<p>Stay in the Light!</p>
<p>Robertjan Tuit</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0f21370e-d4a3-4544-8055-f44b0318c769" class="wlWriterSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight%202" rel="tag">Silverlight 2</a>,<a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Vancouver" rel="tag">Vancouver</a>,<a href="http://technorati.com/tags/Microsoft" rel="tag">Microsoft</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2008/11/02/goodbye-europe-hello-north-america/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2008/11/02/goodbye-europe-hello-north-america/</feedburner:origLink></item>
		<item>
		<title>Software Development Conference 2008</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/9qnrbSwIkyM/</link>
		<comments>http://www.robertjantuit.nl/index.php/2008/09/20/software-development-conference-2008/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 14:35:46 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2008/09/20/software-development-conference-2008/</guid>
		<description><![CDATA[The 6th and 7th of October, we are organizing our 17th! SDN Conference. 2 days of international and national speakers. Be sure to be there for I believe that this year is going to be one of the best ones we ever did!
So if you haven&#8217;t gotten a ticket yet get it here
See you there!
 [...]]]></description>
			<content:encoded><![CDATA[<p>The 6th and 7th of October, we are organizing our 17th! <a href="http://www.sdc.nl">SDN Conference</a>. 2 days of international and national speakers. Be sure to be there for I believe that this year is going to be one of the best ones we ever did!</p>
<p>So if you haven&#8217;t gotten a ticket yet <a href="http://www.sdc.nl/Default.aspx?tabid=77&amp;language=en-US">get it here</a></p>
<p>See you there!</p>
<p><a href="http://www.sdc.nl"><img src="http://www.sdc.nl/Portals/0/images/SDN-08-EN.jpg" width="484" height="242" /></a> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2008/09/20/software-development-conference-2008/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2008/09/20/software-development-conference-2008/</feedburner:origLink></item>
		<item>
		<title>Storyboard Animation for the ScrollViewer: AnimationHelperControl</title>
		<link>http://feedproxy.google.com/~r/RobsWorld/~3/vRv6rN0qVIc/</link>
		<comments>http://www.robertjantuit.nl/index.php/2008/09/13/storyboard-animation-for-the-scrollviewer-animationhelpercontrol/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 18:41:37 +0000</pubDate>
		<dc:creator>robertjantuit</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.robertjantuit.nl/index.php/2008/09/13/storyboard-animation-for-the-scrollviewer-animationhelpercontrol/</guid>
		<description><![CDATA[
The Scrollviewer is a great panel and very easy to use. But it has a drawback. It uses a method to set the scrollbars and content position. This means you cannot use a storyboard animation to animate this.
I had 2 projects that required this functionality, and really needed a better solutions then using a DispatcherTimer [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>The Scrollviewer is a great panel and very easy to use. But it has a drawback. It uses a method to set the scrollbars and content position. This means you cannot use a storyboard animation to animate this.</p>
<p>I had 2 projects that required this functionality, and really needed a better solutions then using a DispatcherTimer to create the animation manually. And after a few good nights of sleep (I always have the best ideas after a good nights rest) I came up with what I think is a nice solution.</p>
<p>The idea is that you need a DependencyProperty to animate a Scrollviewer. But since the ScrollViewer is a Sealed control you can&#8217;t inherit from it, I needed to wrap a new control around it to make it reusable.</p>
<p>So I took a different approach, I created a AnimationHelperControl, which does not have any visuals but only has a Dependency property and an event that is fired when this property has been changed. In this way you can use it to control anything you want.</p>
<p>Below the source code for the control:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">class</span> <span style="color: #80ffff">AnimationHelperControl</span> : <span style="color: #80ffff">Control</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #ffff80">AnimationHelperControl</span>()</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">Visibility</span> = <span style="color: #f0dfaf">Visibility</span>.<span style="color: #ffff80">Collapsed</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">DoubleValue</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">get</span> { <span style="color: #80ff80; font-weight: bold">return</span> (<span style="color: #80ff80; font-weight: bold">double</span>)<span style="color: #ffff80">GetValue</span>(<span style="color: #ffff80">DoubleValueProperty</span>); }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">set</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">SetValue</span>(<span style="color: #ffff80">DoubleValueProperty</span>, <span style="color: #80ff80; font-weight: bold">value</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">DoubleValueChanged</span>(<span style="color: #80ff80; font-weight: bold">value</span>);</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">static</span> <span style="color: #80ff80; font-weight: bold">readonly</span> <span style="color: #80ffff">DependencyProperty</span> <span style="color: #ffff80">DoubleValueProperty</span> =</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ffff">DependencyProperty</span>.<span style="color: #ffff80">Register</span>(<span style="color: #c89191">&quot;DoubleValue&quot;</span>, <span style="color: #80ff80; font-weight: bold">typeof</span>(<span style="color: #80ff80; font-weight: bold">double</span>), <span style="color: #80ff80; font-weight: bold">typeof</span>(<span style="color: #80ffff">AnimationHelperControl</span>), <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">PropertyMetadata</span>((<span style="color: #ffff80">sender</span>, <span style="color: #ffff80">e</span>) =&gt;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">if</span> (<span style="color: #ffff80">e</span>.<span style="color: #ffff80">OldValue</span> != <span style="color: #ffff80">e</span>.<span style="color: #ffff80">NewValue</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">var</span> <span style="color: #ffff80">ah</span> = (<span style="color: #80ffff">AnimationHelperControl</span>)<span style="color: #ffff80">sender</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">ah</span>.<span style="color: #ffff80">DoubleValue</span> = (<span style="color: #80ff80; font-weight: bold">double</span>)<span style="color: #ffff80">e</span>.<span style="color: #ffff80">NewValue</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }));</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">event</span> <span style="color: #f0dfaf">EventHandler</span>&lt;<span style="color: #80ffff">DoubleEventArgs</span>&gt; <span style="color: #ffff80">DoubleValueChange</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">void</span> <span style="color: #ffff80">DoubleValueChanged</span>(<span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">newValue</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">if</span> (<span style="color: #ffff80">DoubleValueChange</span> != <span style="color: #80ff80; font-weight: bold">null</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #ffff80">DoubleValueChange</span>(<span style="color: #80ff80; font-weight: bold">this</span>, <span style="color: #80ff80; font-weight: bold">new</span> <span style="color: #80ffff">DoubleEventArgs</span>() { <span style="color: #ffff80">Value</span> = <span style="color: #ffff80">newValue</span> });</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">class</span> <span style="color: #80ffff">DoubleEventArgs</span> : <span style="color: #80ffff">EventArgs</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">private</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">_Value</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">public</span> <span style="color: #80ff80; font-weight: bold">double</span> <span style="color: #ffff80">Value</span></p>
<p style="margin: 0px">&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">get</span> { <span style="color: #80ff80; font-weight: bold">return</span> <span style="color: #ffff80">_Value</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">set</span> { <span style="color: #ffff80">_Value</span> = <span style="color: #80ff80; font-weight: bold">value</span>; }</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Then you add the control, the scrollviewer and 2 buttons to the page.xaml:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px">&lt;<span style="color: yellow">Grid</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;LayoutRoot&quot;</span><span style="color: #dfdfbf"> Background</span>=<span style="color: white; font-weight: bold">&quot;White&quot;</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Grid.RowDefinitions</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">RowDefinition</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;0.853*&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">RowDefinition</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;0.147*&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;/<span style="color: yellow">Grid.RowDefinitions</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;<span style="color: yellow">local</span>:<span style="color: yellow">AnimationHelperControl</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;xScrollViewerHorizontalOffset&quot; </span><span style="color: #dfdfbf">Grid.RowSpan</span>=<span style="color: white; font-weight: bold">&quot;2&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Grid</span><span style="color: #dfdfbf"> Grid.RowSpan</span>=<span style="color: white; font-weight: bold">&quot;1&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,0,0&quot;</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">ScrollViewer</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;xScrollViewer&quot;</span><span style="color: #dfdfbf"> VerticalScrollBarVisibility</span>=<span style="color: white; font-weight: bold">&quot;Hidden&quot;</span><span style="color: #dfdfbf"> HorizontalScrollBarVisibility</span>=<span style="color: white; font-weight: bold">&quot;Hidden&quot;</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">ScrollViewer.Content</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">StackPanel</span><span style="color: #dfdfbf"> Orientation</span>=<span style="color: white; font-weight: bold">&quot;Horizontal&quot;</span><span style="color: #dfdfbf"> HorizontalAlignment</span>=<span style="color: white; font-weight: bold">&quot;Left&quot;</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Red&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;20,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Blue&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Green&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Purple&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Black&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Yellow&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Rectangle</span><span style="color: #dfdfbf"> Fill</span>=<span style="color: white; font-weight: bold">&quot;Cyan&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;300&quot;</span><span style="color: #dfdfbf"> Height</span>=<span style="color: white; font-weight: bold">&quot;200&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,0,20,0&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/<span style="color: yellow">StackPanel</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/<span style="color: yellow">ScrollViewer.Content</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/<span style="color: yellow">ScrollViewer</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;/<span style="color: yellow">Grid</span>&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Button</span><span style="color: #dfdfbf"> HorizontalAlignment</span>=<span style="color: white; font-weight: bold">&quot;Left&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;8,8,0,8&quot;</span><span style="color: #dfdfbf"> VerticalAlignment</span>=<span style="color: white; font-weight: bold">&quot;Stretch&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;65&quot;</span><span style="color: #dfdfbf"> Content</span>=<span style="color: white; font-weight: bold">&quot;Left&quot;</span><span style="color: #dfdfbf"> Grid.Row</span>=<span style="color: white; font-weight: bold">&quot;1&quot;</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;xButtonLeft&quot;</span>/&gt;</p>
<p style="margin: 0px"><span style="color: #c89191">&#160;&#160;&#160; </span>&lt;<span style="color: yellow">Button</span><span style="color: #dfdfbf"> HorizontalAlignment</span>=<span style="color: white; font-weight: bold">&quot;Right&quot;</span><span style="color: #dfdfbf"> Margin</span>=<span style="color: white; font-weight: bold">&quot;0,8,8,8&quot;</span><span style="color: #dfdfbf"> VerticalAlignment</span>=<span style="color: white; font-weight: bold">&quot;Stretch&quot;</span><span style="color: #dfdfbf"> Width</span>=<span style="color: white; font-weight: bold">&quot;66&quot;</span><span style="color: #dfdfbf"> Content</span>=<span style="color: white; font-weight: bold">&quot;Right&quot;</span><span style="color: #dfdfbf"> Grid.Row</span>=<span style="color: white; font-weight: bold">&quot;1&quot;</span><span style="color: #dfdfbf"> x</span>:<span style="color: #dfdfbf">Name</span>=<span style="color: white; font-weight: bold">&quot;xButtonRight&quot;</span>/&gt;</p>
<p style="margin: 0px">&lt;/<span style="color: yellow">Grid</span>&gt;</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>Remember to the &quot;local&quot; namespace to the xaml.</p>
<p>Then we add the event handler to the page.xaml.cs:</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #ffff80">xScrollViewerHorizontalOffset</span>.<span style="color: #ffff80">DoubleValueChange</span> += (<span style="color: #ffff80">sender</span>, <span style="color: #ffff80">e</span>) =&gt;</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #80ff80; font-weight: bold">this</span>.<span style="color: #ffff80">xScrollViewer</span>.<span style="color: #ffff80">ScrollToHorizontalOffset</span>(<span style="color: #ffff80">e</span>.<span style="color: #ffff80">Value</span>);</p>
<p style="margin: 0px">};</p>
</p></div>
<p>Now you could create storyboard animation on the DoubleValue property of the xScrollViewerHorizontalOffset control, but to keep it short and simple I&#8217;ll use the A<a href="http://www.robertjantuit.nl/index.php/2008/08/13/animateto-extension-methods-in-silverlight-2/">nimateTo extension method of one of my previous posts</a>, which accomplishes the same, only it does it with code. Let&#8217;s use the 2 buttons to animate scrolling left and right.</p>
<div style="padding-bottom: 5px; padding-left: 5px; width: 100%; padding-right: 5px; font-family: consolas; white-space: nowrap; background: #2e2e2e; color: #d2d200; font-size: 10pt; overflow: auto; padding-top: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: #ffff80">xButtonRight</span>.<span style="color: #ffff80">Click</span> += (<span style="color: #ffff80">sender</span>, <span style="color: #ffff80">e</span>) =&gt;</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">xScrollViewerHorizontalOffset</span>.<span style="color: #ffff80">AnimateDoubleTo</span>(<span style="color: #8acccf">200</span>, <span style="color: #c89191">&quot;(StoryboardAnimationHelper.DoubleValue)&quot;</span>, <span style="color: #ffff80">xScrollViewer</span>.<span style="color: #ffff80">HorizontalOffset</span> + <span style="color: #8acccf">320</span>);</p>
<p style="margin: 0px">};</p>
<p style="margin: 0px"><span style="color: #ffff80">xButtonLeft</span>.<span style="color: #ffff80">Click</span> += (<span style="color: #ffff80">sender</span>, <span style="color: #ffff80">e</span>) =&gt;</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #ffff80">xScrollViewerHorizontalOffset</span>.<span style="color: #ffff80">AnimateDoubleTo</span>(<span style="color: #8acccf">200</span>, <span style="color: #c89191">&quot;(StoryboardAnimationHelper.DoubleValue)&quot;</span>, <span style="color: #ffff80">xScrollViewer</span>.<span style="color: #ffff80">HorizontalOffset</span> - <span style="color: #8acccf">320</span>);</p>
<p style="margin: 0px">};</p>
<p style="margin: 0px">&#160;</p>
</p></div>
<p>That should do the trick I&#8217;ll try to upload a Demo Project later this weekend.</p>
<p>Stay in the light!</p>
<p>Robertjan Tuit</p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.robertjantuit.nl/index.php/2008/09/13/storyboard-animation-for-the-scrollviewer-animationhelpercontrol/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.robertjantuit.nl/index.php/2008/09/13/storyboard-animation-for-the-scrollviewer-animationhelpercontrol/</feedburner:origLink></item>
	</channel>
</rss>
