<?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"?><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:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>Jeff Wilcox</title>
	
	<link>http://www.jeff.wilcox.name</link>
	<description>Silverlight, rich client apps and web development</description>
	<lastBuildDate>Thu, 05 Nov 2009 00:18:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/JeffWilcox" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>The Silverlight Toolkit – now in the Microsoft Web Platform Installer</title>
		<link>http://www.jeff.wilcox.name/2009/11/toolkit-webpi/</link>
		<comments>http://www.jeff.wilcox.name/2009/11/toolkit-webpi/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 00:18:04 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/11/toolkit-webpi/</guid>
		<description><![CDATA[It’s now even easier to get started with the Silverlight Toolkit, an excellent complement to your Silverlight development environment. The latest Silverlight 3 release of the Silverlight Toolkit is now available on the Web PI. It is now the recommended way of getting the toolkit.
 
Here’s a link to the installer, if you don’t already [...]]]></description>
			<content:encoded><![CDATA[<p>It’s now even easier to get started with the Silverlight Toolkit, an excellent complement to your Silverlight development environment. The latest Silverlight 3 release of the Silverlight Toolkit is now available on the Web PI. It is now the recommended way of getting the toolkit.</p>
<p><a href="http://www.microsoft.com/web/gallery/install.aspx?appid=SilverlightToolkit"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="btn-free-webpi" border="0" alt="btn-free-webpi" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/btnfreewebpi1.png" width="182" height="43" /></a> </p>
<p>Here’s a link to the installer, if you don’t already have it on your system: <a title="http://www.microsoft.com/web/downloads/platform.aspx" href="http://www.microsoft.com/web/downloads/platform.aspx">http://www.microsoft.com/web/downloads/platform.aspx</a> </p>
<p>Jump right to the toolkit install here: <a title="http://www.microsoft.com/web/gallery/install.aspx?appid=SilverlightToolkit" href="http://www.microsoft.com/web/gallery/install.aspx?appid=SilverlightToolkit">http://www.microsoft.com/web/gallery/install.aspx?appid=SilverlightToolkit</a>    <br /><em>Or</em>, a Twitter-friendly link: <a title="http://bit.ly/3eaT68" href="http://bit.ly/3eaT68">http://bit.ly/3eaT68</a></p>
<h3>Simple installation experience</h3>
<p>It’s quick and easy now to use the Silverlight Toolkit – no need to jump over to the <a href="http://silverlight.codeplex.com/">CodePlex site</a>.</p>
<p><a href="http://www.microsoft.com/web/gallery/install.aspx?appid=SilverlightToolkit"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="WebPi1" border="0" alt="WebPi1" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/WebPi11.png" width="680" height="511" /></a> </p>
<p>Once starting the Web Platform Installer, you’ll find the Silverlight Toolkit under the ‘Web Platform’ tab, in the ‘Tools’ section:</p>
<p><a href="http://www.microsoft.com/web/gallery/install.aspx?appid=SilverlightToolkit"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="WebPi3" border="0" alt="WebPi3" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/WebPi3.png" width="680" height="511" /></a> </p>
<p>The installation should only take a few seconds. Afterwards, you’ll find the controls inside Expression Blend 3, Visual Studio 2008 SP1 with the Silverlight Tools installed, and Visual Studio 2010 Beta 2.</p>
<h3>About the Silverlight Toolkit</h3>
<p>In case you’ve never used the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a>, it’s never too late to start. The following controls have been part of the Silverlight Toolkit development process. You can find out more about the <a href="http://silverlight.codeplex.com/wikipage?title=Quality%20Bands&amp;referringTitle=Home">quality bands here</a>.     <br /> <br />
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="319">
<p><b>Mature/SDK/Runtime</b></p>
<p>AutoCompleteBox              <br />Calendar               <br />ChildWindow               <br />DataGrid               <br />DataPager               <br />DatePicker               <br />GridSplitter               <br />HeaderedItemsControl               <br />TabControl               <br />TreeView</p>
</td>
<td valign="top" width="319">
<p><b>Stable</b>               <br />DockPanel               <br />Expander               <br />HeaderedContentControl               <br />Label               <br />NumericUpDown               <br />Viewbox               <br />WrapPanel</p>
</td>
</tr>
<tr>
<td valign="top" width="319">
<p><b>Preview</b>               <br />Accordion               <br />Charting               <br />DataForm               <br />DomainUpDown               <br />ImplicitStyleManager               <br />LayoutTransformer               <br />Rating               <br />TimePicker               <br />TimeUpDown               <br /><i>11 designer visual themes</i></p>
</td>
<td valign="top" width="319">
<p><b>Experimental</b>               <br />GlobalCalendar               <br />TransitioningContentControl               <br />TreeMap               <br />Drag and Drop support for items controls</p>
</td>
</tr>
</tbody>
</table>
<p><strong>More resources:</strong></p>
<ul>
<li>You can also find the source code <a href="http://silverlight.codeplex.com/SourceControl/ListDownloadableCommits.aspx">online here</a>. </li>
<li>Check out the <a href="http://forums.silverlight.net/forums/35.aspx">Silverlight.net discussion forums for the controls</a> </li>
<li>There is an <a href="http://www.codeplex.com/Silverlight/WorkItem/List.aspx">issue tracker page on CodePlex</a> for reporting and voting on issues </li>
<li>Read the <a href="http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20October%202009%20change%20list">changes between the July 2009 and October 2009 releases</a> </li>
</ul>
<p>You can also find out more about the Web Platform <a href="http://www.microsoft.com/web/">here</a> and <a href="http://weblogs.asp.net/scottgu/archive/2009/06/02/microsoft-web-platform-installer.aspx">here</a>. Hope this helps!</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Btitle%3DThe%2520Silverlight%2520Toolkit%2520%2526ndash%253B%2520now%2520in%2520the%2520Microsoft%2520Web%2520Platform%2520Installer';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Btitle%3DThe%2520Silverlight%2520Toolkit%2520%2526ndash%253B%2520now%2520in%2520the%2520Microsoft%2520Web%2520Platform%2520Installer%26amp%3Bbodytext%3DIt%25E2%2580%2599s%2520now%2520even%2520easier%2520to%2520get%2520started%2520with%2520the%2520Silverlight%2520Toolkit%252C%2520an%2520excellent%2520complement%2520to%2520your%2520Silverlight%2520development%2520environment.%2520The%2520latest%2520Silverlight%25203%2520release%2520of%2520the%2520Silverlight%2520Toolkit%2520is%2520now%2520available%2520on%2520the%2520Web%2520PI.%2520It%2520is%2520now%2520the%2520recomme';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Btitle%3DThe%2520Silverlight%2520Toolkit%2520%2526ndash%253B%2520now%2520in%2520the%2520Microsoft%2520Web%2520Platform%2520Installer';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Btitle%3DThe%2520Silverlight%2520Toolkit%2520%2526ndash%253B%2520now%2520in%2520the%2520Microsoft%2520Web%2520Platform%2520Installer%26amp%3Bnotes%3DIt%25E2%2580%2599s%2520now%2520even%2520easier%2520to%2520get%2520started%2520with%2520the%2520Silverlight%2520Toolkit%252C%2520an%2520excellent%2520complement%2520to%2520your%2520Silverlight%2520development%2520environment.%2520The%2520latest%2520Silverlight%25203%2520release%2520of%2520the%2520Silverlight%2520Toolkit%2520is%2520now%2520available%2520on%2520the%2520Web%2520PI.%2520It%2520is%2520now%2520the%2520recomme';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Bt%3DThe%2520Silverlight%2520Toolkit%2520%2526ndash%253B%2520now%2520in%2520the%2520Microsoft%2520Web%2520Platform%2520Installer';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F11%252Ftoolkit-webpi%252F%26amp%3Btitle%3DThe%2520Silverlight%2520Toolkit%2520%2526ndash%253B%2520now%2520in%2520the%2520Microsoft%2520Web%2520Platform%2520Installer%26amp%3Bannotation%3DIt%25E2%2580%2599s%2520now%2520even%2520easier%2520to%2520get%2520started%2520with%2520the%2520Silverlight%2520Toolkit%252C%2520an%2520excellent%2520complement%2520to%2520your%2520Silverlight%2520development%2520environment.%2520The%2520latest%2520Silverlight%25203%2520release%2520of%2520the%2520Silverlight%2520Toolkit%2520is%2520now%2520available%2520on%2520the%2520Web%2520PI.%2520It%2520is%2520now%2520the%2520recomme';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/11/toolkit-webpi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Round-tripping Silverlight 3 projects with Visual Studio 2008 and Visual Studio 2010</title>
		<link>http://www.jeff.wilcox.name/2009/10/roundtripping-silverlight-with-2010/</link>
		<comments>http://www.jeff.wilcox.name/2009/10/roundtripping-silverlight-with-2010/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 04:39:28 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/10/roundtripping-silverlight-with-2010/</guid>
		<description><![CDATA[Here's a simple tool that I use to round-trip Silverlight solutions and projects between Visual Studio 2008 and Visual Studio 2010 Beta. Use it at your own risk, but enjoy!]]></description>
			<content:encoded><![CDATA[<p>Now that Visual Studio 2010 Beta 2 is out, it is a lot of fun to use the fully interactive design surface for Silverlight. However, it comes at a cost: you need to use the conversion wizard to bring your Visual Studio 2008 solutions and projects up to the expected format for the designer tools and new build environment.</p>
<p>If you deliver your source ultimately to a Visual Studio 2008-targeted source project, or have issue adopting a beta product until its release, this is a pain.</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/ThereAndBackAgain.zip"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VsConversion" border="0" alt="VsConversion" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/VsConversion.png" width="680" height="379" /></a> </p>
<p>I wrote a tool last month for round-trip converting Silverlight-specific solutions and .csproj files between the versions, and want to share it as-is, with no warranty, hoping someone finds it useful.</p>
<p>Here are two potential solutions for dealing with the conversion issue, actually the second builds from the first.</p>
<h3>Use Source Control</h3>
<p>If your project is not churning that often in added and removed files, source control is the easiest solution to this problem!</p>
<ul>
<li>Open your solution in Visual Studio 2010</li>
<li>Allow the conversion wizard to complete</li>
<li>When checking in, carefully revert the .csproj and .sln files (assuming no changes to their contents)</li>
</ul>
<p>Easy enough. But not crisp enough!</p>
<h3>Use my hacky program</h3>
<p>Now assuming you are already using source control, then you can consider using my script/tool for performing the round-trip conversion. You <strong>still</strong> want to have everything in source control – you just never know.</p>
<h4>Before we start</h4>
<ul>
<li>This program will work on the <strong>current directory</strong> and <strong>all subdirectories</strong></li>
<li>It will <strong>modify read-only files</strong></li>
<li>It will consider <strong>all .csproj and .sln files</strong>, potentially destroying non-Silverlight project files – so use caution if the current directory or sub-directory contains other project types</li>
<li>This is <strong>C#-only</strong>, though a similar exercise for .vbproj files would not be that bad</li>
<li>This will <strong>delete</strong> .suo and .user files that may contain version-specific binary data, so you may lose your local settings (such as the current startup project you have set locally)</li>
<li>This ‘works on my machine’ and I am not responsible for data loss in any way</li>
<li>This code is not efficient nor elegant. Get over it! I did!</li>
</ul>
<h4>Download the binary and source</h4>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/ThereAndBackAgain.zip"><strong>ThereAndBackAgain.zip</strong></a> [21.8K, Zip]</p>
<p>I have included the source, Ms-PL licensed, because though awful, maybe someone can do something much better with it!</p>
<h4>Convert all C# projects and solutions to Visual Studio 2010</h4>
<p>Move into the root directory of your solution in a command prompt window, and provide the path to the ThereAndBackAgain.exe file. It will recurse the current directory.</p>
<blockquote><p>pushd c:\myEnlistment\myProject\Silverlight\</p>
<p>c:\tools\ThereAndBackAgain.exe <strong>2010</strong> &lt;enter&gt;</p>
</blockquote>
<p>You’ll see a quick list of what is changed. You can run this on a directory tree that is already converted, and it should not be affected.</p>
<h4>Convert back to Visual Studio 2008</h4>
<p>Pretty similar:</p>
<blockquote><p>pushd c:\myEnlistment\myProject\Silverlight\</p>
<p>c:\tools\ThereAndBackAgain.exe <strong>2008</strong> &lt;enter&gt;</p>
</blockquote>
<h4>Final note</h4>
<p>This works for me. Uh and so no promises beyond that. I <strong>literally just diff’d a new VS 08 and VS 2010 Silverlight project and wrote something to move between the two. </strong>Nothing fancy.</p>
<p><em>If you go this route, remember to convert back your projects and solutions using the tool before checking in! You don’t want to break the build, or a teammates’ development experience.</em></p>
<p>Hope this helps. Again, I wrote this script specifically to meet my needs, but it is FAR from production-ready. You are on your own, feel free to take and run with this.</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Btitle%3DRound-tripping%2520Silverlight%25203%2520projects%2520with%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Btitle%3DRound-tripping%2520Silverlight%25203%2520projects%2520with%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010%26amp%3Bbodytext%3DHere%2527s%2520a%2520simple%2520tool%2520that%2520I%2520use%2520to%2520round-trip%2520Silverlight%2520solutions%2520and%2520projects%2520between%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010%2520Beta.%2520Use%2520it%2520at%2520your%2520own%2520risk%252C%2520but%2520enjoy%2521';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Btitle%3DRound-tripping%2520Silverlight%25203%2520projects%2520with%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Btitle%3DRound-tripping%2520Silverlight%25203%2520projects%2520with%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010%26amp%3Bnotes%3DHere%2527s%2520a%2520simple%2520tool%2520that%2520I%2520use%2520to%2520round-trip%2520Silverlight%2520solutions%2520and%2520projects%2520between%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010%2520Beta.%2520Use%2520it%2520at%2520your%2520own%2520risk%252C%2520but%2520enjoy%2521';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Bt%3DRound-tripping%2520Silverlight%25203%2520projects%2520with%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Froundtripping-silverlight-with-2010%252F%26amp%3Btitle%3DRound-tripping%2520Silverlight%25203%2520projects%2520with%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010%26amp%3Bannotation%3DHere%2527s%2520a%2520simple%2520tool%2520that%2520I%2520use%2520to%2520round-trip%2520Silverlight%2520solutions%2520and%2520projects%2520between%2520Visual%2520Studio%25202008%2520and%2520Visual%2520Studio%25202010%2520Beta.%2520Use%2520it%2520at%2520your%2520own%2520risk%252C%2520but%2520enjoy%2521';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/10/roundtripping-silverlight-with-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Application Library Caching support for the Silverlight Toolkit</title>
		<link>http://www.jeff.wilcox.name/2009/10/toolkit-extmaps/</link>
		<comments>http://www.jeff.wilcox.name/2009/10/toolkit-extmaps/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 07:50:53 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/10/toolkit-extmaps/</guid>
		<description><![CDATA[Here are the application library cache files needed to reduce the size of your Silverlight 3 application's size when using the Silverlight Toolkit.]]></description>
			<content:encoded><![CDATA[<p>We previously received user feedback that we should ship the Application Library Caching manifest files along with the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a>, to help reduce the size of .Xap files and cache the important libraries for future use in applications.</p>
<p>This advanced feature in Silverlight 3 allows libraries that your app depends on to be delivered outside the primary .Xap for your app, allowing the browser to cache the extensions for future use. This will speed up the startup experience for your frequent users if you update the app but don’t have changes to those libraries – it can save you bandwidth costs when hosting on a CDN, too!</p>
<p>We haven’t able to get the files included in the setup experience yet, so I wanted to share with the community the .extmap.xml files to use the feature before we release it in a future Silverlight Toolkit release.</p>
<p>Yes, the next release will have this feature built-in, so this is a stop-gap. Great details on how the feature works <a href="http://timheuer.com/blog/archive/2009/07/13/silverlight-3-cached-assembly-feature.aspx">here</a>.</p>
<h3>What a library cache file looks like</h3>
<p>The XML file is quite basic: it lists the assembly name, assembly version, public key token, and then the path information. Here’s the <strong>System.Windows.Controls.Toolkit.extmap.xml</strong> file:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:b172cd01-de3c-46a5-b4eb-ea5ec30b65af" class="wlWriterEditableSmartContent">
<pre class="xml" name="code">&lt;?xml version="1.0"?&gt;
&lt;manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;assembly&gt;
    &lt;name&gt;System.Windows.Controls.Toolkit&lt;/name&gt;
    &lt;version&gt;2.0.5.0&lt;/version&gt;
    &lt;publickeytoken&gt;31bf3856ad364e35&lt;/publickeytoken&gt;
    &lt;relpath&gt;System.Windows.Controls.Toolkit.dll&lt;/relpath&gt;
    &lt;extension downloadUri="System.Windows.Controls.Toolkit.zip" /&gt;
  &lt;/assembly&gt;
&lt;/manifest&gt;</pre>
</div>
<h3>Downloading and install the files</h3>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/ToolkitApplicationLibraryCacheFiles.zip">Download</a> a ZIP (4 KB) of the extmaps for the toolkit <a href="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/ToolkitApplicationLibraryCacheFiles.zip">here</a>. These files work with both the July 2009 and October 2009 releases of the toolkit, though I’d recommend using the latest available official release!</p>
<p>After downloading, extract the files. For the best experience, copy the files side-by-side with the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> binaries. We added a link to the Binaries folder in the October release of the toolkit to make it quick to get there, too:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="ToolkitBinaries" border="0" alt="ToolkitBinaries" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/ToolkitBinaries.png" width="431" height="548" /> </p>
<p>On my 64-bit machine, the folder is ‘C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Toolkit\Oct09\Bin’</p>
<p>You’ll be asked to elevate when you copy in the extracted .extmap.xml files, as the program location is system-wide. Allow the operation by clicking ‘Continue’:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="DeniedForCopying" border="0" alt="DeniedForCopying" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/DeniedForCopying.png" width="528" height="310" /> </p>
<p>Now you’re ready to go – the Silverlight build tasks will detect the presence of these small XML files and use that information to zip up the dependent libraries for your app.</p>
<h3>How this can help</h3>
<p>Now, I have this amazing Silverlight 3 app that uses the <a href="http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20Overview%20Part%202&amp;referringTitle=Home">charting components from the Silverlight Toolkit</a>:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SampleChartingApp" border="0" alt="SampleChartingApp" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/SampleChartingApp.png" width="680" height="604" /> </p>
<p>When I build the app, I see that the original .Xap file is <strong>345 KB</strong>. This is a debug build of the app, btw.</p>
<p>It includes the toolkit’s charting components, the primary toolkit assembly, plus the control library from the Silverlight SDK.</p>
<p>It is all of great value, but does add up in bytes – and the bytes for those libraries don’t change very often, making them a great target for this caching.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="OriginalSize" border="0" alt="OriginalSize" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/OriginalSize.png" width="680" height="475" /> </p>
<h3>Turning on the feature for your Silverlight Application project</h3>
<p>You need to opt-in to the application library caching feature.</p>
<p>Right-click on your Silverlight application project in Visual Studio (applies the same in Visual Studio 2008 and Visual Studio 2010 Beta 2) and select ‘Properties’</p>
<p>Navigate to the Silverlight tab and check the ‘Reduce XAP size by using application library caching’ box:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SilverlightBuildOptions" border="0" alt="SilverlightBuildOptions" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/SilverlightBuildOptions.png" width="630" height="288" /> </p>
<p>Save the changes and then build your project. Now, we see that there are 3 new .Zip files, and the original .Xap. The .Xap is only <strong>41 KB</strong>, plus the first time someone uses your application from the server, their browser will also go ahead and download the 3 .Zip files equaling the rest of the original app’s size.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="UpdatedSize" border="0" alt="UpdatedSize" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/UpdatedSize.png" width="680" height="475" /> </p>
<p><strong>NOTE:</strong> The reason this is opt-in is that it’s more involved for publishing, since you need to remember that not only do you need the .Xap file for your app, you also need to store the .Zip file(s) of the libraries alongside as well.</p>
<h3>This will be a feature in a future release of the Silverlight Toolkit</h3>
<p>We shipped the October 2009 release of the Silverlight Toolkit on Monday, focusing primarily on delivering the necessary design features for enabling a great Visual Studio 2010 Beta 2 story.</p>
<p>We’ve also been working diligently on longer-lead items for the <em>next</em> release of the Silverlight Toolkit, such as integrating the generation of these .extmap.xml files into our build process. Next, we’ll add them to the setup and with the next release, you won’t need this blog post to take advantage of the feature.</p>
<p>If you’d like to learn more about the feature, <a href="http://timheuer.com/blog/archive/2009/07/13/silverlight-3-cached-assembly-feature.aspx">Tim Heuer</a> really covered this well earlier this year in <a href="http://timheuer.com/blog/archive/2009/07/13/silverlight-3-cached-assembly-feature.aspx">this post</a>.</p>
<p><em>Hope this helps.</em> Special thanks to user ‘TimmyG’ on CodePlex who <a href="http://silverlight.codeplex.com/WorkItem/View.aspx?WorkItemId=3518">initially reminded</a> us of this!</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Btitle%3DApplication%2520Library%2520Caching%2520support%2520for%2520the%2520Silverlight%2520Toolkit';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Btitle%3DApplication%2520Library%2520Caching%2520support%2520for%2520the%2520Silverlight%2520Toolkit%26amp%3Bbodytext%3DHere%2520are%2520the%2520application%2520library%2520cache%2520files%2520needed%2520to%2520reduce%2520the%2520size%2520of%2520your%2520Silverlight%25203%2520application%2527s%2520size%2520when%2520using%2520the%2520Silverlight%2520Toolkit.';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Btitle%3DApplication%2520Library%2520Caching%2520support%2520for%2520the%2520Silverlight%2520Toolkit';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Btitle%3DApplication%2520Library%2520Caching%2520support%2520for%2520the%2520Silverlight%2520Toolkit%26amp%3Bnotes%3DHere%2520are%2520the%2520application%2520library%2520cache%2520files%2520needed%2520to%2520reduce%2520the%2520size%2520of%2520your%2520Silverlight%25203%2520application%2527s%2520size%2520when%2520using%2520the%2520Silverlight%2520Toolkit.';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Bt%3DApplication%2520Library%2520Caching%2520support%2520for%2520the%2520Silverlight%2520Toolkit';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-extmaps%252F%26amp%3Btitle%3DApplication%2520Library%2520Caching%2520support%2520for%2520the%2520Silverlight%2520Toolkit%26amp%3Bannotation%3DHere%2520are%2520the%2520application%2520library%2520cache%2520files%2520needed%2520to%2520reduce%2520the%2520size%2520of%2520your%2520Silverlight%25203%2520application%2527s%2520size%2520when%2520using%2520the%2520Silverlight%2520Toolkit.';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/10/toolkit-extmaps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight Toolkit October 2009 Release</title>
		<link>http://www.jeff.wilcox.name/2009/10/toolkit-october-2009/</link>
		<comments>http://www.jeff.wilcox.name/2009/10/toolkit-october-2009/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 18:03:37 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/10/toolkit-october-2009/</guid>
		<description><![CDATA[The October 2009 release of the Silverlight Toolkit is out, and includes easy drag and drop components and an awesome Visual Studio 2010 experience for the toolkit controls.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> (October 2009) release is now live. The 5<sup>th</sup> release of the product, the toolkit contains a great set of components and features that many of our customers have asked for. Our most recent release, July ’09, has had <b>over 129,000 developer downloads</b> to date.</p>
<p>Here’s what you need to get going:</p>
<p><a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514">Download the Silverlight Toolkit installer</a> for Silverlight 3 (source code included in the installer, or <a href="http://silverlight.codeplex.com/SourceControl/ListDownloadableCommits.aspx">online here</a>)    <br /><a href="http://forums.silverlight.net/forums/35.aspx">Silverlight.net discussion forums for the controls</a>    <br /><a href="http://www.codeplex.com/Silverlight/WorkItem/List.aspx">Issue tracker page on CodePlex</a>    <br /><a href="http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20October%202009%20change%20list">Changes between the July 2009 and October 2009 releases</a></p>
<p>Our installations are side-by-side friendly, so even if you have a previous release, you’ll want to install this one for sure.</p>
<p><i>Here are a few highlights from this release:</i></p>
<h4>Awesome Visual Studio 2010 design experience</h4>
<p>The fully interactive design surface in Visual Studio 2010 really completes the Silverlight development experience. The Silverlight Toolkit contains a rich set of metadata that makes the controls even easier to use.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Dev10" border="0" alt="Dev10" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/Dev10.png" width="680" height="490" /> </p>
<h4>Drag &amp; Drop</h4>
<p>A set of drag and drop targets for ListBox, DataGrid, charts, etc., allows you to add drag &amp; drop support to these controls in a single line of XAML (by enclosing them in a &lt;toolkit:ListBoxDragDropDecorator /&gt; element). Rich LOB-style apps are even easier to build now! Find out more <a href="http://themechanicalbride.blogspot.com/2009/08/new-with-silverlight-toolkit-drag-and.html">here</a>.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="DragAndDrop" border="0" alt="DragAndDrop" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/10/DragAndDrop.png" width="350" height="120" /> </p>
<h4>Charting improvements</h4>
<p>Continued advancement of the charting APIs, optimized for extensibility and performance. <a href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx">Details</a>.</p>
<h3>About the Silverlight Toolkit</h3>
<p>In case you’ve never used the Silverlight Toolkit, here’s what you’ll find inside:</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="319">
<p><b>Mature/Silverlight SDK</b></p>
<p>AutoCompleteBox           <br />Calendar            <br />ChildWindow            <br />DataGrid            <br />DataPager            <br />DatePicker            <br />GridSplitter            <br />HeaderedItemsControl            <br />TabControl            <br />TreeView</p>
</td>
<td valign="top" width="319">
<p><b>Stable</b>            <br />DockPanel            <br />Expander            <br />HeaderedContentControl            <br />Label            <br />NumericUpDown            <br />Viewbox            <br />WrapPanel</p>
</td>
</tr>
<tr>
<td valign="top" width="319">
<p><b>Preview</b>            <br />Accordion            <br />Charting            <br />DataForm            <br />DomainUpDown            <br />ImplicitStyleManager            <br />LayoutTransformer            <br />Rating            <br />TimePicker            <br />TimeUpDown            <br /><i>11 designer visual themes</i></p>
</td>
<td valign="top" width="319">
<p><b>Experimental</b>            <br />GlobalCalendar            <br />TransitioningContentControl            <br />TreeMap            <br />Drag and Drop support for items controls</p>
</td>
</tr>
</tbody>
</table>
<p>Hope you enjoy the new features!</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520October%25202009%2520Release';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520October%25202009%2520Release%26amp%3Bbodytext%3DThe%2520October%25202009%2520release%2520of%2520the%2520Silverlight%2520Toolkit%2520is%2520out%252C%2520and%2520includes%2520easy%2520drag%2520and%2520drop%2520components%2520and%2520an%2520awesome%2520Visual%2520Studio%25202010%2520experience%2520for%2520the%2520toolkit%2520controls.';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520October%25202009%2520Release';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520October%25202009%2520Release%26amp%3Bnotes%3DThe%2520October%25202009%2520release%2520of%2520the%2520Silverlight%2520Toolkit%2520is%2520out%252C%2520and%2520includes%2520easy%2520drag%2520and%2520drop%2520components%2520and%2520an%2520awesome%2520Visual%2520Studio%25202010%2520experience%2520for%2520the%2520toolkit%2520controls.';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Bt%3DSilverlight%2520Toolkit%2520October%25202009%2520Release';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F10%252Ftoolkit-october-2009%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520October%25202009%2520Release%26amp%3Bannotation%3DThe%2520October%25202009%2520release%2520of%2520the%2520Silverlight%2520Toolkit%2520is%2520out%252C%2520and%2520includes%2520easy%2520drag%2520and%2520drop%2520components%2520and%2520an%2520awesome%2520Visual%2520Studio%25202010%2520experience%2520for%2520the%2520toolkit%2520controls.';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/10/toolkit-october-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating a two dimensional barcode control for Silverlight 3</title>
		<link>http://www.jeff.wilcox.name/2009/09/quick-read-silverlight-barcodes/</link>
		<comments>http://www.jeff.wilcox.name/2009/09/quick-read-silverlight-barcodes/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 20:00:00 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=461</guid>
		<description><![CDATA[After using the Starbucks mobile card app for iPhone, I set out to create similar 2D barcodes in Silverlight 3.]]></description>
			<content:encoded><![CDATA[<p>Thanks to the abundance of .NET class libraries that have been developed over nearly a decade of .NET software development, it’s amazingly easy to add powerful functionality to Silverlight applications by reusing existing code. Within a few hours, I was able to create two-dimensional barcodes in Silverlight – making me really want mobile support, web camera support, and printing (<a href="http://silverlight.uservoice.com/pages/4325-feature-suggestions">submit your Silverlight customer suggestions</a>) for this functionality to be super useful.</p>
<p>My temporary obsession with 2D barcodes came about after I installed the awesome <a href="http://www.techflash.com/seattle/2009/09/starbucks_debuts_apps_for_finding_stores_buying_coffee.html">Starbucks Card Mobile app</a> for my iPhone and drove by the Madison Park Starbucks on my way to Redmond, trying out their sweet mobile payment experience. The app worked great – I can only imagine how nice it will be once I can leave my physical Starbucks card at home!</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="starbucksapp1" border="0" alt="starbucksapp1" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/09/starbucksapp1.jpg" width="321" height="497" />     <br /><em>Note: Image is provided by Starbucks, and not a real bar-code that’ll get you free coffee <img src='http://www.jeff.wilcox.name/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </em></p>
<p>I’ve heard stories for years about how many countries worldwide are super-high tech, using <a href="http://en.wikipedia.org/wiki/QR_Code">QR two-dimensional barcodes</a> everywhere, but this was my first experience as a regular consumer, other than seeing them on UPS shipping labels, expensive-looking gadgets in stores, and photos of interesting places:</p>
<p><a href="http://www.flickr.com/photos/avlxyz/2740692511/"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="QuickReadLive" border="0" alt="QuickReadLive" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/09/QuickReadLive1.jpg" width="685" height="324" /></a>&#160; <br /><em>Photo by avlxyz&#8217;, CC-attribution</em></p>
<p>There are so many versions of the QR code standard now that I settled on Version 2, which doesn’t hold as much data as some of the more complex versions – but the library iteself supports them all if you embed a few additional resource files into the assembly.</p>
<p>So what I set and did to get the bare minimum working:</p>
<ul>
<li>Used Joe Stegman’s <a href="http://blogs.msdn.com/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx">EditableImage</a> and <a href="http://blogs.msdn.com/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx">PngEncoder</a> to create a raster image on the client </li>
<li>Found an open-source .NET library that performs at least QR encoding – I found and settled on <a href="http://www.codeproject.com/KB/cs/qrcode.aspx">QRcode on The Code Project</a> site, licensed via the permissive <a href="http://www.codeproject.com/info/cpol10.aspx">CPOL</a> – this work of user ‘twit88’ is the bulk of the awesomeness we’re talking about here </li>
<li>Adapted the library to work with the reduced BCL set (replace ArrayList with generic collections, etc.). I also had to replace some System.Drawing functionality with other equivalents, plus write a quick <a href="http://www.jeff.wilcox.name/2009/09/silverlight-toargb/">ToArgb extension method</a> </li>
<li>Create a simple control, QRBarcode, that has text and barcode color properties </li>
</ul>
<p>Here’s the resulting control in use (<strong>click</strong> to <a href="http://www.jeff.wilcox.name/blog/sampleApps/barcode/BarcodeSample.html"><strong>experience the app</strong></a>):</p>
<p><a href="http://www.jeff.wilcox.name/blog/sampleApps/barcode/BarcodeSample.html"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="BarcodeSample[1]" border="0" alt="BarcodeSample[1]" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/09/BarcodeSample1.png" width="685" height="382" /></a> </p>
<p>It was a quick project, so now, I just need some Silverlight mobile – argh! There isn’t much application to a standard Silverlight app today, unless you want to use SaveFileDialog to store the image to the user’s homepage, or let them take a digital picture of the code. But hey, it was fun!</p>
<p>If you download the project, you’ll see that I purposely excluded a lot of the various QA code spec versions from the final assembly, to cut down its size, plus I commented out some of the encode capability – but overall it went together really quickly and is a solid library, for sure.</p>
<p><a href="http://www.jeff.wilcox.name/blog/sampleApps/barcode/SilverlightBarcode.zip"><strong>Download the zipped up solution</strong></a><strong> with everything you need to experiment</strong> (Silverlight 3, C#, 1.1 MB)</p>
<p>Related note: <a href="http://www.codinghorror.com/blog/archives/001292.html">Jeff Atwood posted a neat comparison</a> of data over the years, back in July.</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Btitle%3DCreating%2520a%2520two%2520dimensional%2520barcode%2520control%2520for%2520Silverlight%25203';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Btitle%3DCreating%2520a%2520two%2520dimensional%2520barcode%2520control%2520for%2520Silverlight%25203%26amp%3Bbodytext%3DAfter%2520using%2520the%2520Starbucks%2520mobile%2520card%2520app%2520for%2520iPhone%252C%2520I%2520set%2520out%2520to%2520create%2520similar%25202D%2520barcodes%2520in%2520Silverlight%25203.';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Btitle%3DCreating%2520a%2520two%2520dimensional%2520barcode%2520control%2520for%2520Silverlight%25203';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Btitle%3DCreating%2520a%2520two%2520dimensional%2520barcode%2520control%2520for%2520Silverlight%25203%26amp%3Bnotes%3DAfter%2520using%2520the%2520Starbucks%2520mobile%2520card%2520app%2520for%2520iPhone%252C%2520I%2520set%2520out%2520to%2520create%2520similar%25202D%2520barcodes%2520in%2520Silverlight%25203.';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Bt%3DCreating%2520a%2520two%2520dimensional%2520barcode%2520control%2520for%2520Silverlight%25203';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fquick-read-silverlight-barcodes%252F%26amp%3Btitle%3DCreating%2520a%2520two%2520dimensional%2520barcode%2520control%2520for%2520Silverlight%25203%26amp%3Bannotation%3DAfter%2520using%2520the%2520Starbucks%2520mobile%2520card%2520app%2520for%2520iPhone%252C%2520I%2520set%2520out%2520to%2520create%2520similar%25202D%2520barcodes%2520in%2520Silverlight%25203.';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/09/quick-read-silverlight-barcodes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding ToArgb() to the Silverlight Color class</title>
		<link>http://www.jeff.wilcox.name/2009/09/silverlight-toargb/</link>
		<comments>http://www.jeff.wilcox.name/2009/09/silverlight-toargb/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 20:19:23 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/09/silverlight-toargb/</guid>
		<description><![CDATA[If you’re using existing imaging libraries with your Silverlight applications, they often represent a Color from the System.Drawing world in the full framework as an integer. An ARGB value is a 32-bit integer with the byte-ordering of AARRGGBB. Using some simple bit shifts and an extension method, you can have this functionality in Silverlight as [...]]]></description>
			<content:encoded><![CDATA[<p>If you’re using existing imaging libraries with your Silverlight applications, they often represent a Color from the System.Drawing world in the full framework as an integer. An ARGB value is a 32-bit integer with the byte-ordering of AARRGGBB. Using some simple bit shifts and an extension method, you can have this functionality in Silverlight as well.</p>
<p>Just add the following class to your project. The extension class is internal, and defined in the same namespace as Color, so it’ll always be accessible:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:656e40aa-b88f-45b1-8d80-1e44d2ca07c9" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

namespace System.Windows.Media
{
    internal static class ColorExtensions
    {
        public static int ToArgb(this Color color)
        {
            int argb = color.A &lt;&lt; 24;
            argb += color.R &lt;&lt; 16;
            argb += color.G &lt;&lt; 8;
            argb += color.B;

            return argb;
        }
    }
}</pre>
</div>
<p>Hope this helps!</p>
<p><em>(And yes, I tried to add this information to the MSDN documentation on ToArgb() using the Community Content feature, but apparently it didn’t like the input. Figuring the search engines will catalog this well enough.)</em></p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Btitle%3DAdding%2520ToArgb%2528%2529%2520to%2520the%2520Silverlight%2520Color%2520class';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Btitle%3DAdding%2520ToArgb%2528%2529%2520to%2520the%2520Silverlight%2520Color%2520class%26amp%3Bbodytext%3DIf%2520you%25E2%2580%2599re%2520using%2520existing%2520imaging%2520libraries%2520with%2520your%2520Silverlight%2520applications%252C%2520they%2520often%2520represent%2520a%2520Color%2520from%2520the%2520System.Drawing%2520world%2520in%2520the%2520full%2520framework%2520as%2520an%2520integer.%2520An%2520ARGB%2520value%2520is%2520a%252032-bit%2520integer%2520with%2520the%2520byte-ordering%2520of%2520AARRGGBB.%2520Usi';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Btitle%3DAdding%2520ToArgb%2528%2529%2520to%2520the%2520Silverlight%2520Color%2520class';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Btitle%3DAdding%2520ToArgb%2528%2529%2520to%2520the%2520Silverlight%2520Color%2520class%26amp%3Bnotes%3DIf%2520you%25E2%2580%2599re%2520using%2520existing%2520imaging%2520libraries%2520with%2520your%2520Silverlight%2520applications%252C%2520they%2520often%2520represent%2520a%2520Color%2520from%2520the%2520System.Drawing%2520world%2520in%2520the%2520full%2520framework%2520as%2520an%2520integer.%2520An%2520ARGB%2520value%2520is%2520a%252032-bit%2520integer%2520with%2520the%2520byte-ordering%2520of%2520AARRGGBB.%2520Usi';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Bt%3DAdding%2520ToArgb%2528%2529%2520to%2520the%2520Silverlight%2520Color%2520class';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Fsilverlight-toargb%252F%26amp%3Btitle%3DAdding%2520ToArgb%2528%2529%2520to%2520the%2520Silverlight%2520Color%2520class%26amp%3Bannotation%3DIf%2520you%25E2%2580%2599re%2520using%2520existing%2520imaging%2520libraries%2520with%2520your%2520Silverlight%2520applications%252C%2520they%2520often%2520represent%2520a%2520Color%2520from%2520the%2520System.Drawing%2520world%2520in%2520the%2520full%2520framework%2520as%2520an%2520integer.%2520An%2520ARGB%2520value%2520is%2520a%252032-bit%2520integer%2520with%2520the%2520byte-ordering%2520of%2520AARRGGBB.%2520Usi';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/09/silverlight-toargb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight Toolkit in the wild – Sunday Night Football player</title>
		<link>http://www.jeff.wilcox.name/2009/09/football-plus-an-accordion-control/</link>
		<comments>http://www.jeff.wilcox.name/2009/09/football-plus-an-accordion-control/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 13:06:21 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=454</guid>
		<description><![CDATA[The awesome online Sunday Night Football experience features the Accordion control from the Silverlight Toolkit.]]></description>
			<content:encoded><![CDATA[<p>If you had a chance to watch the Packers and Bears play last night, you were in for a treat if you used the <a href="http://nbcsports.msnbc.com/id/26393211/ns/sports-nfl/">Silverlight-powered Sunday Night Football Extra</a> player: multiple camera angles, beautiful high definition video, and yes, the Silverlight Toolkit! Last week, the Tennessee Titans played the Pittsburg Steelers (Steelers won, 13-10), using the same technology. The season’s off to a good start now.</p>
<p>NBC has really made a great call here to use <a href="http://www.microsoft.com/silverlight/">Silverlight</a>, paired with <a href="http://www.iis.net/extensions/SmoothStreaming">Smooth Streaming</a> technology. The rich Silverlight app is very nice, <a href="http://www.vertigo.com/Projects.aspx">Vertigo</a> did a great job building it to tie everything together.</p>
<h3>Accordion control for the win!</h3>
<p>One thing that I was really happy to notice in the player app was one of the Preview controls from the Silverlight Toolkit, so I just wanted to take a minute to point that out…</p>
<p><a href="http://nbcsports.msnbc.com/id/26393211/ns/sports-nfl/"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SnfAccordion" border="0" alt="SnfAccordion" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/09/SnfAccordion.jpg" width="685" height="464" /></a> </p>
<p>Here’s a screen shot of the player. On the far right corner, the “Stats” tab contains team stats and other information. The user interface control that lets you decide between the sets of data in this example is the Silverlight Toolkit’s <a href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201&amp;ANCHOR#Accordion">Accordion control</a>.</p>
<p>It’s a nice vote of confidence, seeing this control in use – as a Preview control (<a href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Quality%20Bands">quality band definitions here</a>), it is intended to meet basic usage scenarios, has been released to get feedback, and can be considered an ‘Alpha’ quality control. Maybe we’ll need to prop that up a level with the next release, it looks to be working great!</p>
<p>If you’ve used the control before, you’ll probably recognize that there are two AccordionItems: one with the header ‘Offensive Leaders’, another with the header ‘Team Stats’. The developers at <a href="http://www.vertigo.com/">Vertigo</a> have done a great job of re-templating the control to make it look really nice, plus setup data binding all these fields inside the content of the accordion items.</p>
<p>The Accordion control was developed by <a href="http://www.sitechno.com/blog/">Ruurd Boeke</a>, a member of the Silverlight team. He’s created a great set of guides on the control, I invite you to check them out:</p>
<ul>
<li><a href="http://www.sitechno.com/Blog/ct.ashx?id=1b37749a-295b-4696-96af-b9d8de1c7fb2&amp;url=http%3a%2f%2fwww.sitechno.com%2fBlog%2fAccordionPart1.aspx">Part 1</a> – accordion</li>
<li><a href="http://www.sitechno.com/Blog/ct.ashx?id=1b37749a-295b-4696-96af-b9d8de1c7fb2&amp;url=http%3a%2f%2fwww.sitechno.com%2fBlog%2fAccordionPart2.aspx">Part 2</a> – accordion item</li>
<li><a href="http://www.sitechno.com/Blog/ct.ashx?id=1b37749a-295b-4696-96af-b9d8de1c7fb2&amp;url=http%3a%2f%2fwww.sitechno.com%2fBlog%2fAccordionPart3.aspx">Part 3</a> – expandable content control</li>
<li><a href="http://www.sitechno.com/Blog/ct.ashx?id=1b37749a-295b-4696-96af-b9d8de1c7fb2&amp;url=http%3a%2f%2fwww.sitechno.com%2fBlog%2fAccordionPart4TemplatingExample.aspx">Part 4</a> – retemplating, real world example</li>
<li><a href="http://www.sitechno.com/Blog/AccordionPart5AccordionButton.aspx">Part 5</a> – accordion button</li>
</ul>
<p>To get the control, download and install the <a href="http://silverlight.codeplex.com/">latest Silverlight Toolkit</a> release. The Accordion control is available for both Silverlight 2 and Silverlight 3 development.</p>
<h3>Next game is 9/20 at 8:00 PM ET</h3>
<p>Tune in for the next football game, where the New York Giants will play the Dallas Cowboys. <a href="http://nbcsports.msnbc.com/id/26393211/ns/sports-nfl/">Watch it here</a>.</p>
<h3>Learn more about the Vertigo player</h3>
<p>To learn more about the awesome set of features in this online football experience, check out <a href="http://blogs.vertigo.com/personal/bobc/Blog/archive/2009/09/10/get-ready-for-sunday-night-football.aspx">Bob Cowherd’s blog post</a> that goes through the special features. The devs at Vertigo are top-notch and have done an amazing job pulling this all together.</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520in%2520the%2520wild%2520%2526ndash%253B%2520Sunday%2520Night%2520Football%2520player';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520in%2520the%2520wild%2520%2526ndash%253B%2520Sunday%2520Night%2520Football%2520player%26amp%3Bbodytext%3DThe%2520awesome%2520online%2520Sunday%2520Night%2520Football%2520experience%2520features%2520the%2520Accordion%2520control%2520from%2520the%2520Silverlight%2520Toolkit.';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520in%2520the%2520wild%2520%2526ndash%253B%2520Sunday%2520Night%2520Football%2520player';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520in%2520the%2520wild%2520%2526ndash%253B%2520Sunday%2520Night%2520Football%2520player%26amp%3Bnotes%3DThe%2520awesome%2520online%2520Sunday%2520Night%2520Football%2520experience%2520features%2520the%2520Accordion%2520control%2520from%2520the%2520Silverlight%2520Toolkit.';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Bt%3DSilverlight%2520Toolkit%2520in%2520the%2520wild%2520%2526ndash%253B%2520Sunday%2520Night%2520Football%2520player';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F09%252Ffootball-plus-an-accordion-control%252F%26amp%3Btitle%3DSilverlight%2520Toolkit%2520in%2520the%2520wild%2520%2526ndash%253B%2520Sunday%2520Night%2520Football%2520player%26amp%3Bannotation%3DThe%2520awesome%2520online%2520Sunday%2520Night%2520Football%2520experience%2520features%2520the%2520Accordion%2520control%2520from%2520the%2520Silverlight%2520Toolkit.';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/09/football-plus-an-accordion-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Control Development: Simple code guidelines</title>
		<link>http://www.jeff.wilcox.name/2009/08/custom-controls-simple-code-guidelines/</link>
		<comments>http://www.jeff.wilcox.name/2009/08/custom-controls-simple-code-guidelines/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 23:49:38 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/08/custom-controls-simple-code-guidelines/</guid>
		<description><![CDATA[Here's an initial set of guidelines for building Silverlight custom controls. The first of hopefully many more posts.]]></description>
			<content:encoded><![CDATA[<p>Great custom control development is a skill that takes more than time and experience to perfect. It’s also not a widely documented practice. When it comes to Silverlight controls, there are similarities and differences from WPF custom control development, too – so that chapter on controls in your favorite WPF book often is not directly applicable.</p>
<p>While working with teams throughout Microsoft, and trolling Silverlight forums on <a href="http://silverlight.net/">Silverlight.net</a> and <a href="http://www.stackoverflow.com/">StackOverflow</a>, I’ve come across a few situations where I’ve wanted to share some guidelines for custom control development. Over the next few posts, I’d like to occasionally share my thoughts on this topic, and whatever tips seem pertinent at the time of posting.</p>
<p>I do admit that there’s a lot of flexibility in control development, so I’ll be basing a lot of my tips on both official and unofficial practices on the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> team. And I understand if you don’t agree with everything I have to say. But I do hope this information will be useful!</p>
<h3>Contain your classes</h3>
<p>Controls and classes should always be in their own unique file, instead of having multiple controls or classes in a single file. This includes enums and structs, etc.</p>
<p>So the Dock enum belongs in a file called Dock.cs.</p>
<p>Typically classes are broken up into folders of shared features or sub-namespaces.</p>
<h3>Keep your regions under control</h3>
<p>Regions that serve no real purpose have no need in your code. Grouping all “Public Methods&quot; into a region and having another region with “Private Methods” isn’t helpful to most people.</p>
<p>However, grouping related concepts, interface implementations, and complex algorithms into regions can be a great way to make that 2,000 line file feel a little more navigable.</p>
<p>We always place DependencyProperty declarations and change handlers inside clear regions.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="regions" border="0" alt="regions" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/08/regions.png" width="685" height="260" /> </p>
<h3>Be consistent about where fields belong</h3>
<p>Fields should always be private, only accessible to the control implementation. Whether you place them at the top of the file, the absolute bottom, or alongside related methods and properties (such as in a #region for a DependencyProperty), is a choice that should be consistent within a codebase.</p>
<p>We often try and place backing fields near their respective properties.</p>
<h3>Break comments at 80 characters</h3>
<p>By maintaining a visual break for comments, they become easier to digest while looking through code, regardless of monitor resolution.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="comment_breaks" border="0" alt="comment_breaks" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/08/comment_breaks.png" width="685" height="220" /> </p>
<p>To help with this, you can use a nice registry hack to place a visual guide in the Visual Studio editor (pictured in the above screen capture). Here’s the registry key to set (you can change the color and/or character placement as well):</p>
<blockquote><p>[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor]     <br />&quot;Guides&quot;=&quot;RGB(220,220,220) 80&quot;</p>
</blockquote>
<h3>Consider writing great XML comments</h3>
<p>By writing “great” XML comments, as they would be written in programmer documentation by a writer, you’ll save the time for anyone documenting the controls, improve the IntelliSense experience, and over time find that your code is very clear and crisp.</p>
<p>You can even consider using SandCastle for generating MSDN-style documentation from your code in this case.</p>
<p>If you find yourself writing too much in the comments, your method or feature may be too complex – consider simplifying.</p>
<p>The style we use on the Silverlight Toolkit consists of this:</p>
<ul>
<li>Comments end with a period</li>
<li>Properties start with “Gets or sets”, or “Gets or sets a value indicating whether”</li>
<li>Properties that are only a getter only have the “Gets” portion of “Gets or sets”, etc.</li>
<li>Constructors use wording such as “Initializes a new instance of Type.”</li>
</ul>
<p>Here’s a set of example comments borrowed from the Silverlight team…</p>
<p>Class comments:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:22246144-933b-4aae-8f34-49e5214a44e7" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">/// &lt;summary&gt;
/// Represents a control that displays hierarchical data in a tree structure
/// that has items that can expand and collapse.
/// &lt;/summary&gt;
public partial class TreeView : ItemsControl, IUpdateVisualState
{
}</pre>
</div>
<p>A private field:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:08c2b0ae-696d-4f34-bb15-c95a7d2f4ddc" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// A value indicating whether a read-only dependency property change
        /// handler should allow the value to be set.  This is used to ensure
        /// that read-only properties cannot be changed via SetValue, etc.
        /// &lt;/summary&gt;
        private bool _allowWrite;</pre>
</div>
<p>A public property:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:0db8038f-1fab-4666-9cb0-ce0c3c89776f" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// Gets the selected item in a
        /// &lt;see cref="T:System.Windows.Controls.TreeView" /&gt;.
        /// &lt;/summary&gt;
        /// &lt;value&gt;
        /// The currently selected item or null if no item is selected. The
        /// default value is null.
        /// &lt;/value&gt;
        public object SelectedItem
        { get; set; }</pre>
</div>
<p>An event handler method:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:0481c57c-6fda-49fc-ba49-3971915b235b" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// SelectedItemProperty property changed handler.
        /// &lt;/summary&gt;
        /// &lt;param name="d"&gt;TreeView that changed its SelectedItem.&lt;/param&gt;
        /// &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
        private static void OnSelectedItemPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        { /* ... */ }</pre>
</div>
<p>Public event comments:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:1afb53e0-4b41-40fc-af6a-e1e43e28478a" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// Occurs when the value of the
        /// &lt;see cref="P:System.Windows.Controls.TreeView.SelectedItem" /&gt;
        /// property changes.
        /// &lt;/summary&gt;
        public event RoutedPropertyChangedEventHandler&lt;object&gt; SelectedItemChanged;</pre>
</div>
<p>Constructor:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:9cad46ae-d362-4c1f-ad3f-14bdc6c1d20d" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// Initializes a new instance of the
        /// &lt;see cref="T:System.Windows.Controls.TreeView" /&gt; class.
        /// &lt;/summary&gt;
        public TreeView()
        {
            DefaultStyleKey = typeof(TreeView);
            ItemsControlHelper = new ItemsControlHelper(this);
            Interaction = new InteractionHelper(this);
        }</pre>
</div>
<p>On template application:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:dbbf0324-eb9b-4278-9935-a25d4e0edb9e" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// Builds the visual tree for the
        /// &lt;see cref="T:System.Windows.Controls.TreeView" /&gt; control when a new
        /// control template is applied.
        /// &lt;/summary&gt;
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
        }</pre>
</div>
<p>Bool property with getter and setters:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:0addb496-288d-4bb6-9d7d-e0d5437b7d74" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">        /// &lt;summary&gt;
        /// Gets or sets a value indicating whether the drop-down portion of
        /// the control is open.
        /// &lt;/summary&gt;
        /// &lt;value&gt;
        /// True if the drop-down is open; otherwise, false. The default is
        /// false.
        /// &lt;/value&gt;
        public bool IsDropDownOpen
        {
            get { return (bool)GetValue(IsDropDownOpenProperty); }
            set { SetValue(IsDropDownOpenProperty, value); }
        }</pre>
</div>
<h3>Your event handlers should be thread-safe</h3>
<p>Firing events should be done by first storing the handler in a local variable, similar to this:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:05c559db-12d7-4162-9578-bde2d8381771" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged(string propertyName)
{
    PropertyChangedEventHandler handler = PropertyChanged;
    if (handler != null)
    {
        handler(this, new PropertyChangedEventArgs(propertyName));
    }
}</pre>
</div>
<h3>Fire control events on the user interface thread</h3>
<p>Silverlight only have a single UI thread. However, if you’re interacting with the network or worker threads, the users of your control should not have to worry about being on the UI thread.</p>
<p>Expect that all your events will likely end up changing UIElements that will be checking the thread.</p>
<p>Here’s a simple, efficient way to make sure that your events fire on the UI thread:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:69ae3046-a010-41ec-a37e-ddda219fb9d7" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">/// &lt;summary&gt;
/// Occurs when the DownloadProgress property has changed.
/// &lt;/summary&gt;
public event RoutedEventHandler DownloadProgressChanged;

private void OnDownloadProgressChanged(object sender, RoutedEventArgs args)
{
    if (!Dispatcher.CheckAccess())
    {
        Dispatcher.BeginInvoke(() =&gt; OnDownloadProgressChanged(sender, args));
        return;
    }

    var handler = DownloadProgressChanged;
    if (handler != null)
    {
        handler(this, args);
    }
}</pre>
</div>
<h3>Miscellaneous C# things</h3>
<ul>
<li>Don’t qualify members using “this” or “base” unless required to disambiguate</li>
<li>Prefix private fields with an underscore</li>
<li>Feel free to use automatic properties, but do not use private automatic properties.</li>
<li>Use lowercase ‘string’ when calling methods on it such as ‘string.IsNullOrEmpty’, instead of ‘String.IsNullOrEmpty’.</li>
<li>Similar, refer to and use “object” instead of “Object” for locks and other references to generic objects</li>
</ul>
<h3>Organize your Using statements</h3>
<p>Instead of placing fully qualified type names with namespaces (System.Windows.Controls.Button is not great – just add a using statement for System.Windows.Controls and refer to this as Button), use the built-in Using statement refactoring support in Visual Studio:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="RefactorUsings[1]" border="0" alt="RefactorUsings[1]" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/08/RefactorUsings1.png" width="409" height="374" /> </p>
<p>You want your using statements to be the proper subset of namespaces, and in alphabetical order.</p>
<h3>Mind the .NET Framework Design Guidelines</h3>
<p>When you’re building custom controls, you’re designing a rich API that will enable interesting scenarios for your target developers.</p>
<p>The <a href="http://www.amazon.com/gp/product/0321545613?ie=UTF8&amp;tag=jwilcoxblog-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321545613">.NET Framework Design Guidelines book</a> by Krzysztof Cwalina and Brad Abrams is a really important reference that should be regarded to help assist in the design of your framework.</p>
<p>Depending on the target audience of your work, this may be more or less important: an internal development project may not have the same goals as a custom control that you’d like to sell to other developers.</p>
<p>If you see a specific pattern in existing Silverlight or WPF controls, there’s precedent to use a similar implementation in your own controls for the convenience of developers used to the platform.</p>
<p>Off hand, you should consider some of these tips from the book:</p>
<h4>Remain CLS Compliant</h4>
<p>So that you don’t shut out VB.NET and other language users from the control API, make sure to remain CLS compliant.</p>
<p>This typically translates into situations where you want to expose a generic collection interface instead of an array, for instance. Don’t use the same name, differing only in case.</p>
<p>Good, compliant code:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:b251e967-24bf-44e9-998e-22eed4e9d9b3" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">public IList&lt;interestingitem&gt; InterestingItems { get; }</pre>
</div>
<p>Code that shouldn’t be exposed in a custom control with public visibility:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:0c220367-c16e-4a41-8535-7fcc96280cb6" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">public InterestingItem[] InterestingItems { get; }</pre>
</div>
<h4>Naming guidelines</h4>
<p>All .NET components typically use <em>PascalCasing</em> for properties, members, and events (PMEs). You’ll find <em>camelCasing</em> in use for parameter names only.</p>
<p>You’ll want to be careful about the use of abbreviations and acronyms, and how compound words should appear in your programming interfaces.</p>
<h3>What’s next?</h3>
<p>Let me know in the comments what you think, and especially if you have any particular control development topic I should cover in a future post. Hope you like this!</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Btitle%3DCustom%2520Control%2520Development%253A%2520Simple%2520code%2520guidelines';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Btitle%3DCustom%2520Control%2520Development%253A%2520Simple%2520code%2520guidelines%26amp%3Bbodytext%3DHere%2527s%2520an%2520initial%2520set%2520of%2520guidelines%2520for%2520building%2520Silverlight%2520custom%2520controls.%2520The%2520first%2520of%2520hopefully%2520many%2520more%2520posts.';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Btitle%3DCustom%2520Control%2520Development%253A%2520Simple%2520code%2520guidelines';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Btitle%3DCustom%2520Control%2520Development%253A%2520Simple%2520code%2520guidelines%26amp%3Bnotes%3DHere%2527s%2520an%2520initial%2520set%2520of%2520guidelines%2520for%2520building%2520Silverlight%2520custom%2520controls.%2520The%2520first%2520of%2520hopefully%2520many%2520more%2520posts.';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Bt%3DCustom%2520Control%2520Development%253A%2520Simple%2520code%2520guidelines';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fcustom-controls-simple-code-guidelines%252F%26amp%3Btitle%3DCustom%2520Control%2520Development%253A%2520Simple%2520code%2520guidelines%26amp%3Bannotation%3DHere%2527s%2520an%2520initial%2520set%2520of%2520guidelines%2520for%2520building%2520Silverlight%2520custom%2520controls.%2520The%2520first%2520of%2520hopefully%2520many%2520more%2520posts.';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/08/custom-controls-simple-code-guidelines/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>A Silverlight HighlightingTextBlock implemented in Visual Basic</title>
		<link>http://www.jeff.wilcox.name/2009/08/vb-highlighting-textblock/</link>
		<comments>http://www.jeff.wilcox.name/2009/08/vb-highlighting-textblock/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 20:28:48 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/08/vb-highlighting-textblock/</guid>
		<description><![CDATA[Here's a Visual Basic implementation of HighlightingTextBlock for Silverlight 3.]]></description>
			<content:encoded><![CDATA[<p>Using the same steps and control template XAML from my earlier post today about the HighlightingTextBlock control for Silverlight, you can create a Visual Basic implementation of the control alternatively.</p>
<p>Here’s the VB.NET implementation of the control:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:cc9da320-4da9-4d6c-a3cf-eb1828c6c628" class="wlWriterEditableSmartContent">
<pre class="vb" name="code">Imports System.Windows.Controls.Primitives

Public Class HighlightingTextBlock
    Inherits Control

    ' Contants
    ' --------
    Private Const TextBlockName As String = "Text"

    ' Private fields
    ' --------------
    Private Inlines As List(Of Inline)
    Private TextBlock As TextBlock

    ' Dependency properties
    ' ---------------------

    '
    ' HighlightBrush
    '
    Public Shared ReadOnly HighlightBrushProperty As DependencyProperty = DependencyProperty.Register("HighlightBrush", GetType(Brush), GetType(HighlightingTextBlock), New PropertyMetadata(Nothing, New PropertyChangedCallback(AddressOf HighlightingTextBlock.OnHighlightBrushPropertyChanged)))

    Public Property HighlightBrush() As Brush
        Get
            Return TryCast(MyBase.GetValue(HighlightingTextBlock.HighlightBrushProperty), Brush)
        End Get
        Set(ByVal value As Brush)
            MyBase.SetValue(HighlightingTextBlock.HighlightBrushProperty, value)
        End Set
    End Property

    Private Shared Sub OnHighlightBrushPropertyChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
        TryCast(d, HighlightingTextBlock).ApplyHighlighting()
    End Sub

    '
    ' HighlightFontWeight
    '
    Public Shared ReadOnly HighlightFontWeightProperty As DependencyProperty = DependencyProperty.Register("HighlightFontWeight", GetType(FontWeight), GetType(HighlightingTextBlock), New PropertyMetadata(FontWeights.Normal, New PropertyChangedCallback(AddressOf HighlightingTextBlock.OnHighlightFontWeightPropertyChanged)))

    Public Property HighlightFontWeight() As FontWeight
        Get
            Return DirectCast(MyBase.GetValue(HighlightingTextBlock.HighlightFontWeightProperty), FontWeight)
        End Get
        Set(ByVal value As FontWeight)
            MyBase.SetValue(HighlightingTextBlock.HighlightFontWeightProperty, value)
        End Set
    End Property

    Private Shared Sub OnHighlightFontWeightPropertyChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
        Dim source As HighlightingTextBlock = TryCast(d, HighlightingTextBlock)
        Dim value As FontWeight = DirectCast(e.NewValue, FontWeight)
    End Sub

    '
    ' HighlightText
    '
    Public Shared ReadOnly HighlightTextProperty As DependencyProperty = DependencyProperty.Register("HighlightText", GetType(String), GetType(HighlightingTextBlock), New PropertyMetadata(New PropertyChangedCallback(AddressOf HighlightingTextBlock.OnHighlightTextPropertyChanged)))

    Public Property HighlightText() As String
        Get
            Return TryCast(MyBase.GetValue(HighlightingTextBlock.HighlightTextProperty), String)
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(HighlightingTextBlock.HighlightTextProperty, value)
        End Set
    End Property

    Private Shared Sub OnHighlightTextPropertyChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
        TryCast(d, HighlightingTextBlock).ApplyHighlighting()
    End Sub

    '
    ' Text
    '
    Public Shared ReadOnly TextProperty As DependencyProperty = DependencyProperty.Register("Text", GetType(String), GetType(HighlightingTextBlock), New PropertyMetadata(New PropertyChangedCallback(AddressOf HighlightingTextBlock.OnTextPropertyChanged)))

    Public Property [Text]() As String
        Get
            Return TryCast(MyBase.GetValue(HighlightingTextBlock.TextProperty), String)
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(HighlightingTextBlock.TextProperty, value)
        End Set
    End Property

    Private Shared Sub OnTextPropertyChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
        Dim source As HighlightingTextBlock = TryCast(d, HighlightingTextBlock)
        If (Not source.TextBlock Is Nothing) Then
            Do While (source.TextBlock.Inlines.Count &gt; 0)
                source.TextBlock.Inlines.RemoveAt(0)
            Loop
            Dim value As String = TryCast(e.NewValue, String)
            source.Inlines = New List(Of Inline)
            If (Not [value] Is Nothing) Then
                Dim i As Integer
                For i = 0 To [value].Length - 1
                    Dim [run] As New Run
                    [run].Text = value.Chars(i).ToString
                    Dim inline As Inline = run
                    source.TextBlock.Inlines.Add(inline)
                    source.Inlines.Add(inline)
                Next i
                source.ApplyHighlighting()
            End If
        End If
    End Sub

    ' Initializes a new instance of the HighlightingTextBlock control
    Public Sub New()
        Me.DefaultStyleKey = GetType(HighlightingTextBlock)
    End Sub

    ' Enforce the template
    Private Sub OnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.OnApplyTemplate()
    End Sub

    ' Grab the template parts
    Public Overrides Sub OnApplyTemplate()
        MyBase.OnApplyTemplate()
        Me.TextBlock = TryCast(MyBase.GetTemplateChild(TextBlockName), TextBlock)
        Dim text As String = Me.Text
        Me.Text = Nothing
        Me.Text = [text]
    End Sub

    ' Update highlighting using a simple walking algorithm
    Private Sub ApplyHighlighting()
        If (Not Me.Inlines Is Nothing) Then
            Dim text As String = IIf(Me.Text &lt;&gt; Nothing, Me.Text, String.Empty)
            Dim highlight As String = IIf(Me.HighlightText &lt;&gt; Nothing, Me.HighlightText, String.Empty)
            Dim compare As StringComparison = StringComparison.OrdinalIgnoreCase
            Dim cur As Integer = 0
            Do While (cur &lt; [text].Length)
                Dim i As Integer = IIf((highlight.Length = 0), -1, [text].IndexOf(highlight, cur, [compare]))
                i = IIf((i &lt; 0), [text].Length, i)
                Do While ((cur &lt; i) AndAlso (cur &lt; [text].Length))
                    Me.Inlines.Item(cur).Foreground = MyBase.Foreground
                    Me.Inlines.Item(cur).FontWeight = MyBase.FontWeight
                    cur += 1
                Loop
                Dim start As Integer = cur
                Do While ((cur &lt; (start + highlight.Length)) AndAlso (cur &lt; [text].Length))
                    Me.Inlines.Item(cur).Foreground = Me.HighlightBrush
                    Me.Inlines.Item(cur).FontWeight = Me.HighlightFontWeight
                    cur += 1
                Loop
            Loop
        End If
    End Sub

End Class</pre>
</div>
<h3>Related posts</h3>
<ul>
<li><a href="http://www.jeff.wilcox.name/2009/08/sl3-highlighting-text-block/">Creating a highlighting text block for Silverlight 3, revisited</a></li>
<li><a href="http://www.jeff.wilcox.name/2008/11/highlighting-autocompletebox/">Building a highlighting AutoCompleteBox</a></li>
<li><a href="http://www.jeff.wilcox.name/2009/03/sl3-highlighting-autocompletebox/">Silverlight 3 element name binding improvements</a></li>
</ul>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Btitle%3DA%2520Silverlight%2520HighlightingTextBlock%2520implemented%2520in%2520Visual%2520Basic';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Btitle%3DA%2520Silverlight%2520HighlightingTextBlock%2520implemented%2520in%2520Visual%2520Basic%26amp%3Bbodytext%3DHere%2527s%2520a%2520Visual%2520Basic%2520implementation%2520of%2520HighlightingTextBlock%2520for%2520Silverlight%25203.';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Btitle%3DA%2520Silverlight%2520HighlightingTextBlock%2520implemented%2520in%2520Visual%2520Basic';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Btitle%3DA%2520Silverlight%2520HighlightingTextBlock%2520implemented%2520in%2520Visual%2520Basic%26amp%3Bnotes%3DHere%2527s%2520a%2520Visual%2520Basic%2520implementation%2520of%2520HighlightingTextBlock%2520for%2520Silverlight%25203.';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Bt%3DA%2520Silverlight%2520HighlightingTextBlock%2520implemented%2520in%2520Visual%2520Basic';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fvb-highlighting-textblock%252F%26amp%3Btitle%3DA%2520Silverlight%2520HighlightingTextBlock%2520implemented%2520in%2520Visual%2520Basic%26amp%3Bannotation%3DHere%2527s%2520a%2520Visual%2520Basic%2520implementation%2520of%2520HighlightingTextBlock%2520for%2520Silverlight%25203.';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/08/vb-highlighting-textblock/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a highlighting text block for Silverlight 3, revisited</title>
		<link>http://www.jeff.wilcox.name/2009/08/sl3-highlighting-text-block/</link>
		<comments>http://www.jeff.wilcox.name/2009/08/sl3-highlighting-text-block/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 19:17:32 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/08/sl3-highlighting-text-block/</guid>
		<description><![CDATA[Now that Silverlight 3 has shipped, I’d like to take a moment to revisit the highlighting AutoCompleteBox control that I blogged about back in November of ‘08, and again earlier this year, thanks to tooling improvements: Expression Blend 3 is out, and the Visual Studio 2008 tools have changed as well. There are new project [...]]]></description>
			<content:encoded><![CDATA[<p>Now that Silverlight 3 has shipped, I’d like to take a moment to revisit the highlighting AutoCompleteBox control that I <a href="http://www.jeff.wilcox.name/2008/11/highlighting-autocompletebox/">blogged about back</a> in November of ‘08, and again <a href="http://www.jeff.wilcox.name/2009/03/sl3-highlighting-autocompletebox/">earlier this year</a>, thanks to tooling improvements: <a href="http://www.microsoft.com/expression/products/Blend_Overview.aspx">Expression Blend 3</a> is out, and the Visual Studio 2008 tools have changed as well. There are new project and item templates this time around.</p>
<p>This short post re-creates the HighlightingTextBlock control, using the <strong>Templated Silverlight Control</strong> item template that ships in the Silverlight Tools. When I last blogged about the highlighting text block control, I had to describe in detail how to go about creating a library, creating the default control styles file (Generic.xaml), setting properties, and putting it all together.</p>
<p>Now it is a lot easier! Using the advanced copy-and-paste coding technique, you can create and build this control in about 2 minutes.</p>
<h3>Create a new Silverlight Class Library Project</h3>
<ul>
<li>Open Visual Studio 2008 SP1 </li>
<li>File | New Project, Visual C# | Silverlight | Silverlight Class Library project type </li>
</ul>
<h3>Remove Class1.cs</h3>
<p>The default class file, Class1.cs, can be removed. Right-click on it in the Solution Explorer and select the ‘Delete’ menu item.</p>
<h3>Use the ‘Silverlight Templated Control’ template</h3>
<p>The new template is great since it creates a simple class for the control, sets up the default style key, and then creates/modifies the Generic.xaml theme file for the library, setting all the right properties along the way.</p>
<ul>
<li>Click on the Project menu (or right-click on the project in the Solution Explorer) </li>
<li>Select ‘Add New Item’ </li>
<li>Use the ‘Silverlight Templated Control’ template </li>
<li>Change the name from TemplatedControl1.cs to HighlightingTextBlock.cs </li>
<li>Click ‘Add’ </li>
</ul>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Templated" border="0" alt="Templated" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/08/Templated.png" width="541" height="324" /> </p>
<h3>Insert the control code</h3>
<p>Borrowed from my previous post on the topic, just paste this class’ code into the namespace, replacing what is already there:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:1182d2c0-4aa2-4496-9350-0f266d7158b6" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">/// &lt;summary&gt;
    /// A specialized highlighting text block control.
    /// &lt;/summary&gt;
    public partial class HighlightingTextBlock : Control
    {
        /// &lt;summary&gt;
        /// The name of the TextBlock part.
        /// &lt;/summary&gt;
        private string TextBlockName = "Text";

        /// &lt;summary&gt;
        /// Gets or sets the text block reference.
        /// &lt;/summary&gt;
        private TextBlock TextBlock { get; set; }

        /// &lt;summary&gt;
        /// Gets or sets the inlines list.
        /// &lt;/summary&gt;
        private List&lt;Inline&gt; Inlines { get; set; }

        #region public string Text
        /// &lt;summary&gt;
        /// Gets or sets the contents of the TextBox.
        /// &lt;/summary&gt;
        public string Text
        {
            get { return GetValue(TextProperty) as string; }
            set { SetValue(TextProperty, value); }
        }

        /// &lt;summary&gt;
        /// Identifies the Text dependency property.
        /// &lt;/summary&gt;
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register(
                "Text",
                typeof(string),
                typeof(HighlightingTextBlock),
                new PropertyMetadata(OnTextPropertyChanged));

        /// &lt;summary&gt;
        /// TextProperty property changed handler.
        /// &lt;/summary&gt;
        /// &lt;param name="d"&gt;AutoCompleteBox that changed its Text.&lt;/param&gt;
        /// &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
        private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HighlightingTextBlock source = d as HighlightingTextBlock;

            if (source.TextBlock != null)
            {
                while (source.TextBlock.Inlines.Count &gt; 0)
                {
                    source.TextBlock.Inlines.RemoveAt(0);
                }
                string value = e.NewValue as string;
                source.Inlines = new List&lt;Inline&gt;();
                if (value != null)
                {
                    for (int i = 0; i &lt; value.Length; i++)
                    {
                        Inline run = new Run { Text = value[i].ToString() };
                        source.TextBlock.Inlines.Add(run);
                        source.Inlines.Add(run);
                    }

                    source.ApplyHighlighting();
                }
            }
        }

        #endregion public string Text

        #region public string HighlightText
        /// &lt;summary&gt;
        /// Gets or sets the highlighted text.
        /// &lt;/summary&gt;
        public string HighlightText
        {
            get { return GetValue(HighlightTextProperty) as string; }
            set { SetValue(HighlightTextProperty, value); }
        }

        /// &lt;summary&gt;
        /// Identifies the HighlightText dependency property.
        /// &lt;/summary&gt;
        public static readonly DependencyProperty HighlightTextProperty =
            DependencyProperty.Register(
                "HighlightText",
                typeof(string),
                typeof(HighlightingTextBlock),
                new PropertyMetadata(OnHighlightTextPropertyChanged));

        /// &lt;summary&gt;
        /// HighlightText property changed handler.
        /// &lt;/summary&gt;
        /// &lt;param name="d"&gt;AutoCompleteBox that changed its HighlightText.&lt;/param&gt;
        /// &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
        private static void OnHighlightTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HighlightingTextBlock source = d as HighlightingTextBlock;
            source.ApplyHighlighting();
        }

        #endregion public string HighlightText

        #region public Brush HighlightBrush
        /// &lt;summary&gt;
        /// Gets or sets the highlight brush.
        /// &lt;/summary&gt;
        public Brush HighlightBrush
        {
            get { return GetValue(HighlightBrushProperty) as Brush; }
            set { SetValue(HighlightBrushProperty, value); }
        }

        /// &lt;summary&gt;
        /// Identifies the HighlightBrush dependency property.
        /// &lt;/summary&gt;
        public static readonly DependencyProperty HighlightBrushProperty =
            DependencyProperty.Register(
                "HighlightBrush",
                typeof(Brush),
                typeof(HighlightingTextBlock),
                new PropertyMetadata(null, OnHighlightBrushPropertyChanged));

        /// &lt;summary&gt;
        /// HighlightBrushProperty property changed handler.
        /// &lt;/summary&gt;
        /// &lt;param name="d"&gt;HighlightingTextBlock that changed its HighlightBrush.&lt;/param&gt;
        /// &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
        private static void OnHighlightBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HighlightingTextBlock source = d as HighlightingTextBlock;
            source.ApplyHighlighting();
        }
        #endregion public Brush HighlightBrush

        #region public FontWeight HighlightFontWeight
        /// &lt;summary&gt;
        /// Gets or sets the font weight used on highlighted text.
        /// &lt;/summary&gt;
        public FontWeight HighlightFontWeight
        {
            get { return (FontWeight)GetValue(HighlightFontWeightProperty); }
            set { SetValue(HighlightFontWeightProperty, value); }
        }

        /// &lt;summary&gt;
        /// Identifies the HighlightFontWeight dependency property.
        /// &lt;/summary&gt;
        public static readonly DependencyProperty HighlightFontWeightProperty =
            DependencyProperty.Register(
                "HighlightFontWeight",
                typeof(FontWeight),
                typeof(HighlightingTextBlock),
                new PropertyMetadata(FontWeights.Normal, OnHighlightFontWeightPropertyChanged));

        /// &lt;summary&gt;
        /// HighlightFontWeightProperty property changed handler.
        /// &lt;/summary&gt;
        /// &lt;param name="d"&gt;HighlightingTextBlock that changed its HighlightFontWeight.&lt;/param&gt;
        /// &lt;param name="e"&gt;Event arguments.&lt;/param&gt;
        private static void OnHighlightFontWeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            HighlightingTextBlock source = d as HighlightingTextBlock;
            FontWeight value = (FontWeight)e.NewValue;
        }
        #endregion public FontWeight HighlightFontWeight

        /// &lt;summary&gt;
        /// Initializes a new HighlightingTextBlock class.
        /// &lt;/summary&gt;
        public HighlightingTextBlock()
        {
            DefaultStyleKey = typeof(HighlightingTextBlock);
            Loaded += OnLoaded;
        }

        /// &lt;summary&gt;
        /// Loaded method handler.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The loaded event.&lt;/param&gt;
        /// &lt;param name="e"&gt;The event data.&lt;/param&gt;
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            OnApplyTemplate();
        }

        /// &lt;summary&gt;
        /// Override the apply template handler.
        /// &lt;/summary&gt;
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Grab the template part
            TextBlock = GetTemplateChild(TextBlockName) as TextBlock;

            // Re-apply the text value
            string text = Text;
            Text = null;
            Text = text;
        }

        /// &lt;summary&gt;
        /// Apply the visual highlighting.
        /// &lt;/summary&gt;
        private void ApplyHighlighting()
        {
            if (Inlines == null)
            {
                return;
            }

            string text = Text ?? string.Empty;
            string highlight = HighlightText ?? string.Empty;
            StringComparison compare = StringComparison.OrdinalIgnoreCase;

            int cur = 0;
            while (cur &lt; text.Length)
            {
                int i = highlight.Length == 0 ? -1 : text.IndexOf(highlight, cur, compare);
                i = i &lt; 0 ? text.Length : i;

                // Clear
                while (cur &lt; i &#038;&#038; cur &lt; text.Length)
                {
                    Inlines[cur].Foreground = Foreground;
                    Inlines[cur].FontWeight = FontWeight;
                    cur++;
                }

                // Highlight
                int start = cur;
                while (cur &lt; start + highlight.Length &#038;&#038; cur &lt; text.Length)
                {
                    Inlines[cur].Foreground = HighlightBrush;
                    Inlines[cur].FontWeight = HighlightFontWeight;
                    cur++;
                }
            }
        }
    }</pre>
</div>
<p>Then, refactor the Using statements to make the code a little crisper:</p>
<ul>
<li>Right-click on one of the ‘using’ statements at the top of the file </li>
<li>Select ‘Organize Usings’, then ‘Remove and Sort’</li>
</ul>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="RefactorUsings" border="0" alt="RefactorUsings" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/08/RefactorUsings.png" width="409" height="374" /> </p>
<h3>Define the default control style</h3>
<p>Now, Generic.xaml is already created in the Themes folder – so go ahead and open it, then use this for the control template. Our default style is simple: sets the default highlight brush color, plus a single template part – a text block named ‘Text’.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:05362e20-1d92-4755-873c-e774656b7c75" class="wlWriterEditableSmartContent">
<pre class="xml" name="code">&lt;Style TargetType="local:HighlightingTextBlock"&gt;
        &lt;Setter Property="HighlightBrush" Value="Blue" /&gt;
        &lt;Setter Property="Template"&gt;
            &lt;Setter.Value&gt;
                &lt;ControlTemplate TargetType="local:HighlightingTextBlock"&gt;
                    &lt;TextBlock x:Name="Text" /&gt;
                &lt;/ControlTemplate&gt;
            &lt;/Setter.Value&gt;
        &lt;/Setter&gt;
    &lt;/Style&gt;</pre>
</div>
<p>Build the project, and you’re good to go and use that control now. Hope this helps!</p>



Share and Enjoy:


	<a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Btitle%3DCreating%2520a%2520highlighting%2520text%2520block%2520for%2520Silverlight%25203%252C%2520revisited';" title="Live"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Btitle%3DCreating%2520a%2520highlighting%2520text%2520block%2520for%2520Silverlight%25203%252C%2520revisited%26amp%3Bbodytext%3DNow%2520that%2520Silverlight%25203%2520has%2520shipped%252C%2520I%25E2%2580%2599d%2520like%2520to%2520take%2520a%2520moment%2520to%2520revisit%2520the%2520highlighting%2520AutoCompleteBox%2520control%2520that%2520I%2520blogged%2520about%2520back%2520in%2520November%2520of%2520%25E2%2580%259808%252C%2520and%2520again%2520earlier%2520this%2520year%252C%2520thanks%2520to%2520tooling%2520improvements%253A%2520Expression%2520Blend%25203%2520is%2520out';" title="Digg"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" id="dotnetkicks" href="javascript:window.location='http%3A%2F%2Fwww.dotnetkicks.com%2Fkick%2F%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Btitle%3DCreating%2520a%2520highlighting%2520text%2520block%2520for%2520Silverlight%25203%252C%2520revisited';" title="DotNetKicks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F';" title="Technorati"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Btitle%3DCreating%2520a%2520highlighting%2520text%2520block%2520for%2520Silverlight%25203%252C%2520revisited%26amp%3Bnotes%3DNow%2520that%2520Silverlight%25203%2520has%2520shipped%252C%2520I%25E2%2580%2599d%2520like%2520to%2520take%2520a%2520moment%2520to%2520revisit%2520the%2520highlighting%2520AutoCompleteBox%2520control%2520that%2520I%2520blogged%2520about%2520back%2520in%2520November%2520of%2520%25E2%2580%259808%252C%2520and%2520again%2520earlier%2520this%2520year%252C%2520thanks%2520to%2520tooling%2520improvements%253A%2520Expression%2520Blend%25203%2520is%2520out';" title="del.icio.us"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Bt%3DCreating%2520a%2520highlighting%2520text%2520block%2520for%2520Silverlight%25203%252C%2520revisited';" title="Facebook"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a>
	<a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.jeff.wilcox.name%252F2009%252F08%252Fsl3-highlighting-text-block%252F%26amp%3Btitle%3DCreating%2520a%2520highlighting%2520text%2520block%2520for%2520Silverlight%25203%252C%2520revisited%26amp%3Bannotation%3DNow%2520that%2520Silverlight%25203%2520has%2520shipped%252C%2520I%25E2%2580%2599d%2520like%2520to%2520take%2520a%2520moment%2520to%2520revisit%2520the%2520highlighting%2520AutoCompleteBox%2520control%2520that%2520I%2520blogged%2520about%2520back%2520in%2520November%2520of%2520%25E2%2580%259808%252C%2520and%2520again%2520earlier%2520this%2520year%252C%2520thanks%2520to%2520tooling%2520improvements%253A%2520Expression%2520Blend%25203%2520is%2520out';" title="Google Bookmarks"><img src="http://www.jeff.wilcox.name/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/08/sl3-highlighting-text-block/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
