<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;AkIGQnc4cSp7ImA9WhVUFk0.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647</id><updated>2012-05-21T09:55:23.939-04:00</updated><category term="images" /><category term="arm" /><category term="silverlight seo" /><category term="xaml keys" /><category term="textblock" /><category term="transport" /><category term="dynamic modules" /><category term="liskov substitution" /><category term="bugs" /><category term="development" /><category term="winrt" /><category term="source code browser" /><category term="dynamic types" /><category term="tombstone" /><category term="snowflake" /><category term="conversion" /><category term="events" /><category term="OOB" /><category term="rss reader" /><category term="rest services" /><category term="silverlight toolkit" /><category term="nonsecure items" /><category term="module" /><category term="silverlight navigation" /><category term="silverlight download" /><category term="ria services" /><category term="moq" /><category term="image transform" /><category term="powershell" /><category term="web client" /><category term="property change" /><category term="video" /><category term="nosql" /><category term="#msmix11w" /><category term="codeproject" /><category term="prism" /><category term="locator" /><category term="saga pattern" /><category term="ie 6.0" /><category term="facebook" /><category term="by ref" /><category term="linq" /><category term="windows mobile 7" /><category term="mix 2011" /><category term="theme" /><category term="observable" /><category term="azure" /><category term="datagridtemplatecolumn" /><category term="embedded resources" /><category term="click event" /><category term="common table expression" /><category term="crud" /><category term="mvc" /><category term="ms-pl" /><category term="build" /><category term="mvvm" /><category term="databinding" /><category term="rx" /><category term="client script" /><category term="unit testing" /><category term="NHibernate" /><category term="asp.net" /><category term="design" /><category term="scrollchanged" /><category term="anti-aliasing" /><category term="copyleft" /><category term="postback. callback. button" /><category term="enumerator" /><category term="windsor" /><category term=".NET tools" /><category term="text search" /><category term="silverlight animation" /><category term="subversion" /><category term="yuml" /><category term="fluent interfaces" /><category term="dropdown" /><category term="reflection" /><category term="model-view-controller" /><category term="list" /><category term="storyboard" /><category term="reportviewer" /><category term="cal" /><category term="serialization" /><category term="paging" /><category term="preloading" /><category term="ASP.NET control" /><category term="command" /><category term="OODB" /><category term="model-view-presenter" /><category term="silverlight 5" /><category term="silverlight printing" /><category term="single responsibility" /><category term="datacontext" /><category term="#msmix11s" /><category term="silverlight controls" /><category term="mvp" /><category term="olympics" /><category term="dynamic xap" /><category term="knockoutjs" /><category term="tortoisesvn" /><category term="MEF" /><category term="frameworks" /><category term="child window" /><category term="value type" /><category term="partinitializer" /><category term="plugin" /><category term="hierarchical data template" /><category term="animation" /><category term="line of business" /><category term="mix" /><category term="dynamic control" /><category term="source control" /><category term="host control" /><category term="JSON" /><category term="cross domain" /><category term="scrollview" /><category term="touch" /><category term="focus" /><category term="data temlate" /><category term="law of demeter" /><category term="silverlight 4" /><category term="feed reader" /><category term="navigation" /><category term="secondary tiles" /><category term="dry" /><category term="transaction" /><category term="windows service" /><category term="silverlight" /><category term="number" /><category term="design-time" /><category term="wpf control" /><category term="expression blend" /><category term="modules" /><category term="cube" /><category term="dispatcher" /><category term="solid principle" /><category term="silveright 3" /><category term="old school" /><category term="delegates" /><category term="weakreference" /><category term="constructor injection" /><category term="observablecollection" /><category term="datagrid" /><category term="jquery" /><category term="idataerrorinfo" /><category term="odata" /><category term="user control" /><category term="silverlight 3" /><category term="iapplicationservice" /><category term="dropdown bug" /><category term="CTE" /><category term="wpf" /><category term="behavior" /><category term="automated testing" /><category term="id" /><category term="exception" /><category term=".net framework 4.5" /><category term="lifetime management" /><category term="caching" /><category term="entity framework" /><category term="sql 2008" /><category term="custom markup extension" /><category term="silverlight services" /><category term="yield" /><category term="dialog" /><category term="xaml" /><category term="path" /><category term="SQL" /><category term="scriptableobject" /><category term="html5" /><category term="encoding" /><category term="Jounce" /><category term="singleton" /><category term="Windows Workflow Foundation" /><category term="yagni" /><category term="treeview" /><category term="windows phone 7" /><category term="smooth streaming" /><category term="unity framework" /><category term="out of browser" /><category term="plasma" /><category term="nunit" /><category term="validation" /><category term="service host" /><category term="convention" /><category term="ultralight.mvvm" /><category term="c#" /><category term="firefox" /><category term="image reflection" /><category term="interface segregation" /><category term="queries" /><category term="fractal" /><category term="data form" /><category term="pinvoke" /><category term="inotifypropertychanged" /><category term="mocking" /><category term="embedded javascript" /><category term="tiles" /><category term="web service" /><category term="ancestor" /><category term="dynamic data" /><category term=".net" /><category term="event aggregator" /><category term="cag" /><category term="isolated storage" /><category term="bing maps" /><category term="value converter" /><category term="xml" /><category term="silverlight myths" /><category term="windows runtime" /><category term="relative source" /><category term="data contract" /><category term="select" /><category term="attribute" /><category term="sharpdevelop" /><category term="silverlight games" /><category term="#msmix11sw" /><category term="ultra light" /><category term="visual tree" /><category term="schema" /><category term="licenses" /><category term="silverlight unit test" /><category term="metro" /><category term="callback" /><category term="icustomtypeprovider" /><category term="webforms" /><category term="deploymentcatalog" /><category term="handler" /><category term="data grid" /><category term="style" /><category term="inversion of control" /><category term="visual studio" /><category term="composite application guidance" /><category term="windows 8" /><category term="ssrs" /><category term="custom" /><category term="ui virtualization" /><category term="live smooth streaming" /><category term="html" /><category term="combobox" /><category term="large data sets" /><category term="quickstart" /><category term="task parallel library" /><category term="visual state manager" /><category term="syntax highlighter" /><category term="sterling" /><category term="ref keyword" /><category term="media" /><category term="xbox live" /><category term="viewmodel" /><category term="width" /><category term="system.web.ui" /><category term="javascript" /><category term="silverlight 3.0.50106.0" /><category term="asynchronous" /><category term="workflow" /><category term="debugging" /><category term="anonymous method" /><category term="silverlight richtextarea" /><category term="tablet" /><category term="server control" /><category term="windows communication foundation" /><category term="silverlight splash" /><category term="pivot" /><category term="pipes and filters" /><category term="gnu" /><category term="vs 2010" /><category term="windows phone 7 series" /><category term="childwindow" /><category term="regions" /><category term="view model" /><category term="zoom" /><category term="partial members" /><category term="panel" /><category term="iusertype" /><category term="pipeline pattern" /><category term="changed" /><category term="enterprise" /><category term="telerik" /><category term="html 5" /><category term="triggeraction" /><category term="viewbox" /><category term="postbacksettings error" /><category term="Koch" /><category term="database" /><category term="ndepend" /><category term="scrollviewer" /><category term="wcf" /><category term="delegatecommand" /><category term="assert" /><category term="debug" /><category term="coroutine" /><category term="codestock" /><category term="tpl" /><category term="dependency injection" /><category term="key" /><category term="slate" /><category term="assert.true" /><category term="wcf ria" /><category term="Managed Extensibility Framework" /><category term="code first" /><category term="composite wpf" /><category term="consumer preview" /><category term="dynamic xaml" /><category term="magic string" /><category term="unspecified error" /><category term="lambda expression" /><category term="zune" /><category term="ajax" /><category term="updatepanel" /><category term="trigger" /><category term="view engine" /><category term="ui automation" /><category term="inline hyperlink" /><category term="reference type" /><category term="exportprovider" /><category term="isinteger" /><category term="listbox" /><category term="XAP" /><category term="portable library" /><category term="single point of truth" /><category term="textbox" /><category term="windbg" /><category term="gmail autopilot" /><category term="enumerable" /><category term="napkee" /><category term="resource dictionary" /><category term="silverlight test" /><category term="free software" /><category term="performance profiling" /><category term="balsamiq" /><category term="captcha" /><category term="dependency property" /><category term="matrix" /><category term="generics" /><category term="multivalue" /><category term="dictionary" /><category term="resource file" /><category term="https" /><category term="reactive extensions" /><category term="open closed" /><category term="attached property" /><category term="references" /><category term="collections" /><category term="metadata" /><category term="model-view-viewmodel" /><category term="profiling" /><category term="bitmap" /><category term="binding" /><title>C#er : IMage</title><subtitle type="html">Developer and author Jeremy Likness blogs about enterprise and line of business development on Microsoft platforms using technologies like LINQ, Entity Framework, C#, ASP.NET, MVC, Silverlight, XAML, and Windows 8 (Metro and WinRT).</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://csharperimage.jeremylikness.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>271</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/CSharperImage" /><feedburner:info uri="csharperimage" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/3.0/" /><logo>http://jeremylikness.com/signature.gif</logo><entry gd:etag="W/&quot;DkIARH86eCp7ImA9WhVUFEg.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-8396948445989127223</id><published>2012-05-19T15:09:00.000-04:00</published><updated>2012-05-19T15:09:05.110-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-19T15:09:05.110-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tiles" /><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="secondary tiles" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="windows runtime" /><category scheme="http://www.blogger.com/atom/ns#" term="winrt" /><title>How to Debug a Windows 8 Metro Secondary Tile</title><content type="html">&lt;p&gt;I've been working on Chapter 7 of my upcoming book, &lt;a href="https://www.facebook.com/pages/Designing-Windows-8-Metro-Applications-with-C-and-XAML/114194758709235" target="_blank"&gt;Designing Windows 8 Metro Applications with C# and XAML&lt;/a&gt;. This chapter focuses on tiles and toast notifications. In the Windows 8 runtime, it is incredibly easy to prompt the user to pin a secondary tile. This is a tile that has a deep link for content. For example, my reference application contains blogs and blog posts from several Wintellect employees. You can pin a specific blog or even a specific item within a blog. The application bar provides the icon to click to &lt;b&gt;Pin to Start&lt;/b&gt;:
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-difmK1w5pTI/T7ftbKgN1lI/AAAAAAAAAq8/3PakGSyWhms/s1600/07fig04.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="240" width="320" src="http://3.bp.blogspot.com/-difmK1w5pTI/T7ftbKgN1lI/AAAAAAAAAq8/3PakGSyWhms/s320/07fig04.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The code simply grabs the current "group" that represents a blog, then formats a unique id for the tile, a title, and a special set of arguments that are passed when the tile is tapped:
&lt;pre&gt;
private void Pin_Click_1(object sender, RoutedEventArgs e)
{
    var group = DefaultViewModel["Group"] as BlogGroup;
    var title = string.Format("Blog: {0}", group.Title);            
    ((App)Application.Current).PinToStart(this,
        string.Format("Wintellog.{0}", group.Id.GetHashCode()),
        title,
        title,
        string.Format("Group={0}", group.Id));
}
&lt;/pre&gt;
&lt;p&gt;The code on the &lt;code&gt;App&lt;/code&gt; class that does the actual work simply sets up some assets for the tile, computes the location of the button that was tapped and then sets up the tile to prompt the user to pin it: 
&lt;pre&gt;
public async void PinToStart(object sender, string id, string shortName, string displayName, string args)
{
    var logo = new Uri("ms-appx:///Assets/Logo.png");
    var smallLogo = new Uri("ms-appx:///Assets/SmallLogo.png");
    var wideLogo = new Uri("ms-appx:///Assets/WideLogo.png");
    var tile = new SecondaryTile(id, shortName, displayName, args, TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo,
        logo);
    tile.ForegroundText = ForegroundText.Dark;
    tile.SmallLogo = smallLogo;
    tile.WideLogo = wideLogo;            

    var element = sender as FrameworkElement; 
    var buttonTransform = element.TransformToVisual(null);
    var point = buttonTransform.TransformPoint(new Point());
    var rect = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));

    await tile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Left);        
}
&lt;/pre&gt;
&lt;p&gt;You can see what the prompt looks like here: 
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-Ffv0g57PqVs/T7fttYRGooI/AAAAAAAAArI/zNpJiBsU1hM/s1600/07fig05.tif" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="240" width="320" src="http://1.bp.blogspot.com/-Ffv0g57PqVs/T7fttYRGooI/AAAAAAAAArI/zNpJiBsU1hM/s320/07fig05.tif" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;When the application launches, it can read the arguments that are passed in and use them to navigate to the deep link:
&lt;pre&gt;
if (_activationArgs.Arguments.StartsWith("Group"))
{
    var group = _activationArgs.Arguments.Split('=');
    target = typeof(GroupDetailPage);
    parameter = list.Where(g =&gt; g.Id.Equals(group[1])).FirstOrDefault();
}
&lt;/pre&gt;
&lt;p&gt;The problem that you may encounter when dealing with secondary tiles is that the arguments are read-only when the application is launched. If you launch your Metro application from the debugger, you cannot modify the arguments and they will be passed in as blank. This will cause the application to respond as if it were launched from the primary tile, not a secondary one. Fortunately, the solution to debug secondary tiles is very straightforward. Simply right-click on the Metro project in the Solution Explorer and navigate to the Debug tab. There, you can set the application to get ready for debugging &lt;i&gt;but not actually launch&lt;/i&gt; when you start a debugger session. This is what the setting looks like (see &lt;b&gt;Do not launch, but debug my code when it starts&lt;/b&gt;):
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-3spzLrqCabc/T7fud7BP58I/AAAAAAAAArU/xFOGj7icVFc/s1600/07fig06.tif" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="240" width="320" src="http://4.bp.blogspot.com/-3spzLrqCabc/T7fud7BP58I/AAAAAAAAArU/xFOGj7icVFc/s320/07fig06.tif" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Once you check this setting, you can launch debug and the application will simply wait. Then, you can press the Windows key to open the start screen and launch the application from a secondary tile. When the application is launched, it will jump into the debugger and you can hit your breakpoints to see the secondary tile arguments passed in and troubleshoot any issues you may have. Please head over to the Facebook page for my &lt;a href="https://www.facebook.com/pages/Designing-Windows-8-Metro-Applications-with-C-and-XAML/114194758709235" target="_blank"&gt;upcoming book&lt;/a&gt; and "Like" it to receive updates and learn when it will be available for preview online and released to print. I'll be handing out sample chapters at my upcoming speaking events, so I hope to see you there at one of them.&lt;p&gt;
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-8396948445989127223?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=wULeZzqcTB8:XsVeDR9QPRk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=wULeZzqcTB8:XsVeDR9QPRk:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=wULeZzqcTB8:XsVeDR9QPRk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=wULeZzqcTB8:XsVeDR9QPRk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=wULeZzqcTB8:XsVeDR9QPRk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=wULeZzqcTB8:XsVeDR9QPRk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=wULeZzqcTB8:XsVeDR9QPRk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=wULeZzqcTB8:XsVeDR9QPRk:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/wULeZzqcTB8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/8396948445989127223/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/05/how-to-debug-windows-8-metro-secondary.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/8396948445989127223?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/8396948445989127223?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/wULeZzqcTB8/how-to-debug-windows-8-metro-secondary.html" title="How to Debug a Windows 8 Metro Secondary Tile" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-difmK1w5pTI/T7ftbKgN1lI/AAAAAAAAAq8/3PakGSyWhms/s72-c/07fig04.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/05/how-to-debug-windows-8-metro-secondary.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkINRnszcCp7ImA9WhVUEEo.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6268150992848609306</id><published>2012-05-15T06:43:00.001-04:00</published><updated>2012-05-15T06:43:17.588-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-15T06:43:17.588-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="windows runtime" /><category scheme="http://www.blogger.com/atom/ns#" term="asynchronous" /><category scheme="http://www.blogger.com/atom/ns#" term="task parallel library" /><title>The Task: Async and Await in a Windows Runtime World</title><content type="html">&lt;p&gt;In my &lt;a href="http://csharperimage.jeremylikness.com/2012/05/task-events-asynchronous-calls-async.html" target="_blank"&gt;last blog post&lt;/a&gt;, I covered how to wrap your arms around the Task class and its relationship to the new &lt;font face="Consolas"&gt;async&lt;/font&gt; and &lt;font face="Consolas"&gt;await&lt;/font&gt; keywords. I mentioned that the post was focused on the .NET Framework only because the Windows Runtime handles these operations differently. In this post, I’ll cover what those differences are.&lt;/p&gt; &lt;h3&gt;Task is a Task is a Task&lt;/h3&gt; &lt;p&gt;First, in the Windows Runtime, a &lt;font face="Consolas"&gt;Task&lt;/font&gt; is a &lt;font face="Consolas"&gt;Task&lt;/font&gt; … is a &lt;font face="Consolas"&gt;Task&lt;/font&gt;. You can write your code to return a &lt;font face="Consolas"&gt;Task&lt;/font&gt; or &lt;font face="Consolas"&gt;Task&amp;lt;T&amp;gt;&lt;/font&gt; in your Windows 8 Metro applications. If you are going to expose a Windows Runtime (WinRT) component, however, one of the rules is that you must always return a WinRT type. For asynchronous operations, there are four types allowed:&lt;/p&gt; &lt;table border="1" cellspacing="0" cellpadding="2" width="668"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="139"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="253"&gt;&lt;strong&gt;No Result&lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="274"&gt;&lt;strong&gt;Returns Results&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="139"&gt;&lt;strong&gt;No Progress or Cancellation&lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="253"&gt;&lt;font face="Consolas"&gt;IAsyncAction&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="274"&gt;&lt;font face="Consolas"&gt;IAsyncOperation&amp;lt;TResult&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="139"&gt;&lt;strong&gt;Supports Progress and/or Cancellation&lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="253"&gt;&lt;font face="Consolas"&gt;IAsyncActionWithProgress&amp;lt;TProgress&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="274"&gt;&lt;font face="Consolas"&gt;IAsyncOperationWithProgress&amp;lt;TResult, TProgress&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;The type you return depends on whether or not you return a result, and whether or not you support checking progress and/or cancellation. &lt;/p&gt; &lt;h3&gt;Task is a &lt;font face="Consolas"&gt;IAsyncAction&lt;/font&gt; or &lt;font face="Consolas"&gt;IAsyncOperation&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/h3&gt; &lt;p&gt;If you don’t support progress or cancellation, returning the necessary type is easy: simply use a &lt;font face="Consolas"&gt;Task&lt;/font&gt; and return it using one of the extension methods to convert it to the corresponding WinRT type. For example, the following useless piece of code iterates through all of the available integers and returns nothing:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IAsyncAction IterateAsync()
{
   &lt;span class="kwrd"&gt;return&lt;/span&gt; Task.Run(() =&amp;gt;
   {
      &lt;span class="kwrd"&gt;for&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt; x = Int.MinValue; x &amp;lt; Int.MaxValue; x++) ;
   }).AsAsyncAction();
}
&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;For a more practical example, consider the multiplication method I used in the last blog post. To convert that to a result, I simply do: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; IAsyncOperation&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
{
   &lt;span class="kwrd"&gt;return&lt;/span&gt; Task.Run(() =&amp;gt; a * b)
      .AsAsyncOperation();
}
&lt;/pre&gt;
&lt;p&gt;That’s fairly simple and straightforward. What about supporting progress and/or cancellation?&lt;/p&gt;
&lt;h3&gt;Forget Tasks: The 411 on &lt;font face="Consolas"&gt;AsyncInfo&lt;/font&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;font face="Consolas"&gt;AsyncInfo&lt;/font&gt; class is there to assist you with performing asynchronous actions or operations that support cancellation and reporting progress.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IAsyncOperationWithProgress&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
{
   &lt;span class="kwrd"&gt;return&lt;/span&gt; AsyncInfo.Run&amp;lt;IList&amp;lt;&lt;span class="kwrd"&gt;long&lt;/span&gt;&amp;gt;, &lt;span class="kwrd"&gt;double&lt;/span&gt;&amp;gt;((token, progress) =&amp;gt;
      Task.Run&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;(() =&amp;gt;
      {
         progress.Report(0);
         var result = a*b;
         token.ThrowIfCancellationRequested();
         progress.Report(100.0);
         &lt;span class="kwrd"&gt;return&lt;/span&gt; result;
      }, token));
}&lt;/pre&gt;
&lt;p&gt;Obviously the operation is a bit contrived as the multiplication operation doesn’t take as long, but hopefully this simple example illustrates the point of what is possible. The &lt;font face="Consolas"&gt;IAsyncActionWithProgress&lt;/font&gt; will work the same way, it simply doesn’t return a result.&lt;/p&gt;
&lt;p&gt;There you have it … the scoop on the new &lt;font face="Consolas"&gt;async&lt;/font&gt; and &lt;font face="Consolas"&gt;await&lt;/font&gt; keywords and how they behave both with and without the Windows Runtime. Now that you have the basics, head over to Stephen Toub’s blog post and read the far more in depth &lt;a href="http://www.windows8tricks.net/2012/05/diving-deep-with-winrt-and-await/" target="_blank"&gt;Diving Deep with WinRT and await&lt;/a&gt;.
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6268150992848609306?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-eVKOJ5ICiQ:0pSccCZm4Ng:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-eVKOJ5ICiQ:0pSccCZm4Ng:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-eVKOJ5ICiQ:0pSccCZm4Ng:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=-eVKOJ5ICiQ:0pSccCZm4Ng:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-eVKOJ5ICiQ:0pSccCZm4Ng:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=-eVKOJ5ICiQ:0pSccCZm4Ng:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-eVKOJ5ICiQ:0pSccCZm4Ng:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-eVKOJ5ICiQ:0pSccCZm4Ng:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/-eVKOJ5ICiQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6268150992848609306/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/05/task-async-and-await-in-windows-runtime.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6268150992848609306?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6268150992848609306?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/-eVKOJ5ICiQ/task-async-and-await-in-windows-runtime.html" title="The Task: Async and Await in a Windows Runtime World" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/05/task-async-and-await-in-windows-runtime.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQARHo4eCp7ImA9WhVVF0U.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-9129572958395123471</id><published>2012-05-11T20:41:00.001-04:00</published><updated>2012-05-11T20:42:25.430-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-11T20:42:25.430-04:00</app:edited><title>The Task: Events, Asynchronous Calls, Async and Await</title><content type="html">&lt;p&gt;Almost any software application today will likely contain a long-running process. “Long-running” may be a relative term but in the Windows Runtime it is specifically anything that could take longer than 50ms to execute. That’s a fairly small window, and it means those operations will need to run concurrently to the main application thread. Concurrency is important in both client applications (to keep from blocking the UI) and server applications (to accommodate multiple simultaneous requests). &lt;/p&gt; &lt;p&gt;The new technology referred to as &lt;a href="http://msdn.microsoft.com/en-us/vstudio/gg316360" target="_blank"&gt;Visual Studio Asynchronous Programming&lt;/a&gt; provides a streamlined language syntax for asynchronous development. It does this by providing two new keywords: &lt;font face="Consolas"&gt;async&lt;/font&gt; and &lt;font face="Consolas"&gt;await&lt;/font&gt;. While these keywords may simplify asynchronous development, they can still be confusing to developers. There are a lot of materials out there but I thought it might help to take a very simple example and explore just what these keywords are and how they operate. In this post I’ll focus specifically on the .NET Framework 4.5 support. While they are also supported for Metro-style applications, the implementation is slightly different.&lt;/p&gt; &lt;h3&gt;The Main Event&lt;/h3&gt; &lt;p&gt;In the movie &lt;em&gt;Mission Impossible II&lt;/em&gt;, the short-lived protagonist Dr. Nekhorvich says: &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;“…every search for a hero must begin with something every hero needs, a villain. So in a search for our hero, Bellerophon, we have created a more effective monster: Chimera.”&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;In the search for an elegant solution to asynchronous programming we must start with some of the rougher implementations that have plagued developers in the past. &lt;/p&gt; &lt;p&gt;The event-based pattern is probably one of the most well-known asynchronous patterns to .NET developers as it is prevalent throughout the base library. Let’s assume I have a method that multiplies two numbers and for some crazy reason (maybe I’m sending it over a 300 baud modem to my Commodore 64 to process the result on the 6502 chip … you know, using a bunch of ROR operations) it takes a bit longer to process than I’d like, so I want to make sure it executes asynchronously. The first thing I’ll do is create an event argument payload for the result:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MultiplyEventArgs : EventArgs 
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Result
    {
        get;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; set; 
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; MultiplyEventArgs(&lt;span class="kwrd"&gt;int&lt;/span&gt; result)
    {
        Result = result;
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Next, I’ll define an interface:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IMultiplierEvent
{
    &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;MultiplyEventArgs&amp;gt; MultiplyCompleted;
    &lt;span class="kwrd"&gt;void&lt;/span&gt; MultiplyAsync(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b); 
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Finally, I’ll implement the class that executes the operation asynchronous and fires the completed event when done.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MultiplierEvent : IMultiplierEvent
{

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;MultiplyEventArgs&amp;gt; MultiplyCompleted;

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RaiseCompleted(&lt;span class="kwrd"&gt;int&lt;/span&gt; result)
    {
          
        var handler = MultiplyCompleted;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (handler != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            handler(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplyEventArgs(result));
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MultiplyAsync(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
    {
        Task.Run(() =&amp;gt; RaiseCompleted(a * b));
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;I can test this in a simple console program with a method call: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; Program
{
    &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)
    {
        var p = &lt;span class="kwrd"&gt;new&lt;/span&gt; Program();
            
        p.DoEvent();

        Console.ReadLine();
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;The implementation requires two methods, one to set it up and another to receive the completed event. Not bad, but you can imagine handling a chain of multiple events could get ugly quickly.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoEvent()
{
    Console.WriteLine(&lt;span class="str"&gt;"Firing as an event 2 * 3 ..."&lt;/span&gt;); 
    IMultiplierEvent eventBased = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplierEvent();
    eventBased.MultiplyCompleted += eventBased_MultiplyCompleted;
    eventBased.MultiplyAsync(2, 3);
}

&lt;span class="kwrd"&gt;void&lt;/span&gt; eventBased_MultiplyCompleted(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, MultiplyEventArgs e)
{
    Console.WriteLine(&lt;span class="str"&gt;"Event result: {0}"&lt;/span&gt;, e.Result); 
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;That’s the old world of events.&lt;/p&gt;
&lt;h3&gt;The Asynchronous Programming Model&lt;/h3&gt;
&lt;p&gt;Another popular asynchronous model is the Asynchronous Programming Model, or APM. The framework provides the &lt;font face="Consolas"&gt;IAsyncResult&lt;/font&gt; interface and you specify a pair of methods to &lt;font face="Consolas"&gt;Begin&lt;/font&gt; and &lt;font face="Consolas"&gt;End&lt;/font&gt; the operation. The first method always returns the &lt;font face="Consolas"&gt;IAsyncResult&lt;/font&gt; and the second method always takes the &lt;font face="Consolas"&gt;IAsyncResult&lt;/font&gt; and returns the result of the call.&lt;/p&gt;
&lt;p&gt;In the implementation I create a nested class used to help maintain the state between the calls:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; AsyncState
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Delegate MethodToCall { get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; State { get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set; }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; AsyncState(Delegate methodToCall, &lt;span class="kwrd"&gt;object&lt;/span&gt; state)
    {
        MethodToCall = methodToCall;
        State = state;
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Then I implement the methods. Notice that I’m casting the method call to a delegate and taking advantage of the built-in capability to invoke it asynchronously, then wrapping the end call to return the result. &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MultiplierApm : IMultiplierApm
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; AsyncState [...]

    &lt;span class="kwrd"&gt;public&lt;/span&gt; IAsyncResult BeginMultiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b, AsyncCallback callback, &lt;span class="kwrd"&gt;object&lt;/span&gt; state)
    {
        Func&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; multiply = Multiply;
        var asyncState = &lt;span class="kwrd"&gt;new&lt;/span&gt; AsyncState(multiply, state);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; multiply.BeginInvoke(a, b, callback, asyncState); 
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; EndMultiply(IAsyncResult asyncResult)
    {
        var asyncState = (AsyncState)asyncResult.AsyncState;
        var multiply = (Func&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;)asyncState.MethodToCall;
        &lt;span class="kwrd"&gt;return&lt;/span&gt; multiply.EndInvoke(asyncResult); 
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; a * b;
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now that I have an implementation, I can call it like this: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoApm()
{
    Console.WriteLine(&lt;span class="str"&gt;"Firing as APM 3 * 4 ..."&lt;/span&gt;); 
    IMultiplierApm apmBased = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplierApm();
    apmBased.BeginMultiply(3, 4,
        result =&amp;gt;
        {
            var &lt;span class="kwrd"&gt;value&lt;/span&gt; = apmBased.EndMultiply(result);
            Console.WriteLine(&lt;span class="str"&gt;"Apm result: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;value&lt;/span&gt;);
        }, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Note that I might have used two methods for the APM as well, I simplify chose to take a short cut but using a lambda expression instead. &lt;/p&gt;
&lt;h3&gt;Taking Asynchronous Operations to Task&lt;/h3&gt;
&lt;p&gt;With the new task library, setting up and calling asynchronous operations is far easier than the previous two approaches. First, I can use a single method signature and simplify specify the need for asynchronous operations by wrapping the result in a &lt;font face="Consolas"&gt;Task&lt;/font&gt;:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IMultiplier
{
    Task&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b); 
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;For the implementation, I can easily use the built-in methods available in the library to spin off my thread: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Multiplier : IMultiplier
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Task&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
    {
        &lt;span class="rem"&gt;//return Task.Factory.StartNew(() =&amp;gt; a * b);&lt;/span&gt;
        &lt;span class="kwrd"&gt;return&lt;/span&gt; Task.Run(() =&amp;gt; a * b); 

    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Finally, I can use the new keywords to make calling and waiting for the result easy. When I want to do something asynchronously without blocking the thread I’m on, I simply modify the method with the &lt;font face="Consolas"&gt;async&lt;/font&gt; keyword, then &lt;font face="Consolas"&gt;await&lt;/font&gt; the asynchronous operaiton. Again, it’s as simple as &lt;font face="Consolas"&gt;async&lt;/font&gt; to mark the method’s intention of spinning of a separate task to wait for, then &lt;font face="Consolas"&gt;await&lt;/font&gt; to launch the thread and receive the results in a single line of code.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; async &lt;span class="kwrd"&gt;void&lt;/span&gt; DoTask()
{
    Console.WriteLine(&lt;span class="str"&gt;"Firing as task 4 * 5 ..."&lt;/span&gt;);
    IMultiplier taskBased = &lt;span class="kwrd"&gt;new&lt;/span&gt; Multiplier();
    Console.WriteLine(&lt;span class="str"&gt;"Task result: {0}"&lt;/span&gt;, await taskBased.Multiply(4, 5));
}       &lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;What happens here is that the current thread runs up until the await operation. There, the operation is spun off on a new thread. The main thread will wait for that thread to complete but will not block – it is not a synchronous operation. When the concurrent thread finishes what it is doing, it will drop the result back on the calling thread and allow me to interrogate the result. Notice that I can even nest the call inside of other operations – here the task must actually complete before it can pass the result to the string formatter which in turn sends the output to the console. &lt;/p&gt;
&lt;p&gt;Simple interface design, simple implementation, and simple execution. I like it! But what do I do about those existing events and APM-based interfaces? &lt;/p&gt;
&lt;h3&gt;Wrapping Events&lt;/h3&gt;
&lt;p&gt;Fortunately, it’s possible to bundle up any asynchronous operation into a task. For this reason, I almost always declare my interfaces using Task. That way I can hide the underlying implementation. Let’s test this out. How can I take my &lt;font face="Consolas"&gt;IMultiplier&lt;/font&gt; interface and use it to call my &lt;font face="Consolas"&gt;MultiplierEvent&lt;/font&gt; class? The trick is to use a &lt;font face="Consolas"&gt;TaskCompletionSource&lt;/font&gt;. This special class allows me to perform an asynchronous operation using any pattern I prefer and then set a result when I’m done. The token will expose the event as a task that can be awaited. Here is a wrapper class that implements the simple interface:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MultiplierEventAsTask : IMultiplier
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; IMultiplierEvent _event;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; MultiplierEventAsTask()
    {
        _event = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplierEvent();
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; Task&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
    {
        var tcs = &lt;span class="kwrd"&gt;new&lt;/span&gt; TaskCompletionSource&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;();
        _event.MultiplyCompleted += (sender, args) =&amp;gt;
                {
                    tcs.SetResult(args.Result);
                };
        _event.MultiplyAsync(a, b); 
        &lt;span class="kwrd"&gt;return&lt;/span&gt; tcs.Task;
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;I can then call it the same way I did the task-based implementation.&lt;/p&gt;
&lt;h3&gt;Wrapping the APM &lt;/h3&gt;
&lt;p&gt;Wrapping the APM model is even easier because the library provides a set of functions to convert existing operations. The &lt;font face="Consolas"&gt;FromAsync&lt;/font&gt; method will take most APM-style calls and turn them into tasks: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MultiplierApmAsTask : IMultiplier
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; IMultiplierApm _apm;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; MultiplierApmAsTask()
    {
        _apm = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplierApm();
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; Task&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; Multiply(&lt;span class="kwrd"&gt;int&lt;/span&gt; a, &lt;span class="kwrd"&gt;int&lt;/span&gt; b)
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; Task&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;.Factory.FromAsync(_apm.BeginMultiply, 
            _apm.EndMultiply, a, b, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
    }
} &lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Once again, the end result is the same simple interface despite a completely different implementation. &lt;/p&gt;
&lt;h3&gt;That’s a Wrap!&lt;/h3&gt;
&lt;p&gt;Using the Task we can now take various implementations and simplify them to a common, easy to use and understand interface. This little piece of code will execute each of the different implementations in order, waiting for the result but without blocking the main thread: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; async &lt;span class="kwrd"&gt;void&lt;/span&gt; DoAll()
{
    &lt;span class="rem"&gt;// convert event to a task &lt;/span&gt;
    Console.WriteLine(&lt;span class="str"&gt;"Firing all converted events in order ..."&lt;/span&gt;);
            
    IMultiplier taskFromEvent = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplierEventAsTask();
    IMultiplier taskFromApm = &lt;span class="kwrd"&gt;new&lt;/span&gt; MultiplierApmAsTask();
    IMultiplier task = &lt;span class="kwrd"&gt;new&lt;/span&gt; Multiplier();

    Console.WriteLine(&lt;span class="str"&gt;"2 * 3 = {0}"&lt;/span&gt;, await taskFromEvent.Multiply(2, 3));
    Console.WriteLine(&lt;span class="str"&gt;"4 * 5 = {0}"&lt;/span&gt;, await taskFromApm.Multiply(4, 5));
    Console.WriteLine(&lt;span class="str"&gt;"6 * 7 = {0}"&lt;/span&gt;, await task.Multiply(6, 7));            
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;There is a lot more you can do than simply &lt;font face="Consolas"&gt;await&lt;/font&gt; tasks. You can combine tasks, chain tasks, even wait for one or all tasks to complete before moving onto another task. Once you understand that &lt;font face="Consolas"&gt;async&lt;/font&gt; simply specifies the intention to do something asynchronously without blocking the main thread, and &lt;font face="Consolas"&gt;await&lt;/font&gt; simply launches a task and returns the result once that task is complete, you should be well on your way to simplifying your asynchronous development.&lt;/p&gt;
&lt;p&gt;Download the sample project &lt;a href="https://sites.google.com/site/jeremyliknessextras/source-code/ShowAsyncInterface.zip?attredirects=0&amp;amp;d=1" target="_blank"&gt;here&lt;/a&gt;. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-9129572958395123471?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-pD_TqbyuWk:4BWYDWUuk_M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-pD_TqbyuWk:4BWYDWUuk_M:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-pD_TqbyuWk:4BWYDWUuk_M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=-pD_TqbyuWk:4BWYDWUuk_M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-pD_TqbyuWk:4BWYDWUuk_M:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=-pD_TqbyuWk:4BWYDWUuk_M:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-pD_TqbyuWk:4BWYDWUuk_M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-pD_TqbyuWk:4BWYDWUuk_M:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/-pD_TqbyuWk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/9129572958395123471/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/05/task-events-asynchronous-calls-async.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/9129572958395123471?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/9129572958395123471?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/-pD_TqbyuWk/task-events-asynchronous-calls-async.html" title="The Task: Events, Asynchronous Calls, Async and Await" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/05/task-events-asynchronous-calls-async.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQGRns4fip7ImA9WhVXFEQ.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-8083528054939728987</id><published>2012-04-15T09:42:00.000-04:00</published><updated>2012-04-15T09:42:07.536-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-15T09:42:07.536-04:00</app:edited><title>Sample Applications from Designing Silverlight Business Applications</title><content type="html">&lt;p&gt;I've received a few emails regarding the book that the code files are not available from the publisher website. I've spoken with the publisher about this and they are working to correct it, but I wanted to provide a link for those of you who have been patiently waiting. As a backup to the main website, I've posted all of the sample applications online to SkyDrive and you can download them by clicking on &lt;a href="http://sdrv.ms/Is5nLV" target="_blank"&gt;this link&lt;/a&gt;. I appreciate you patience and hope you will take the time to post a review on the site you purchased the book from once you have read and worked through the examples to help others who are considering picking it up for themselves. 
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-8083528054939728987?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Y7aNC5Yo1fE:0fWuG01P2fY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Y7aNC5Yo1fE:0fWuG01P2fY:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Y7aNC5Yo1fE:0fWuG01P2fY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=Y7aNC5Yo1fE:0fWuG01P2fY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Y7aNC5Yo1fE:0fWuG01P2fY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=Y7aNC5Yo1fE:0fWuG01P2fY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Y7aNC5Yo1fE:0fWuG01P2fY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Y7aNC5Yo1fE:0fWuG01P2fY:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/Y7aNC5Yo1fE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/8083528054939728987/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/04/sample-applications-from-designing.html#comment-form" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/8083528054939728987?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/8083528054939728987?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/Y7aNC5Yo1fE/sample-applications-from-designing.html" title="Sample Applications from Designing Silverlight Business Applications" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>7</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/04/sample-applications-from-designing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8BSXg7fSp7ImA9WhVQGUo.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6718281641208103204</id><published>2012-04-09T08:34:00.001-04:00</published><updated>2012-04-09T08:34:18.605-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-09T08:34:18.605-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mvvm" /><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="codestock" /><category scheme="http://www.blogger.com/atom/ns#" term="winrt" /><title>CodeStock 2012</title><content type="html">&lt;p&gt;Thanks for everyone's support and votes. I have been selected to present two sessions at CodeStock 2012.
&lt;p&gt;Per the &lt;a href="http://codestock.org/" target="_blank"&gt;CodeStock&lt;/a&gt; website: 
&lt;blockquote&gt;CodeStock is a two day event for technology and information exchange.  Created by the community, for the community &amp;mdash; this is not an industry trade show pushing the latest in marketing as technology, but a gathering of working professionals sharing knowledge and experience.&lt;/blockquote&gt;
&lt;p&gt;This is always a great conference. I have the added bonus of getting close to the corporate headquarters for &lt;a href="http://www.wintellect.com/" target="_blank"&gt;Wintellect&lt;/a&gt; and visiting company co-founder &lt;a href="http://wintellect.com/Company/Our-Management/Jeff-Prosise" target="_blank"&gt;Jeff Prosise&lt;/a&gt;. This year there were quite a few Wintellect employees selected to speak. I'll be there with Mitch Harpur (&lt;a href="http://codestock.org/Sessions/come-get-a-message-at-the-spa.aspx" target="_blank"&gt;Come Get a Message at the SPA&lt;/a&gt;), Rik Robinson (&lt;a href="http://codestock.org/Sessions/css3-how-to-fake-it-while-they-bake-it.aspx" target="_blank"&gt;CSS3: How to Fake It While They Bake It&lt;/a&gt; and &lt;a href="http://codestock.org/Sessions/touring-the-jquery-ui-widget-factory.aspx" target="_blank"&gt;Touring the jQuery UI Widget Factory&lt;/a&gt;), John Garland (&lt;a href="http://codestock.org/Sessions/putting-the-cloud-in-your-pocket-a-guide-to-using-windows-azure-to-build-cloud-enabled-windows-phone.aspx" target="_blank"&gt;Putting the Cloud in Your Pocket: A Guide to Using Windows Azure to Build Cloud-Enabled Windows Phone Apps&lt;/a&gt;), and our Technical Director &lt;a href="http://wintellect.com/Company/Our-Management/Steven-Porter" target="_blank"&gt;Steve Porter&lt;/a&gt;. 
&lt;p&gt;I'll be doing two sessions: 
&lt;p&gt;&lt;h2&gt;&lt;a href="http://codestock.org/Sessions/mvvm-for-modern-application-development.aspx" target="_blank"&gt;MVVM for Modern Application Development&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Model-View-ViewModel pattern was introduced for Windows Presentation Foundation applications (WPF) and later exploded in popularity with the introduction of various frameworks to support development on additional platforms including Silverlight and Windows Phone. The release of KnockoutJS the pattern has extended MVVM to the web and exposed it to the JavaScript stack, while the new Windows 8 Metro platform embraces the same XAML and C#-based technologies that WPF and Silverlight pioneered. In this talk, Jeremy Likness takes a deep dive into the history of the pattern, describes its benefits, and discusses how it relates to modern application development. Is it a bad fit for web applications? Does it belong in the Metro space? Learn the benefits and trade-offs to help decide if this pattern makes sense in your projects moving forward. 
&lt;p&gt;&lt;h2&gt;&lt;a href="http://codestock.org/Sessions/top-10-developer-features-in-windows-8-metro.aspx" target="_blank"&gt;Top 10 Developer Features in Windows 8 Metro&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Windows 8 presents a new platform for application development called Metro. This platform is specifically focused on the tablet and slate market and provides many advanced features including touch-friendly interfaces and advanced power management features. Metro also introduces a new runtime known as WinRT that exposes some incredible contracts and interfaces that make it easier than ever before to build connected, collaborative, touch-friendly applications. Jeremy Likness shares the top 10 features developers will love about this platform. This is based on my recent article &lt;a href="http://www.informit.com/articles/article.aspx?p=1853667" target="_blank"&gt;here&lt;/a&gt; with live code samples and demos. 
&lt;p&gt;It should be a very good conference and I hope you are able to make it. I'm always happy to connect with blog readers and Twitter followers so please don't hesitate to pop over and say "Hello" even if you can't make my sessions. It's tough putting together a schedule for this event because there are so many good talks. If you think you may be going, why not drop a line in the comments or ping me on &lt;a href="http://twitter.com/jeremylikness" target="_blank"&gt;Twitter&lt;/a&gt;? I look forward to seeing some of you there. 
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6718281641208103204?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aoseznmQYQI:2_ofXViVk3A:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aoseznmQYQI:2_ofXViVk3A:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aoseznmQYQI:2_ofXViVk3A:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=aoseznmQYQI:2_ofXViVk3A:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aoseznmQYQI:2_ofXViVk3A:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=aoseznmQYQI:2_ofXViVk3A:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aoseznmQYQI:2_ofXViVk3A:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aoseznmQYQI:2_ofXViVk3A:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/aoseznmQYQI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6718281641208103204/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/04/codestock-2012.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6718281641208103204?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6718281641208103204?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/aoseznmQYQI/codestock-2012.html" title="CodeStock 2012" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/04/codestock-2012.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcMR3o7fip7ImA9WhVQFkk.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-3189221479493606229</id><published>2012-04-05T12:21:00.001-04:00</published><updated>2012-04-05T12:24:46.406-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-05T12:24:46.406-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight 5" /><category scheme="http://www.blogger.com/atom/ns#" term="xaml" /><category scheme="http://www.blogger.com/atom/ns#" term="windows runtime" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><category scheme="http://www.blogger.com/atom/ns#" term="winrt" /><title>Designing Silverlight Business Applications Officially Released</title><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321810414" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="slbookcover" border="0" alt="slbookcover" src="http://lh6.ggpht.com/-V8-lch3ip3U/T33GescOOHI/AAAAAAAAAps/vuQXH0JYqz0/slbookcover%25255B3%25255D.png?imgmax=800" width="180" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In June of 2011 I started the journey of writing a Silverlight book. The Silverlight team was about to release version 5 with an incredible set of new features that would revolutionize how it can be used in the enterprise. I knew there were already a number of books available to use a reference for fundamentals and controls, so I wanted to dig deeper and hit the topics I was challenged with in my job as a consultant as well as those questions that continually seem to surface on blogs and forums. I began with an introduction that analyzed client technologies available at the time, especially focusing on how HTML5 was evolving but not yet mature. The focus of the book is my “sweet spot” as I have been developing Silverlight applications for the enterprise since it’s version 3 release in 2008. &lt;/p&gt; &lt;p&gt;No one could have realized just how much change would take place over the following year. Silverlight 5 was released but without a roadmap for version 6 and Windows 8 was announced. Fortunately it was soon discovered that Windows 8 provides a path to build applications using C# and XAML, has full support for running Silverlight 5, and through the Portable Class Library even provides a path to create code that can be used to target both present state and future state applications. &lt;/p&gt; &lt;p&gt;I had the privilege of working with a phenomenal team at Addison-Wesley Professional along with two very experienced Silverlight developers as technical editors who helped shape the book to contain the depth and quality of information that is available today. &lt;/p&gt; &lt;p&gt;The book is in stock at Amazon.com as of today. There are a number of ways you can order the book:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Paperback, eBook, and combo packages at the &lt;a href="http://www.informit.com/store/product.aspx?isbn=0321810414" target="_blank"&gt;publisher’s website&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Paperback from Amazon.com by &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321810414" target="_blank"&gt;clicking on this link&lt;/a&gt;. &lt;/li&gt; &lt;li&gt;Kindle edition at &lt;a href="http://www.amazon.com/gp/product/B007P40A6S/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B007P40A6S" target="_blank"&gt;this link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.barnesandnoble.com/w/designing-silverlight-business-applications-jeremy-likness/1105140264?ean=9780321810410&amp;amp;itm=1&amp;amp;usri=designing+silverlight+business+applications" target="_blank"&gt;Barnes and Noble&lt;/a&gt; (available for NOOK as well)&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.powells.com/biblio/62-9780321810410-0" target="_blank"&gt;Powell’s books&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://google.com/search?q=0321810414" target="_blank"&gt;Search by the ISBN 0321810414&lt;/a&gt; for international options – it is available overseas through several channels&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The &lt;a href="http://www.informit.com/store/product.aspx?isbn=0321810414" target="_blank"&gt;publisher’s website&lt;/a&gt; provides you with the table of contents and provides a sample chapter to download that covers the Model-View-View Model (MVVM) pattern.&lt;/p&gt; &lt;p&gt;The book also features the &lt;a href="http://jounce.codeplex.com/" target="_blank"&gt;Jounce MVVM Open Source Framework&lt;/a&gt; I developed along with a sample application that covers &lt;a href="http://csharperimage.jeremylikness.com/2012/03/jounce-mvvm-wcf-ria-printing-and-more.html" target="_blank"&gt;quite a few features&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Is this book relevant? I believe it is if you’ll accept my biased opinion because companies have Line of Business applications today, they are not releasing Windows 8 applications right now, and Silverlight remains a very viable solution for these applications. The majority of concepts covered in this book translate to the C#/XAML stack used for Windows 8 Metro applications and apply to building enterprise applications in general. There has been tremendous support for this and I’ve included some of the most difficult patterns and problems to tackle with solutions that translate to other platforms as well.&lt;/p&gt; &lt;p&gt;I want to thank the community for their incredible support as it has been an amazing journey. I also would ask that if you have invested in the Rough Cuts, eBooks, paperback, or other editions, that once you’ve had time to read this book you take the time to post your review and comments online. It is your reviews and comments that other developers will trust when they are making the decision to invest, so honest feedback helps them decide whether or not this is a resource that will provide them with value. It also helps me improve how I deliver content to make it the best possible quality for you.&lt;/p&gt; &lt;p&gt;So what’s next for me? I’m already several chapters into my next book. It will cover Building Windows 8 Metro Applications with C# and XAML, and I’ll include information about how Silverlight developers today can take advantage of the Metro platform for tomorrow’s applications. This book will be available for early access to read, review, and provide feedback through the Safari Rough Cuts program. Stay tuned and I’ll announce when more information becomes available.&lt;/p&gt; &lt;p&gt;Thanks again!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-3189221479493606229?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=7Vcbeq7CPQQ:sMVqlfO5SgI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=7Vcbeq7CPQQ:sMVqlfO5SgI:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=7Vcbeq7CPQQ:sMVqlfO5SgI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=7Vcbeq7CPQQ:sMVqlfO5SgI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=7Vcbeq7CPQQ:sMVqlfO5SgI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=7Vcbeq7CPQQ:sMVqlfO5SgI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=7Vcbeq7CPQQ:sMVqlfO5SgI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=7Vcbeq7CPQQ:sMVqlfO5SgI:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/7Vcbeq7CPQQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/3189221479493606229/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/04/designing-silverlight-business.html#comment-form" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3189221479493606229?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3189221479493606229?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/7Vcbeq7CPQQ/designing-silverlight-business.html" title="Designing Silverlight Business Applications Officially Released" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-V8-lch3ip3U/T33GescOOHI/AAAAAAAAAps/vuQXH0JYqz0/s72-c/slbookcover%25255B3%25255D.png?imgmax=800" height="72" width="72" /><thr:total>12</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/04/designing-silverlight-business.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIASXY7eyp7ImA9WhVQFEo.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6606390968871840213</id><published>2012-04-03T13:02:00.000-04:00</published><updated>2012-04-03T13:02:28.803-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-03T13:02:28.803-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="xaml" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><title>The Top 10 Features Windows 8 Metro Developers Will Love</title><content type="html">&lt;p&gt;Windows 8 Metro is a new platform for developing applications that are tailored to the devices on which they run. These devices may include traditional desktops and laptops as well as the new tablet and slate form factors. In this article I cover the top ten features developers will love about the new development environment. This is part of my work on the upcoming book, Building Windows 8 Metro Applications with XAML and C#. 
&lt;p&gt;&lt;a href="http://www.informit.com/articles/article.aspx?p=1853667" target="_blank"&gt;Read the full article online at InformIT.&lt;/a&gt;
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6606390968871840213?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=JH5b-vGGjZk:h2UqEdCNa9k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=JH5b-vGGjZk:h2UqEdCNa9k:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=JH5b-vGGjZk:h2UqEdCNa9k:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=JH5b-vGGjZk:h2UqEdCNa9k:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=JH5b-vGGjZk:h2UqEdCNa9k:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=JH5b-vGGjZk:h2UqEdCNa9k:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=JH5b-vGGjZk:h2UqEdCNa9k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=JH5b-vGGjZk:h2UqEdCNa9k:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/JH5b-vGGjZk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6606390968871840213/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/04/top-10-features-windows-8-metro.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6606390968871840213?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6606390968871840213?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/JH5b-vGGjZk/top-10-features-windows-8-metro.html" title="The Top 10 Features Windows 8 Metro Developers Will Love" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/04/top-10-features-windows-8-metro.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YMSX8yeip7ImA9WhVQEEs.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6552656297537497305</id><published>2012-03-29T19:53:00.001-04:00</published><updated>2012-03-29T19:53:08.192-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-29T19:53:08.192-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".net" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="winrt" /><title>.NET and Metro: The Windows Runtime and the CLR on Windows 8</title><content type="html">&lt;p&gt;Many developers tend to look at Windows 8 as a completely new platform and even question whether it heralded the imminent demise of managed code. After spending many months digging into the Windows Runtime (WinRT), Metro style or “tailored” applications, and exploring how they related to the .NET Framework, I’ve come to the conclusion that the two work very closely together and in fact are engineered to integrate. That means good news for managed developers. The .NET Framework 4.5 is very much “Metro-aware” while the Windows Runtime knows how to shake hands with the CLR. The purpose of this post is to elaborate on this a bit more than what I covered in my &lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by.html" target="_blank"&gt;Portable Class Library&lt;/a&gt; series.&lt;/p&gt; &lt;h2&gt;Metadata&lt;/h2&gt; &lt;p&gt;The first thing to note is that WinRT components, regardless of what language they were written in, share the same metadata format as .NET Framework assemblies. This is what allows you to navigate to the metadata folder at &lt;strong&gt;c:\windows\system32\WinMetadata&lt;/strong&gt; and be able to use &lt;font face="Courier New"&gt;ildasm.exe&lt;/font&gt; to expose the definitions of WinRT components that are part of the Windows 8 operating system. The standard is documented as ECMA-335 and you can check &lt;a href="http://www.ecma-international.org/publications/standards/Ecma-335.htm" target="_blank"&gt;this link&lt;/a&gt; to learn more.&lt;/p&gt; &lt;p&gt;As part of this metadata, types and assemblies can be tagged with a new Intermediate Language (IL) keyword called &lt;font face="Courier New"&gt;windowsruntime&lt;/font&gt;. This keyword tags the type as a WinRT component. The .NET Framework uses this to know when to marshal parameters because the WinRT type system is not the same as the one supported by the CLR. Fortunately, this is supported “under the covers” as you’ll see in the next section. When an assembly is tagged with the keyword, it instructs the .NET Framework to use a special APIs like the one called &lt;font face="Courier New"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/br229860(v=vs.85).aspx" target="_blank"&gt;RoResolveNamespace&lt;/a&gt;&lt;/font&gt; to load references. This is a way that all supported WinRT languages can access underlying components.&lt;/p&gt; &lt;h2&gt;Type Conversion&lt;/h2&gt; &lt;p&gt;As I mentioned, the .NET Framework does some magic with type conversion. This happens in both directions (calls into and values received from WinRT components). This is not new – this has been supported for awhile and you can see a list of &lt;a href="http://msdn.microsoft.com/en-us/library/0t2cwe11.aspx" target="_blank"&gt;Default Marshaling for Value Types&lt;/a&gt; in the MSDN documentation. A &lt;font face="Courier New"&gt;System.Int32&lt;/font&gt; becomes a &lt;font face="Courier New"&gt;ELEMENT_TYPE_I4&lt;/font&gt; and vice versa. These are what are referred to as “fundamental types.”&lt;/p&gt; &lt;p&gt;In addition, however, the CLR performs implicit mapping to more complex types. If you’ve been doing any Windows 8 development, you are probably familiar with conversions that look like this: &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;Windows.Foundation.Collections.IVector&amp;lt;T&amp;gt;&lt;/font&gt; &amp;lt;= =&amp;gt; &lt;font face="Courier New"&gt;System.Collections.Generic.IList&amp;lt;T&amp;gt;&lt;/font&gt; &lt;/p&gt; &lt;p&gt;You can read the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/br211929.aspx" target="_blank"&gt;list of WinRT collection types&lt;/a&gt;, then drill into the detail to see the corresponding .NET map.&lt;/p&gt; &lt;p&gt;Here is a list of commonly mapped types:&lt;/p&gt; &lt;p&gt; &lt;table border="0" cellspacing="0" cellpadding="2" width="645"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;strong&gt;Windows Runtime&lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;strong&gt;.NET Framework&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IIterable&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IIterator&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IEnumerator&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IVector&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IList&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IVectorView&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IReadOnlyList&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IMap&amp;lt;K, V&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IDictionary&amp;lt;TKey, TValue&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IMapView&amp;lt;K, V&amp;gt;&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IReadOnlyDictionary&amp;lt;TKey, TValue&amp;gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IBindableIterable&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IEnumerable&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;IBindableVector&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;IList&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;Windows.UI.Xaml.Data.INotifyPropertyChanged&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;System.ComponentModel.INotifyPropertyChanged&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;Windows.UI.Xaml.Data.PropertyChangedEventHandler&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;System.ComponentModel.PropertyChangedEventHandler&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="308"&gt;&lt;font size="1" face="Courier New"&gt;Windows.UI.Xaml.Data.PropertyChangedEventArgs&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" width="335"&gt;&lt;font size="1" face="Courier New"&gt;System.ComponentModel.PropertyChangedEventArgs&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;There are other mapped types that you may not be as familiar with, such as the map from a &lt;font face="Courier New"&gt;Windows.Foundation.Uri&lt;/font&gt; to a &lt;font face="Courier New"&gt;System.Uri&lt;/font&gt;.While this is done “automatically” it does have side effects. The WinRT Uri does not support anything but absolute Uris, so any attempt to pass a relative Uri into a WinRT component will fail.  &lt;p&gt;Any other types are projected automatically without conversion. A good example of this is the built-in XAML controls for building Metro applications. &lt;font face="Courier New"&gt;Windows.UI.Xaml.Controls.Button&lt;/font&gt; appears as a CLR class to your .NET code, but it also appears as a C++ class to developers using the C++ option. There is no map or conversion, the type remains the same but the projection provides all of the plumbing necessary for it to act and feel like a type native to the environment you are working in. Any necessary wrappers are created behind the scenes – you’ll learn more about that later. &lt;/p&gt; &lt;p&gt;Because special types can have side effects, it’s important to know what they are and what restrictions exist. Here is a short list: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Courier New"&gt;Array – &lt;/font&gt;&lt;font face="Arial"&gt;If you still use this construct for collections it’s important to note that WinRT does not support the class being passed by reference as in the CLR. Arrays can either be provided as input parameters to a WinRT component, where they can be referenced but not modified, or as output parameters, where what you pass in is really just regarded as a buffer and not inspected but populated by the component. &lt;/font&gt; &lt;li&gt;&lt;font face="Courier New"&gt;DateTimeOffset – &lt;/font&gt;&lt;font face="Arial"&gt;in the Windows Runtime, this becomes a &lt;font face="Courier New"&gt;Windows.Foundation.DateTime&lt;/font&gt; value which does not contain time zone information. The CLR will convert your time to UTC before passing it to the WinRT component, and will convert any result from UTC to local time. To resolve this, you should be prepared to convert the value to local time before passing it to a WinRT component and back from local time to the target time zone when you receive values back.&lt;/font&gt;  &lt;li&gt;&lt;font face="Courier New"&gt;String&lt;/font&gt; – this becomes a &lt;font face="Courier New"&gt;HSTRING&lt;/font&gt; which does not support null values. You should not pass a null string into a WinRT component, nor should you ever see a null value returned back. Instead, use &lt;font face="Courier New"&gt;String.Empty.&lt;/font&gt;  &lt;li&gt;&lt;font face="Courier New"&gt;Uri&lt;/font&gt; – this is converted to &lt;font face="Courier New"&gt;Windows.Foundation.Uri&lt;/font&gt; which only accepts absolute Uris. Attempting to pass a relative Uri will result in an exception.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;In addition, it’s important to note some WinRT types and how they impact the CLR. Understanding these types is more important if you plan to write WinRT components in C++ for consumption by the .NET Framework – otherwise most of this happens behind the scenes for you.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Courier New"&gt;ELEMENT_TYPE_OBJECT&lt;/font&gt; – on the surface, this is mapped as System.Object in the .NET Framework. It is used to pass back other types from APIs. What’s important to note is how it is mapped on the .NET side. This type represents a pointer to the COM &lt;font face="Courier New"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/br205821(v=vs.85).aspx" target="_blank"&gt;IInspectable&lt;/a&gt;&lt;/font&gt; interface. It is responsible for projecting WinRT components into all supported languages and all WinRT interface types must derive from it. One important method that it declares is &lt;font face="Courier New"&gt;GetRuntimeClassName&lt;/font&gt;. If this passes back a value, the CLR will create a strongly-typed &lt;a href="http://msdn.microsoft.com/en-us/library/8bwh56xe.aspx" target="_blank"&gt;Runtime Callable Wrapper (RCW)&lt;/a&gt; for the projection. Otherwise, it will create a weakly-typed wrapper that simply resolves to &lt;font face="Courier New"&gt;System.__ComObject&lt;/font&gt; regardless of the actual backing type.  &lt;li&gt;&lt;font face="Courier New"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/br224583(v=vs.85).aspx" target="_blank"&gt;IReference&amp;lt;T&amp;gt;&lt;/a&gt;&lt;/font&gt; – this is an interesting type because it handles two features in the Windows Runtime. First, it is a way of providing a nullable type. While it maps loosely to &lt;font face="Courier New"&gt;Nullable&amp;lt;T&amp;gt; &lt;/font&gt;&lt;font face="Arial"&gt;the mechanism is slightly different. The pointer itself will be null if the value passed is null, otherwise it will point to an implementation that returns the actual value when the &lt;font face="Courier New"&gt;get_Value&lt;/font&gt; method is called. Conversely, a null pointer results in a &lt;font face="Courier New"&gt;Nullable&amp;lt;T&amp;gt;&lt;/font&gt; instance created with &lt;font face="Courier New"&gt;HasValue&lt;/font&gt; set to false. The type also facilitates boxing. Instead of returning a direct value, a WinRT component can return an &lt;font face="Courier New"&gt;ELEMENT_TYPE_OBJECT&lt;/font&gt; (&lt;font face="Courier New"&gt;System.Object&lt;/font&gt; to the CLR) and implement &lt;font face="Courier New"&gt;IInspectable&lt;/font&gt; to return &lt;font face="Courier New"&gt;IReference&amp;lt;Int32&amp;gt;&lt;/font&gt; as the type. When that happens, the CLR will call the method to obtain the value, then box it on the managed heap and pass the reference back into the managed stack.&lt;/font&gt;&lt;br&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Events&lt;/h2&gt; &lt;p&gt;In the CLR, managed events can have multiple delegates assigned and removed. Removing an event is as simply as using the operator to remove it and passing the delegate that handles the event callbacks. In WinRT, the event system is token-based. When you add a delegate to handle an event, you receive a unique token. To remove your delegate from the event, you call a method to remove and pass in the token, not the delegate. &lt;/p&gt; &lt;p&gt;Events are mapped between the CLR and WinRT by the compiler. If you decompile your code you will see this in action. The CLR uses the helper classes:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;System.Runtime.WindowsRuntime.WindowsRuntimeMarshal.AddEventHandler &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;System.Runtime.WindowsRuntime.WindowsRuntimeMarshal.RemoveEventHandler &lt;/font&gt;&lt;/p&gt; &lt;p&gt;The compiler will emit code that maps the events through these classes. The classes will maintain the dictionary of tokens and delegates, so you can code your familiar remove operation and have it automatically pass the correct token behind the scenes. &lt;/p&gt; &lt;h2&gt;Summary&lt;/h2&gt; &lt;p&gt;For the most part, you don’t have to worry about any of the magic happening behind the scenes because it is done for you. However, the purpose of this was to show how much thought and engineering went into actually working with both .NET and WinRT to ensure the two could work closely together. This to me is evidence that .NET is not a second-rate citizen in Windows 8, but an important factor that was carefully considered as part of the overall strategy to create a flexible new platform with reach. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6552656297537497305?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=4dptsAU454Q:ZeUTYmmUN-M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=4dptsAU454Q:ZeUTYmmUN-M:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=4dptsAU454Q:ZeUTYmmUN-M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=4dptsAU454Q:ZeUTYmmUN-M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=4dptsAU454Q:ZeUTYmmUN-M:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=4dptsAU454Q:ZeUTYmmUN-M:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=4dptsAU454Q:ZeUTYmmUN-M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=4dptsAU454Q:ZeUTYmmUN-M:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/4dptsAU454Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6552656297537497305/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/03/net-and-metro-windows-runtime-and-clr.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6552656297537497305?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6552656297537497305?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/4dptsAU454Q/net-and-metro-windows-runtime-and-clr.html" title=".NET and Metro: The Windows Runtime and the CLR on Windows 8" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/03/net-and-metro-windows-runtime-and-clr.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUIDQng8eip7ImA9WhVRFEs.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-905058687050167025</id><published>2012-03-22T21:48:00.000-04:00</published><updated>2012-03-22T21:52:53.672-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-22T21:52:53.672-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mvvm" /><category scheme="http://www.blogger.com/atom/ns#" term="wcf ria" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight printing" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight 5" /><category scheme="http://www.blogger.com/atom/ns#" term="out of browser" /><category scheme="http://www.blogger.com/atom/ns#" term="Jounce" /><category scheme="http://www.blogger.com/atom/ns#" term="navigation" /><title>Jounce MVVM WCF RIA Printing and More Example</title><content type="html">&lt;p&gt;I finally managed to update and upload my &lt;a href="http://jounce.codeplex.com/SourceControl/changeset/view/89576#1749776" target="_blank"&gt;To-Do List Reference Application&lt;/a&gt;. This is a Silverlight 5 application based on my &lt;a href="http://jounce.codeplex.com/" target="_blank"&gt;Jounce framework&lt;/a&gt; that demonstrates a number of different features. I built it as part of my book, &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321810414" target="_blank"&gt;Designing Silverlight Business Applications&lt;/a&gt;. There are several chapters devoted specifically to the construction of this example application. It is a demonstration application, so while it contains a lot of different components designed to illustrate various points, it's not intended to be a "production application." I won't even call it an "enterprise application" because it falls far short of what you might typically build for the enterprise, but this one has a lot more code than your typical two-page blog post program.
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-kVCP2V5CVIk/T2vWTxbGQzI/AAAAAAAAApM/3IxBAx7Ut4s/s1600/todolist.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="283" width="400" src="http://3.bp.blogspot.com/-kVCP2V5CVIk/T2vWTxbGQzI/AAAAAAAAApM/3IxBAx7Ut4s/s400/todolist.png" /&gt;&lt;/a&gt;&lt;/div&gt; 
&lt;p&gt;Specifically, it demonstrates the following concepts: 
&lt;ul&gt;&lt;li&gt;The Jounce framework (of course)&lt;li&gt;The MVVM pattern&lt;li&gt;Using a shared view model to display non-shared data (this is a common misconception, that if you edit five records you need five instances of the same view model)&lt;li&gt;Jounce-specific navigation and parameter-passing&lt;li&gt;Use of the Visual State Manager (VSM)&lt;li&gt;Design-time support&lt;li&gt;The Managed Extensibility Framework&lt;li&gt;Theme management (i.e. storing a theme in a separate project and referencing it)&lt;li&gt;WCF RIA Services&lt;li&gt;Mapping (auto-mapping properties from one entity to another)&lt;li&gt;Event aggregator messaging&lt;li&gt;Repository pattern&lt;li&gt;The &lt;a href="http://sterling.codeplex.com/" target="_blank"&gt;Sterling NoSQL database&lt;/a&gt; (the example uses both a server-side and client-side instance)&lt;li&gt;Synchronization between the client and server when the client is offline&lt;li&gt;p/Invoke&lt;li&gt;Concurrency management&lt;li&gt;Offline Out-of-Browser (OOB) including UI for installation and removal&lt;li&gt;Use of behaviors&lt;li&gt;Extensions for fluent interfaces&lt;li&gt;Region management&lt;li&gt;Validation&lt;li&gt;Printing&lt;li&gt;Localization (version "as is" has Spanish text substituted in the edit dialog)&lt;li&gt;COM Interop (exports items to Excel)&lt;li&gt;HTML DOM interaction (application works with JavaScript to warn the user if they edit a record and try to navigate in the browser) and updates the title whether in browser or OOB mode)&lt;li&gt;Tracking dirty records using the entity view model&lt;li&gt;Filtering and sorting&lt;li&gt;Touch interaction using the &lt;a href="http://lighttouch.codeplex.com/" target="_blank"&gt;LightTouch&lt;/a&gt; library&lt;li&gt;Out-of-Browser child windows&lt;li&gt;Toast notifications&lt;li&gt;Testing&lt;/ul&gt;
&lt;p&gt;I'm sure there are some items I left out. I hope this helps answer a lot of questions I receive and I also hope it is taken as guidance and an example, not a "final architecture" or production-ready module as again, the key intent is to provide examples of a lot of different features. There is only one thing I ask: that if you have questions about the application, you first &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321810414" target="_blank"&gt;invest in the book&lt;/a&gt; and ask me only if you don't find your answers there. Jounce is an open source community project and I'm sharing this example application as well, but the book is how I spent the better part of a year compiling all of the information I know about enterprise Silverlight development into one comprehensive resource. It's not a rehash of blog posts and contains a lot of content. However, if you've got the book, have worked through the examples and still have some questions or issues, please don't hesitate to contact me through the &lt;a href="http://jounce.codeplex.com/discussions/" target="_blank"&gt;Jounce discussion forums&lt;/a&gt; or by replying in the comments section below.
&lt;p&gt;Simply head over to the &lt;a href="http://jounce.codeplex.com/SourceControl/changeset/view/89576#1749776" target="_blank"&gt;Jounce website&lt;/a&gt; and click the download icon when browsing the latest source to grab the application. Thanks, and enjoy!
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-905058687050167025?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=OCofI7CmX2k:Z4NegYUjhG4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=OCofI7CmX2k:Z4NegYUjhG4:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=OCofI7CmX2k:Z4NegYUjhG4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=OCofI7CmX2k:Z4NegYUjhG4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=OCofI7CmX2k:Z4NegYUjhG4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=OCofI7CmX2k:Z4NegYUjhG4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=OCofI7CmX2k:Z4NegYUjhG4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=OCofI7CmX2k:Z4NegYUjhG4:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/OCofI7CmX2k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/905058687050167025/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/03/jounce-mvvm-wcf-ria-printing-and-more.html#comment-form" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/905058687050167025?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/905058687050167025?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/OCofI7CmX2k/jounce-mvvm-wcf-ria-printing-and-more.html" title="Jounce MVVM WCF RIA Printing and More Example" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-kVCP2V5CVIk/T2vWTxbGQzI/AAAAAAAAApM/3IxBAx7Ut4s/s72-c/todolist.png" height="72" width="72" /><thr:total>8</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/03/jounce-mvvm-wcf-ria-printing-and-more.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0cARno7eCp7ImA9WhVSF04.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-5447648648947665985</id><published>2012-03-14T07:15:00.001-04:00</published><updated>2012-03-14T09:17:27.400-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-14T09:17:27.400-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term=".net framework 4.5" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="portable library" /><title>Understanding the Portable Library by Chasing ICommand (3 of 3)</title><content type="html">&lt;p&gt;&lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by.html" target="_blank"&gt;Part 1: Creating the Portable Library&lt;/a&gt;&lt;br&gt;&lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_09.html"&gt;Part 2: Portability in Silverlight and WPF: a Tale of Type Forwarders&lt;/a&gt;&lt;br&gt;Part 3: Portability in Metro: A CLR and WinRT Love Affair (this post)&lt;/p&gt; &lt;h3&gt;Portability in Metro: A CLR and WinRT Love Affair&lt;/h3&gt; &lt;p&gt;In this series we’ve covered the portable library and reviewed how it allows you to create assemblies that can be shared without recompilation across multiple platforms. You created a portable assembly with a view model and a command in it, then successfully integrated it in a WPF and a Silverlight project. Now it’s time to code for the future and go Metro.&lt;/p&gt; &lt;p&gt;Create a new C# Metro application using the blank page template. Reference the &lt;strong&gt;PortableCommandLibrary&lt;/strong&gt; project. Open the &lt;strong&gt;BlankPage.xaml&lt;/strong&gt; file and drop in the same XAML you used for WPF and Silverlight. First, fix up a reference:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;xmlns:portable="using:PortableCommandLibrary"&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Next, add the XAML inside of the main grid:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;portable:ViewModel&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Text}"&lt;/span&gt; &lt;span class="attr"&gt;Command&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ClickCommand}"&lt;/span&gt;
        &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt;
        &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt;
        &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now compile, deploy, and run the application. It will work just as it did for WPF and Silverlight.&lt;/p&gt;
&lt;p&gt;First the button:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-p-FxNzmwMBw/T2B9rNqVc5I/AAAAAAAAAnk/xJqAGVwouNE/s1600-h/portablelibmetro12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibmetro1" border="0" alt="portablelibmetro1" src="http://lh5.ggpht.com/-TGG0Vn-IlAw/T2B9rbGL0mI/AAAAAAAAAns/9vKE9xYGX0Y/portablelibmetro1_thumb.png?imgmax=800" width="244" height="186"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then the disabled button:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-jc1qFWwhJdE/T2B9rlAc95I/AAAAAAAAAn0/yE-uSqyqIkU/s1600-h/portablelibmetro22.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibmetro2" border="0" alt="portablelibmetro2" src="http://lh5.ggpht.com/-ViaPuyZQEhs/T2B9r7uhakI/AAAAAAAAAn8/WhSVO4SytgU/portablelibmetro2_thumb.png?imgmax=800" width="244" height="186"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What’s interesting for this example is that you know when you want to wire a command, you have to use a completely separate namespace from Silverlight. In fact, the namespace implies that you are accessing a WinRT component that is part of the operating system and not even a managed object. How do we pull that off with an assembly that isn’t modified? &lt;/p&gt;
&lt;p&gt;To begin the journey, start with the assembly that is referenced directly by the portable library. This is &lt;font face="Courier New"&gt;System.Windows.dll&lt;/font&gt; only this time you’ll inspect it in the &lt;strong&gt;.NETCore&lt;/strong&gt; folder, which is the smaller profile allowed for Metro applications. Once again, the assembly contains no implementation. Opening the manifest, you will find a series of type forwarders. This time the &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; interface is redirected to &lt;font face="Courier New"&gt;System.ObjectModel.dll&lt;/font&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh5.ggpht.com/-qwW9wBanWlk/T2B9sIfsedI/AAAAAAAAAoE/YIbvPdc4NKM/s1600-h/portablelibmetro33.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibmetro3" border="0" alt="portablelibmetro3" src="http://lh4.ggpht.com/-_OZOy7v70a4/T2B9spw516I/AAAAAAAAAoM/EBdEuRVYNr0/portablelibmetro3_thumb1.png?imgmax=800" width="608" height="394"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What’s next? You guessed it. Pop open the &lt;font face="Courier New"&gt;System.ObjectModel.dll&lt;/font&gt; assembly and you’ll find:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-vIZEODIBHvk/T2B9s2JDZWI/AAAAAAAAAoU/iIfkVJJieYk/s1600-h/portablelibmetro43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibmetro4" border="0" alt="portablelibmetro4" src="http://lh3.ggpht.com/-2i3DGwel-VE/T2B9tccRylI/AAAAAAAAAoc/TcmwgGo4l1Q/portablelibmetro4_thumb1.png?imgmax=800" width="560" height="354"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So there it is … but there’s a problem. When you specify your own command implementation, you have to reference the &lt;font face="Courier New"&gt;Windows.UI.Xaml.Input&lt;/font&gt; namespace. So how will this reference work? This is where Metro works a little bit of magic.&lt;/p&gt;
&lt;p&gt;It turns out the platform maintains an internal table that maps CLR namespaces to the WinRT equivalents. This allows seamless integration between the types. For example, the CLR may be exposed to the type &lt;font face="Courier New"&gt;Windows.Foundation.Uri&lt;/font&gt; when dealing with a WinRT component. When this happens, it automatically maps this to the .NET &lt;font face="Courier New"&gt;System.Uri&lt;/font&gt;. When the CLR passes &lt;font face="Courier New"&gt;System.Uri&lt;/font&gt; to a WinRT component, it is converted to a &lt;font face="Courier New"&gt;Windows.Foundation.Uri&lt;/font&gt; reference. &lt;/p&gt;
&lt;p&gt;In our case, the code references: &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;System.Windows.Input.ICommand&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The platform will automatically map this to the WinRT counterpart, &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;Windows.UI.Xaml.Input.ICommand&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;This is a very powerful feature because it enables compatibility between legacy code and the new runtime with minimal effort on the part of the developer. If your type maps to an actual object that can have an activated instance, rather than just an interface, the CLR will automatically instantiate a Runtime Callable Wrapper (RCW) to proxy calls to the underlying WinRT (essentially COM) component.&lt;/p&gt;
&lt;p&gt;The whole portable path looks like this in the end:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/--oFkQbdUvIE/T2B9t9O_F9I/AAAAAAAAAok/ZlEgJ3JxjSg/s1600-h/portablelibmetro5%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelibmetro5" border="0" alt="portablelibmetro5" src="http://lh4.ggpht.com/-CIdJ9Af-9kw/T2B9uJTrQLI/AAAAAAAAAos/A0MkI3ZZWgE/portablelibmetro5_thumb%25255B1%25255D.png?imgmax=800" width="595" height="425"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to see the “projected” types you can use &lt;strong&gt;ildasm.exe&lt;/strong&gt; with the &lt;strong&gt;/project&lt;/strong&gt; switch and in theory, if you run this against one of the &lt;strong&gt;.WinMD&lt;/strong&gt; files (such as &lt;strong&gt;Windows.UI.Xaml.Input.WinMD&lt;/strong&gt;) located in &lt;strong&gt;%windir%\winmetdata&lt;/strong&gt; you should see .NET projected types instead of Windows Runtime types … I have yet to get this to work but if you have, please post the details here.&lt;/p&gt;
&lt;p&gt;And that’s it – you’ve learned how to create an assembly that is completely portable between .NET Framework 4.5 (WPF), Silverlight 4.0 and 5.0, and Windows 8 Metro, and learned a bit about how it works by chasing down &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; under the covers. Hopefully this helps with understanding the library and also with planning out how to map future projects that need to share code between existing implementations and future Metro targets.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-5447648648947665985?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aqzDmfqZujs:R6dka7Bd4Lk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aqzDmfqZujs:R6dka7Bd4Lk:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aqzDmfqZujs:R6dka7Bd4Lk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=aqzDmfqZujs:R6dka7Bd4Lk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aqzDmfqZujs:R6dka7Bd4Lk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=aqzDmfqZujs:R6dka7Bd4Lk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aqzDmfqZujs:R6dka7Bd4Lk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=aqzDmfqZujs:R6dka7Bd4Lk:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/aqzDmfqZujs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/5447648648947665985/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_14.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/5447648648947665985?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/5447648648947665985?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/aqzDmfqZujs/understanding-portable-library-by_14.html" title="Understanding the Portable Library by Chasing ICommand (3 of 3)" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-TGG0Vn-IlAw/T2B9rbGL0mI/AAAAAAAAAns/9vKE9xYGX0Y/s72-c/portablelibmetro1_thumb.png?imgmax=800" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_14.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUABRnkyfSp7ImA9WhVSF08.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-5315129241143812429</id><published>2012-03-09T17:18:00.001-05:00</published><updated>2012-03-14T07:15:57.795-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-14T07:15:57.795-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="wpf" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="portable library" /><category scheme="http://www.blogger.com/atom/ns#" term="winrt" /><title>Understanding the Portable Library by Chasing ICommand (2 of 3)</title><content type="html">&lt;p&gt;&lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by.html" target="_blank"&gt;Part 1: Creating the Portable Library&lt;/a&gt;&lt;br&gt;Part 2: Portability in Silverlight and WPF: a Tale of Type Forwarders (this post)&lt;br&gt;&lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_14.html" target="_blank"&gt;Part 3: Portability in Metro: A CLR and WinRT Love Affair&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;Portability in Silverlight and WPF: a Tale of Type Forwarders&lt;/h3&gt; &lt;p&gt;In the last post, I walked through creating a portable assembly that will target Silverlight 4.0 and above, .NET Framework 4.5, and Windows 8 Metro. In the assembly were a few classes that handled commands and property change notification for a simple view model. In this post I’ll show you how to reference the assembly in Silverlight and WPF and explain why it works.&lt;/p&gt; &lt;p&gt;The first step is to create a new Silverlight 5.0 project (just using that because it’s the latest version, I know the library will technically support 4.0). Just make a simple application (no need to have a web project as well). The project will be created with the default &lt;font face="Courier New"&gt;App.xaml&lt;/font&gt; and &lt;font face="Courier New"&gt;MainPage.xaml&lt;/font&gt;. In the solution explorer, right-click on the &lt;strong&gt;References&lt;/strong&gt; node and add a reference to the &lt;strong&gt;PortableCommandLibrary&lt;/strong&gt; project. Now open up the XAML for the main page. At the top, add a namespace declaration for the view model: &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;xmlns:portable="clr-namespace:PortableCommandLibrary;assembly=PortableCommandLibrary"&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Next, paste the following XAML inside the main grid called &lt;strong&gt;LayoutRoot&lt;/strong&gt; (you’ll use the exact same snippet for all of the projects in this series).&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;portable:ViewModel&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Text}"&lt;/span&gt; &lt;span class="attr"&gt;Command&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ClickCommand}"&lt;/span&gt;
        &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt;
        &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt;
        &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now compile and run the application. You should see something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-0aW8Vq6gPU0/T1qBuU3C35I/AAAAAAAAAlk/bK1qmEhCIdA/s1600-h/portablelibsilverlight12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibsilverlight1" border="0" alt="portablelibsilverlight1" src="http://lh5.ggpht.com/-TzkxWUZr0Fc/T1qBvFrq92I/AAAAAAAAAls/UG-WSE-cnzM/portablelibsilverlight1_thumb.png?imgmax=800" width="244" height="118"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you follow the instructions, you should end up with this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-q8k_0SLPPYo/T1qBvcFPHEI/AAAAAAAAAl0/UmBinGre8zI/s1600-h/portablelibsilverlight22.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibsilverlight2" border="0" alt="portablelibsilverlight2" src="http://lh6.ggpht.com/-5SS2sP-a4vg/T1qBv4Q8KlI/AAAAAAAAAl8/VCsSJXPDlPs/portablelibsilverlight2_thumb.png?imgmax=800" width="244" height="118"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I’d love to show you how this worked with the portable library, but the answer is pretty boring. As I showed you in the &lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by.html" target="_blank"&gt;last post&lt;/a&gt;, the portable assembly points to an &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; interface that lives in the &lt;font face="Courier New"&gt;System.Windows.Input&lt;/font&gt; namespace in the &lt;font face="Courier New"&gt;System.Windows.dll&lt;/font&gt; assembly. If you peek inside Silverlight’s assemblies and run &lt;strong&gt;ildasm.exe&lt;/strong&gt; you’ll see:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-uKAZO9tT0Zw/T1qBwNEHJlI/AAAAAAAAAmE/x14g0T9ibOc/s1600-h/portablelibsilverlight33.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibsilverlight3" border="0" alt="portablelibsilverlight3" src="http://lh6.ggpht.com/-28T6x_Pee7Y/T1qBwgBFpiI/AAAAAAAAAmM/9FVxTVH5V1s/portablelibsilverlight3_thumb1.png?imgmax=800" width="645" height="330"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The reference can be visualized like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-Nxl_x7aW_yI/T1qBxDCsc5I/AAAAAAAAAmU/Gjgn-O8aQpw/s1600-h/portablelibsilverlight43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibsilverlight4" border="0" alt="portablelibsilverlight4" src="http://lh4.ggpht.com/-9TsfWHe_kGM/T1qBxj47jvI/AAAAAAAAAmc/UWXR8pCqMao/portablelibsilverlight4_thumb1.png?imgmax=800" width="306" height="149"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Really no magic at all – Silverlight is a lowest common denominator here. So let’s try something a little more interesting. Create a new WPF project and reference the same portable library. Add the same namespace declaration to the &lt;font face="Courier New"&gt;MainWindow.xaml&lt;/font&gt; file and drop in the XAML inside the &lt;font face="Courier New"&gt;Grid&lt;/font&gt; tag. Run the application – look familiar?&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-15fPzSwAK4w/T1qBx_Is6jI/AAAAAAAAAmk/BQDVd6pZiOE/s1600-h/portablelibwpf12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibwpf1" border="0" alt="portablelibwpf1" src="http://lh4.ggpht.com/-hgM9ze_BeDs/T1qByHGlDiI/AAAAAAAAAms/8B8KN6W4GUI/portablelibwpf1_thumb.png?imgmax=800" width="235" height="118"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Click it.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-ZxbWv9rlkQM/T1qByXuLmTI/AAAAAAAAAm0/GnzlOEVshx0/s1600-h/portablelibwpf22.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibwpf2" border="0" alt="portablelibwpf2" src="http://lh3.ggpht.com/-Cd-R35yPVt0/T1qByuLOydI/AAAAAAAAAm8/g8W2dWdDzy8/portablelibwpf2_thumb.png?imgmax=800" width="244" height="118"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;OK, so it works the same way, but we noted earlier that the &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; interface lives someplace different. How does this work? If you recall, the reference to &lt;font face="Courier New"&gt;System.Windows.dll&lt;/font&gt; in the portable library was tagged as &lt;em&gt;retargetable&lt;/em&gt;. This tells the runtime that the target may really exist somewhere else. In fact, if you look at the references available for the .NET Framework 4.5 (here’s a tip: forget that old &lt;font face="Courier New"&gt;%windir%\Microsoft.NET\Framework\&lt;/font&gt; stuff … instead, try the newer &lt;font face="Courier New"&gt;%programdir%\Reference Assemblies\Microsoft\Framework\.NETFramework\ &lt;/font&gt;folder), you’ll find there &lt;em&gt;is&lt;/em&gt; a &lt;font face="Courier New"&gt;System.Windows.dll&lt;/font&gt; file. Pop it open with &lt;strong&gt;ildasm.exe&lt;/strong&gt; and you’ll see there is no implementation in the file, only metadata. Read the manifest and you’ll come across this little gem: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-zQnxsWXQLQw/T1qBzKf5hLI/AAAAAAAAAnE/VCHNUUJUYFc/s1600-h/portablelibwpf34.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibwpf3" border="0" alt="portablelibwpf3" src="http://lh6.ggpht.com/-v_IR48u_3l8/T1qBzZwOpvI/AAAAAAAAAnM/49IFbfypg0A/portablelibwpf3_thumb2.png?imgmax=800" width="602" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Ah-hah! The portable library people have been planning this for longer than most readers suspect. There’s a nice reference now that politely invites the CLR to look somewhere &lt;em&gt;else&lt;/em&gt; for the implementation, specifically in &lt;font face="Courier New"&gt;System.dll&lt;/font&gt;. If you open that assembly, you’ll see the interface is indeed defined there. So, what really happened looks a little like this for the .NET Framework 4.5: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-EBuUBBnkCRg/T1qBzovm_tI/AAAAAAAAAnU/kWaxUpyh650/s1600-h/portablelibwpf43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelibwpf4" border="0" alt="portablelibwpf4" src="http://lh6.ggpht.com/-mi5uXmlopBA/T1qB0BgDFVI/AAAAAAAAAnc/rKjH6Z_5ljU/portablelibwpf4_thumb1.png?imgmax=800" width="521" height="172"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you’re turning pale at the thought of so many hops, don’t get worried. These tables are loaded into memory and represent very miniscule lookups. The portable team assured me that any performance cost due to a little indirection is negligible. &lt;/p&gt;
&lt;p&gt;What I love about the approach is that it uses a lot of pieces that have been already in place but in a clever way that gives us this powerful functionality of using the same assembly in Silverlight (web) or WPF (desktop). In the next post, we’ll take it even further and see how it relates to the brand new platform of the Windows Runtime (WinRT) for a Windows 8 Metro application. How on earth do we go from this to an unmanaged code base?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-5315129241143812429?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=DhisVjGFBlE:aWQkLQZLOTo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=DhisVjGFBlE:aWQkLQZLOTo:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=DhisVjGFBlE:aWQkLQZLOTo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=DhisVjGFBlE:aWQkLQZLOTo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=DhisVjGFBlE:aWQkLQZLOTo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=DhisVjGFBlE:aWQkLQZLOTo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=DhisVjGFBlE:aWQkLQZLOTo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=DhisVjGFBlE:aWQkLQZLOTo:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/DhisVjGFBlE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/5315129241143812429/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_09.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/5315129241143812429?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/5315129241143812429?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/DhisVjGFBlE/understanding-portable-library-by_09.html" title="Understanding the Portable Library by Chasing ICommand (2 of 3)" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-TzkxWUZr0Fc/T1qBvFrq92I/AAAAAAAAAls/UG-WSE-cnzM/s72-c/portablelibsilverlight1_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_09.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAMQX07cSp7ImA9WhVSF08.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6736429318590813618</id><published>2012-03-08T20:45:00.001-05:00</published><updated>2012-03-14T07:16:20.309-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-14T07:16:20.309-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="wpf" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="portable library" /><category scheme="http://www.blogger.com/atom/ns#" term="winrt" /><title>Understanding the Portable Library by Chasing ICommand (1 of 3)</title><content type="html">&lt;p&gt;Part 1: Creating the Portable Library (this post)&lt;br&gt;&lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_09.html"&gt;Part 2: Portability in Silverlight and WPF: a Tale of Type Forwarders&lt;/a&gt;&lt;br&gt;&lt;a href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by_14.html" target="_blank"&gt;Part 3: Portability in Metro: A CLR and WinRT Love Affair&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The &lt;a href="http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981" target="_blank"&gt;portable library tools&lt;/a&gt; have been available for several months now. The goal for this add-in to Visual Studio 2010 was to enable you to create special portable assemblies that can run on various platforms, ranging from XBox and Windows Phone 7 to various versions of the .NET Framework and Windows 8, without having to recompile them. That’s a pretty amazing feat and allows developers to avoid some crazy practices like linking source code.&lt;/p&gt; &lt;p&gt;With Visual Studio 11, the tools are no longer an add-in but are a built-in part of the product. You can directly create portable class libraries and build these magic assemblies that can be reused without recompiling. For many users, this is incredibly important because it means they can not only reuse their libraries between platforms like the phone and the desktop, but also can build insurance for the future. Think about it: you can build a Silverlight application today, share your libraries with a Metro application you are developing for tomorrow, and only have to branch the parts of the code that are necessary. &lt;/p&gt; &lt;p&gt;You may be surprised to learn just how much functionality can be shared. Property change notification, commands, even the network stacks can be shared across targets. The purpose of this post is to summarize some of the capabilities, show you how to build a project that shares portable libraries, and then get into the dirty details of how the magic really works. How can we possibly have an assembly that Silverlight recognizes today work without modification or recompilation in our Windows 8 Metro application of the future? Keep on reading if you want to uncover the answer.&lt;/p&gt; &lt;p&gt;For this example I’ll walk you through creating a view model that executes a command and changes some text. The view model will be reused without modification in a Silverlight, WPF, and Windows 8 Metro project, along with property change notification and the implementation of &lt;font face="Courier New"&gt;ICommand&lt;/font&gt;. What makes this interesting is the fact that &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; lives in very different places on these platforms.&lt;/p&gt; &lt;p&gt;In Silverlight and WPF, &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; lives in the &lt;font face="Courier New"&gt;System.Windows.Input&lt;/font&gt; namespace. While the namespace is the same, the assemblies are not. The definition exists in &lt;font face="Courier New"&gt;System.Windows.dll&lt;/font&gt; for Silverlight but in WPF and the .NET Framework 4.5 it is defined in &lt;font face="Courier New"&gt;System.dll&lt;/font&gt;. On Windows 8 Metro, the namespace for &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; is &lt;font face="Courier New"&gt;Windows.Xaml.UI.Input&lt;/font&gt;. There, it doesn’t even live in an assembly but is defined through metadata and projected by the underlying OS. How does the portable library reconcile these differences?&lt;/p&gt; &lt;p&gt;If you want to follow along and have Visual Studio 11 Beta Ultimate (this won’t work with Express) simply create a new solution called &lt;strong&gt;PortableCommandLibrary&lt;/strong&gt; and with a project of type &lt;strong&gt;Visual C# –&amp;gt; Windows –&amp;gt; Portable Class Library&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-Nioo7i0XRT0/T1lglg7dVJI/AAAAAAAAAjo/X5WBOEZ5n2s/s1600-h/portablelib14.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="portablelib1" border="0" alt="portablelib1" src="http://lh6.ggpht.com/-ddtinW2q4KE/T1lgmFYQCzI/AAAAAAAAAjw/KzpD0I0G0iQ/portablelib1_thumb2.png?imgmax=800" width="650" height="470"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Now you can modify the target frameworks. As you may imagine, the platforms you wish to target will limit your options. For example, if you want to target the phone, you won’t be able to use the Managed Extensibility Framework (MEF). If you want to target the XBox, you won’t have the networking stack available. The combination of targets will limit the portable APIs available for you to use in your portable library. The beauty is that you don’t have to figure out what’s compatible as the team has figured this out for you and will automatically restrict your options based on what you select.&lt;/p&gt; &lt;p&gt;Right-click the project node and go into &lt;strong&gt;Properties (ALT+ENTER)&lt;/strong&gt;. Click on the &lt;strong&gt;Change&lt;/strong&gt; button.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-_hA0SBbPhGI/T1lgmu86cwI/AAAAAAAAAj4/ROcgJS0cyZw/s1600-h/portablelib2%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelib2" border="0" alt="portablelib2" src="http://lh5.ggpht.com/-FQH40VtIGBA/T1lgmw6op1I/AAAAAAAAAkA/gzWxZRLc0Fw/portablelib2_thumb%25255B1%25255D.png?imgmax=800" width="647" height="232"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;This will give you the option to select the profile you wish to use. For this example, we’ll build a library that targets .NET Framework 4.5 for WPF, Silverlight 4.0 and higher, and Metro.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-rer8V2mHmVE/T1lgnfvXlcI/AAAAAAAAAkI/FvaOnQjO1rI/s1600-h/portablelib3%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelib3" border="0" alt="portablelib3" src="http://lh6.ggpht.com/-sHV4a_l-yxM/T1lgniKagFI/AAAAAAAAAkQ/pEFZkhJ_efE/portablelib3_thumb%25255B1%25255D.png?imgmax=800" width="474" height="458"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Great! Now take a look at the &lt;strong&gt;Solution Explorer &lt;/strong&gt;under &lt;strong&gt;References. &lt;/strong&gt;What is that? “Portable Subset”? &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-GnpBUfbbUCk/T1lgoCy6KJI/AAAAAAAAAkY/W0-o_mMSXU4/s1600-h/portablelib4%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelib4" border="0" alt="portablelib4" src="http://lh3.ggpht.com/-j1GKo805HzM/T1lgojcrtWI/AAAAAAAAAkg/IRQAtTyr-sc/portablelib4_thumb%25255B2%25255D.png?imgmax=800" width="282" height="97"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Look at the properties for the reference and you’ll see a path. Navigate to the path. Wow, now &lt;em&gt;this&lt;/em&gt; is interesting! There are the DLLs you can safely use between the targets. You can see a redistribution list and a set of supported frameworks as well.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-r8c9kq0eAdQ/T1lgo0fFqsI/AAAAAAAAAko/4XFjZrn61_g/s1600-h/portablelib5%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelib5" border="0" alt="portablelib5" src="http://lh6.ggpht.com/-enAt4Tzg8K0/T1lgplh-X6I/AAAAAAAAAkw/dfVnrKqB3Og/portablelib5_thumb%25255B1%25255D.png?imgmax=800" width="555" height="569"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The magic here is worked by a new Visual Studio 11 feature called Extension SDKs. This feature allows you to use a “reference” that is actually a package of files. It solves the problem of &lt;a href="http://timheuer.com/blog/archive/2012/03/07/creating-custom-controls-for-metro-style-apps.aspx" target="_blank"&gt;deploying custom controls with assets&lt;/a&gt; and also helps us write portable code. The portable team was kind enough to figure out all of the available permutations of framework combinations and package them as specific extensions to make a seamless reference experience in Visual Studio 11. You can read Microsoft’s documentation on how to create your own SDKs &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh768146(v=vs.110).aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;OK so now we’ve learned a little bit about the magic that makes this work. The SDK reference constrains what we can do to code that is portable between the target runtimes. So what next? How about create a command that can perform a single action and then disables itself? You’ll need to add a using statement for &lt;font face="Courier New"&gt;System.Windows.Input&lt;/font&gt;: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ClickOnceCommand : ICommand 
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ClickOnceCommand(Action action)
    {
        _action = action;
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; Action _action; 
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; _canClick = &lt;span class="kwrd"&gt;true&lt;/span&gt;;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; CanExecute(&lt;span class="kwrd"&gt;object&lt;/span&gt; parameter)
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; _canClick;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler CanExecuteChanged;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Execute(&lt;span class="kwrd"&gt;object&lt;/span&gt; parameter)
    {
        _canClick = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
        _action();
        var handler = CanExecuteChanged;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (handler != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            handler(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);
        }
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Great! Next, let’s create a view model that exposes a text property. The property invites the user to click. The view model will expose a command and feed it the action to change the text (to admonish the user &lt;em&gt;not &lt;/em&gt;to click). The view model looks like this: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ViewModel : INotifyPropertyChanged 
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ViewModel()
    {
        ClickCommand = &lt;span class="kwrd"&gt;new&lt;/span&gt; ClickOnceCommand(() =&amp;gt; Text = &lt;span class="str"&gt;"Don't Click Me"&lt;/span&gt;);
        _text = &lt;span class="str"&gt;"Click Me"&lt;/span&gt;;
    }

    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _text;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Text
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _text; }
        set
        {
            _text = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
            RaisePropertyChanged(&lt;span class="str"&gt;"Text"&lt;/span&gt;);
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; ICommand ClickCommand { get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set; }

    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RaisePropertyChanged(&lt;span class="kwrd"&gt;string&lt;/span&gt; propertyName)
    {
        var handler = PropertyChanged;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (handler != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            handler(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyChangedEventArgs(propertyName));
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Here’s the interesting part: we’ve now created a functional view model and command that will work on multiple platforms from a single assembly without recompilation. If you’re concerned about your path from now to Windows 8, consider Silverlight 5 or WPF as an interim because the following XAML will work without a single modification across all of these targets (Silverlight, WPF, and Windows 8 Metro): &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;portable:ViewModel&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Text}"&lt;/span&gt; &lt;span class="attr"&gt;Command&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ClickCommand}"&lt;/span&gt;
            &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt;
            &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt;
            &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Obviously it won’t always be that simple but there is a lot of opportunity for sharing code here. Don’t worry about using the XAML just yet – I’ll walk through that in the next post. You don’t have to be an expert to figure out what the goal is: we want to show a button that invites the user to click. When clicked, it will disable itself and tell the user not to click it. Simple, no? &lt;/p&gt;
&lt;p&gt;You can build the portable library and inspect it with &lt;strong&gt;ildasm.exe&lt;/strong&gt;. What I want you to notice is that the &lt;font face="Courier New"&gt;ICommand&lt;/font&gt; reference points to the &lt;font face="Courier New"&gt;System.Windows.dll&lt;/font&gt; assembly:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-5mk3zTsnhL0/T1lgp_Zd-vI/AAAAAAAAAk4/gtoHEXyxntQ/s1600-h/portablelib6%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelib6" border="0" alt="portablelib6" src="http://lh6.ggpht.com/--V6KoXBcrjE/T1lgqfZPUCI/AAAAAAAAAlA/3ny1stGVaVQ/portablelib6_thumb%25255B1%25255D.png?imgmax=800" width="508" height="199"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For Silverlight, this is fine … that’s exactly where it lives. In the .NET Framework 4.5, however, it lives in &lt;font face="Courier New"&gt;System.dll&lt;/font&gt;. Windows 8 Metro defines it in a different namespace: &lt;font face="Courier New"&gt;Windows.UI.Xaml.Input&lt;/font&gt;. So how can this single assembly work in those environments without being rebuilt? &lt;/p&gt;
&lt;p&gt;I’ll explore the answer for WPF and the .NET Framework 4.5 in the next post. For now, take a look at the manifest that was generated for our portable assembly. Note the special tag on the external references. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-__tFUjy7XGk/T1lgquZ89-I/AAAAAAAAAlI/V86AyY2AZZI/s1600-h/portablelib7%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="portablelib7" border="0" alt="portablelib7" src="http://lh4.ggpht.com/-YwT_3Nh_VYM/T1lgrFVi03I/AAAAAAAAAlQ/GBmrVpbEqxY/portablelib7_thumb%25255B1%25255D.png?imgmax=800" width="450" height="333"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;More to come!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6736429318590813618?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=vY6qTN41mjg:jw8uZHHyLu8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=vY6qTN41mjg:jw8uZHHyLu8:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=vY6qTN41mjg:jw8uZHHyLu8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=vY6qTN41mjg:jw8uZHHyLu8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=vY6qTN41mjg:jw8uZHHyLu8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=vY6qTN41mjg:jw8uZHHyLu8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=vY6qTN41mjg:jw8uZHHyLu8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=vY6qTN41mjg:jw8uZHHyLu8:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/vY6qTN41mjg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6736429318590813618/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6736429318590813618?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6736429318590813618?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/vY6qTN41mjg/understanding-portable-library-by.html" title="Understanding the Portable Library by Chasing ICommand (1 of 3)" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-ddtinW2q4KE/T1lgmFYQCzI/AAAAAAAAAjw/KzpD0I0G0iQ/s72-c/portablelib1_thumb2.png?imgmax=800" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/03/understanding-portable-library-by.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUENSH47cSp7ImA9WhVSEEk.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-7532222332682040440</id><published>2012-03-06T10:28:00.001-05:00</published><updated>2012-03-06T10:28:19.009-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-06T10:28:19.009-05:00</app:edited><title>Windows 8 Icons: Segoe UI Symbol</title><content type="html">&lt;p&gt;Here’s a quick and easy tip for developing Windows 8 Metro applications. Are you looking for decent icons to use in your &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.appbar.aspx" target="_blank"&gt;Application Bar&lt;/a&gt;? Windows 8 makes it incredibly easy by using the built-in &lt;a href="http://www.microsoft.com/typography/fonts/font.aspx?FMID=1798" target="_blank"&gt;Segoe UI Symbol&lt;/a&gt; font. There are tons of icons embedded in the font that are perfect for using in your applications.&lt;/p&gt; &lt;p&gt;Take a look at the following XAML snippet from the Microsoft &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465303.aspx" target="_blank"&gt;quick start for adding an app bar&lt;/a&gt;:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Vertical"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,14,0,5"&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource AppBarButtonStyle}"&lt;/span&gt;
       &lt;span class="attr"&gt;FontFamily&lt;/span&gt;&lt;span class="kwrd"&gt;="Segoe UI Symbol"&lt;/span&gt; &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="18.667"&lt;/span&gt; 
       &lt;span class="attr"&gt;Padding&lt;/span&gt;&lt;span class="kwrd"&gt;="8,8,0,0"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,0,10"&lt;/span&gt;
       &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="&amp;amp;#xE112;"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Back"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;It defines the section of the application bar you see below: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-sDIgmvIwZs8/T1YtCgKPnRI/AAAAAAAAAjI/YukIhWVuUYw/s1600-h/back%25255B2%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="back" border="0" alt="back" src="http://lh5.ggpht.com/-Z9J4wbKJ9-U/T1YtDSb9--I/AAAAAAAAAjQ/1LJ-pm5nbzc/back_thumb.png?imgmax=800" width="196" height="100"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The key is in the content tag that specifies the arcane text &amp;amp;#xE112; – this is simply a notation that references the location of the symbol in the font (you can see the “font family” is set to the appropriate font). So how do you go about finding these icons? Fairly simple: on the Windows 8 machine, press the Windows Start Button (that button that has the Windows logo on it) or open the start menu and type “Character Map.” This will give you access to launch the &lt;strong&gt;Character Map&lt;/strong&gt; application. Switch the font to Segoe UI Symbol and scroll down to the bottom until you see something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-OjbMPuyN20Y/T1YtD6iGlqI/AAAAAAAAAjY/49tsht7qaR0/s1600-h/segoeuisymbol%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="segoeuisymbol" border="0" alt="segoeuisymbol" src="http://lh6.ggpht.com/-hmhj1RRbK1M/T1YtEXwSyGI/AAAAAAAAAjg/hykLBi5Jy7w/segoeuisymbol_thumb%25255B2%25255D.png?imgmax=800" width="612" height="670"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now you can simply select the icon you wish to include. For this example I’ve selected the camera icon. Note the code at the bottom: U+E114. That is the code I need to know I can use &amp;amp;#xE114; in text for the Segoe UI Symbol font to make the camera icon appear.&lt;/p&gt;
&lt;p&gt;How cool is that? You’ll find the font covers most of the icons you would need for your application. By using the icons from the font set, you also ensure consistency with other Metro applications. Users will be familiar with the fonts and it will make it easier for them to choose the right one for the task they intend to perform.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-7532222332682040440?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AW84FsRs4K0:w-BnIlytIlk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AW84FsRs4K0:w-BnIlytIlk:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AW84FsRs4K0:w-BnIlytIlk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=AW84FsRs4K0:w-BnIlytIlk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AW84FsRs4K0:w-BnIlytIlk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=AW84FsRs4K0:w-BnIlytIlk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AW84FsRs4K0:w-BnIlytIlk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AW84FsRs4K0:w-BnIlytIlk:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/AW84FsRs4K0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/7532222332682040440/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/03/windows-8-icons-segoe-ui-symbol.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7532222332682040440?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7532222332682040440?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/AW84FsRs4K0/windows-8-icons-segoe-ui-symbol.html" title="Windows 8 Icons: Segoe UI Symbol" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-Z9J4wbKJ9-U/T1YtDSb9--I/AAAAAAAAAjQ/1LJ-pm5nbzc/s72-c/back_thumb.png?imgmax=800" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/03/windows-8-icons-segoe-ui-symbol.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMCRHw6eCp7ImA9WhVTFU4.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6418126495792993311</id><published>2012-02-29T12:22:00.001-05:00</published><updated>2012-02-29T12:27:45.210-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-29T12:27:45.210-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="consumer preview" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><title>Windows 8 Consumer Preview 101</title><content type="html">&lt;p&gt;It’s finally here! Unless you’ve been hiding under a rock, you have heard the buzz around the Windows 8 Consumer Preview. If you haven’t had the opportunity to grab it and install it, I suggest you browser over to &lt;a href="http://windows.microsoft.com/en-US/windows-8/iso" target="_blank"&gt;this link&lt;/a&gt; now and download your copy! There are many exciting new features, and this post will guide you through a few of them.&lt;/p&gt; &lt;h2&gt;It is a Beta After All&lt;/h2&gt; &lt;p&gt;There has been much buzz around whether or not the name “Consumer Preview” means it is not a beta and therefore the final release will be delayed. There is a lot of speculation around why the word “beta” is being avoided. Here is &lt;a href="http://www.zdnet.com/blog/bott/windows-8-consumer-preview-due-february-29-why-its-not-called-beta/4496" target="_blank"&gt;an article explaining some of these ideas&lt;/a&gt;. When you install the Consumer Preview – in fact, any time it loads or wakes up – you are presented with an image of, well, a Beta.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/--RkRcferbao/T05ehNp1KBI/AAAAAAAAAg8/Rze6Laq7ZR4/s1600-h/addmef2.png"&gt;&lt;img title="addmef" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="addmef" src="http://lh4.ggpht.com/-PDg__g5ZkuY/T05eiKZFMkI/AAAAAAAAAhE/OVbrAUMnorI/addmef_thumb.png?imgmax=800" width="217" height="214"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;The Green Stack Isn’t Only Green&lt;/h2&gt; &lt;p&gt;A common name for Metro-style applications you may hear is the “green stack.” This is named because the &lt;a href="http://www.zdnet.com/blog/perlow/windows-8-developer-preview-video-tour/18680" target="_blank"&gt;Developer Preview sported a green background&lt;/a&gt;. That’s no longer the case. You can now customize the color and design of the background for your Metro experience. I proudly present the Metro palette:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-cXMhPRSB9f4/T05ejSfK7oI/AAAAAAAAAhM/B7oxK4lgX9c/s1600-h/personalize4.png"&gt;&lt;img title="personalize" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="personalize" src="http://lh4.ggpht.com/-lS_p_GTghKU/T05elRBgKqI/AAAAAAAAAhU/oSU0vJWpwbg/personalize_thumb2.png?imgmax=800" width="502" height="247"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Where is the Start Button? &lt;/h2&gt; &lt;p&gt;Twitter, Facebook, and blogs were going crazy over the rumors that the start button was going away. As a few people quickly pointed out, that isn’t really the case. True, there is no long a pervasive Start Button sitting on the corner of your task bar. But do you need it? First, most hardware and keyboards have a Start Button already – new tablets for Windows will feature this, so you can use the version on your device (this is similar to the way Windows Phone comes with hardware Back, Home, and Search buttons). &lt;/p&gt; &lt;p&gt;Even if you think resorting to the hardware is a cop-out, there is hope. Simply swipe your thumb in from the right edge of the screen or move your mouse pointer over to the right edge, and you will be greeted with … well … it’s a button, and I’m pretty sure it takes you to the screen you’re looking for.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-gQJkLtQOuPM/T05emVYh09I/AAAAAAAAAhc/0Zi4rjCjTtI/s1600-h/startmenu8.png"&gt;&lt;img title="startmenu" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="startmenu" src="http://lh3.ggpht.com/-UOcxtAI4TBc/T05em_nVU1I/AAAAAAAAAhk/shHQ7kHCGgA/startmenu_thumb4.png?imgmax=800" width="576" height="451"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Lots of New Tiles&lt;/h2&gt; &lt;p&gt;One thing you’re sure to notice immediately is the number of new tiles. Microsoft has been working hard to add additional functionality to the Metro stack and it shows. Just take a look.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-DmNBuSBuOlc/T05enpv2epI/AAAAAAAAAhs/V6GS4M9QHDA/s1600-h/start4.png"&gt;&lt;img title="start" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="start" src="http://lh4.ggpht.com/-Ys8eBBmI-po/T05eo5w-NXI/AAAAAAAAAh0/Jrw-7CjyDk8/start_thumb2.png?imgmax=800" width="538" height="423"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Does that look busy or what? This snapshot was from a new install because I didn’t want to share too much personal information, but once you log into the various tools, the tiles will begin to update. I’ll go into some more interesting features below. You can see that instead of Windows Live, you have applications integrated into the platform for things like Mail and Messaging. What else can you see? &lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;XBox Live Games&lt;/strong&gt; – along with all of the fun integration with your account and avatar  &lt;li&gt;&lt;strong&gt;Bing Maps&lt;/strong&gt; – yes, it will find your current location and give you driving directions  &lt;li&gt;&lt;strong&gt;Calendar – &lt;/strong&gt;once you link your accounts, the Calendar works very similar to the way the Windows Phone does and aggregates your calendars together with a live tile announcing upcoming events  &lt;li&gt;&lt;strong&gt;XBox Live Companion&lt;/strong&gt; – yes, you can link to your favorite console and control it from your tablet  &lt;li&gt;&lt;strong&gt;Store&lt;/strong&gt; – everyone has a store, right? &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;These are just some of the highlights. Let’s dive a layer deeper.&lt;/p&gt; &lt;h2&gt;Mail&lt;/h2&gt; &lt;p&gt;Mail is an integrated feature. I like having mail right there, but it feels a bit raw. I was not able to hook into my hosted Exchange (soon to be Office 365) account and once I closed and came back, lost the ability to add a new account. Still, it allows me to browse mails quickly and easily and demonstrates the potential of where the platform can go.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-FfAeIjrGP1E/T05eqPZXlmI/AAAAAAAAAh8/2en8LleET4w/s1600-h/mail3.png"&gt;&lt;img title="mail" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="mail" src="http://lh5.ggpht.com/-QV77GKMc7Xw/T05eqXwBGwI/AAAAAAAAAiE/cgjuWHt9yIc/mail_thumb1.png?imgmax=800" width="520" height="434"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Music and Videos&lt;/h2&gt; &lt;p&gt;Ah, now this one was fun! I wondered whether or not I would have to install Zune. When you first pop in, you get some encouraging sections like this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-Gu5JdIYb2Xc/T05eq_jXyjI/AAAAAAAAAiM/lq4rvYINPE8/s1600-h/music3.png"&gt;&lt;img title="music" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="music" src="http://lh3.ggpht.com/-eoreitHaDpI/T05etUMHlLI/AAAAAAAAAiU/jon2IU8rDGU/music_thumb1.png?imgmax=800" width="553" height="462"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;What? No music? Do I have to go online and grab it? On a whim, I decided to copy over my Zune library from another laptop. This was just a straight file system copy, but guess what? It worked. Once I had the music moved over, it was instantly recognized and available to shuffle, play, and enjoy from my tablet. My tile turned into this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-Sf_8GKwqyrY/T05euXpAXRI/AAAAAAAAAic/jSqlX-K4kEA/s1600-h/music-tile3.png"&gt;&lt;img title="music-tile" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="music-tile" src="http://lh5.ggpht.com/-YxqNv_cOjT0/T05ev6rrYtI/AAAAAAAAAik/Yj3Im4vmXvI/music-tile_thumb1.png?imgmax=800" width="555" height="302"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Previewing just a cross-section of some of the albums I have digitized. As for videos, I have lots of DVDs. Anyone have a good, um, ripper they can recommend?&lt;/p&gt; &lt;h2&gt;People&lt;/h2&gt; &lt;p&gt;This is by far my favorite feature. Like mail, it has a lot of work left to be done. The interface is not great and in fact scanning updates is tedious. However, the potential is what excites me the most. I love this feature on my Windows Phone. Basically, add connections to social networks, mail, etc. and all of your contacts meld together into one place. You get tile notifications, seamless history between messages, emails, and phone calls, and updates and notifications all in one place. The potential exists here for the same integration, it just needs to mature more.&lt;/p&gt; &lt;p&gt;Below you can see some of the potential – the cut off portion has contact names and pictures (I don’t think they’d be happy if I shared them here, hence the crop).&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-tFFSrIYxrCs/T05ewEpU4EI/AAAAAAAAAis/YJmobDaAYF8/s1600-h/people3.png"&gt;&lt;img title="people" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="people" src="http://lh6.ggpht.com/-eNRLzUNRtak/T05ewiFpMzI/AAAAAAAAAi0/Y6OyPJR1iY0/people_thumb1.png?imgmax=800" width="297" height="434"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Closing Applications&lt;/h2&gt; &lt;p&gt;Oh, remember how everyone complained that app swapping was a pain because there was no easy way to close applications? Not any more. There is a new gesture to take care of this. With your finger you can simply swipe downward from the top of the tablet display. This will shrink the current application. From there you can release and have it snap back, or continue to swipe down off the bottom and this action will close the application. Using a mouse? No problem. Hover near the top of the application until the pointer turns into a little hand. Click to grab, then drag it down and toss it off the bottom of your screen to close it.&lt;/p&gt; &lt;h2&gt;Conclusion&lt;/h2&gt; &lt;p&gt;I think there is a huge step forward between the Developer Preview and the Consumer Preview. It seems Microsoft is working hard and listening to feedback. There is a lot of work to do, however. &lt;/p&gt; &lt;p&gt;Did you install the Consumer Preview? If so, what are your thoughts? Ping back with the comments below.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6418126495792993311?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=b0I3rPj1X0M:kEO67ZuukNQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=b0I3rPj1X0M:kEO67ZuukNQ:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=b0I3rPj1X0M:kEO67ZuukNQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=b0I3rPj1X0M:kEO67ZuukNQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=b0I3rPj1X0M:kEO67ZuukNQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=b0I3rPj1X0M:kEO67ZuukNQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=b0I3rPj1X0M:kEO67ZuukNQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=b0I3rPj1X0M:kEO67ZuukNQ:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/b0I3rPj1X0M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6418126495792993311/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/02/windows-8-consumer-preview-101.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6418126495792993311?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6418126495792993311?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/b0I3rPj1X0M/windows-8-consumer-preview-101.html" title="Windows 8 Consumer Preview 101" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-PDg__g5ZkuY/T05eiKZFMkI/AAAAAAAAAhE/OVbrAUMnorI/s72-c/addmef_thumb.png?imgmax=800" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/02/windows-8-consumer-preview-101.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEACSXo6fSp7ImA9WhVTEU0.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-3112272527071619703</id><published>2012-02-24T13:06:00.000-05:00</published><updated>2012-02-24T13:06:08.415-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-24T13:06:08.415-05:00</app:edited><title>What are YOU Looking for in the Consumer Preview?</title><content type="html">&lt;p&gt;It seems there is quite a bit of anticipation surrounding the imminent release of the Windows 8 Consumer Preview. I've read the speculation about what it will actually include, or not include, and if this release really means anything in the larger scheme of things. 
&lt;p&gt;The release will coincide with the &lt;a href="http://www.mobileworldcongress.com/index.html" target="_blank"&gt;Mobile World Congress&lt;/a&gt;. What I find interesting is that the same week, thousands of &lt;a href="http://mvp.support.microsoft.com/" target="_blank"&gt;Microsoft MVP awardees&lt;/a&gt; will descend on Bellevue, Washington (close to the campus in Redmond) for the &lt;A href="http://mvp.support.microsoft.com/MVPsummit" target="_blank"&gt;Global MVP Summit&lt;/a&gt;. I know as a Silverlight MVP I am very interested in what I will learn that week &amp;mdash; unfortunately it is often NDA so I'm not always able to share. I'll be keeping a close eye on the MWC and the release of the Windows 8 preview. 
&lt;p&gt;If you are in Seattle next week, why not drop by our &lt;a href="http://www.eventbrite.com/event/2992170663" target="_blank"&gt;Wintellect tweetup&lt;/a&gt;? Use the link to register. I'll be there along with the debugging master &lt;a href="http://wintellect.com/Consulting/Consultants/John-Robbins" target="_blank"&gt;John "Bugslayer" Robbins&lt;/a&gt;, CLR expert &lt;a href="http://wintellect.com/Consulting/Consultants/Jeffrey-Richter" target="_blank"&gt;Jeffrey Richter&lt;/a&gt;, and fellow MVP &lt;A href="http://wintellect.com/Company/Our-Management/Steven-Porter" target="_blank"&gt;Steve Porter&lt;/a&gt;. We'll be discusing several topics ranging from Windows 8 to the new look for &lt;A href="http://msdn.microsoft.com/en-us/vstudio/hh127353" target="_blank"&gt;Visual Studio 11&lt;/a&gt;. 
&lt;p&gt;My book &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321810414" target="_blank"&gt;Designing Silverlight Business Applications&lt;/a&gt; is very close to final release. You can pre-order for 42% off at Amazon as of the date of this blog post. I am working on my second book about Windows 8 Metro Applications and am learning more and more how the fundamental skills and concepts we learned for Silverlight apply in this new environment. As I read the buzz about the new version coming out, I wonder how many people are actually hands-on with the Developer Preview bits and what your expectations are for the Consumer Preview that is right around the corner. What are your thoughts? What do you think Microsoft needs to demonstrate with this release? What do you see as the major hurdles they will need to overcome in order to successfully gain a foothold in the consumer market? What is your general feedback from using the current version? Please use the comments below to share your thoughts as this important conversation gains momentum moving into next week. 
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-3112272527071619703?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-L_A8ekEFjI:cDV4cXCBmZA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-L_A8ekEFjI:cDV4cXCBmZA:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-L_A8ekEFjI:cDV4cXCBmZA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=-L_A8ekEFjI:cDV4cXCBmZA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-L_A8ekEFjI:cDV4cXCBmZA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=-L_A8ekEFjI:cDV4cXCBmZA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-L_A8ekEFjI:cDV4cXCBmZA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=-L_A8ekEFjI:cDV4cXCBmZA:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/-L_A8ekEFjI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/3112272527071619703/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/02/what-are-you-looking-for-in-consumer.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3112272527071619703?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3112272527071619703?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/-L_A8ekEFjI/what-are-you-looking-for-in-consumer.html" title="What are YOU Looking for in the Consumer Preview?" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>5</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/02/what-are-you-looking-for-in-consumer.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYMSHY_eip7ImA9WhRaEU4.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6933861427457390693</id><published>2012-02-09T23:25:00.001-05:00</published><updated>2012-02-13T06:39:49.842-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-13T06:39:49.842-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="arm" /><category scheme="http://www.blogger.com/atom/ns#" term="metro" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="windows 8" /><title>Windows 8: The Facts about ARM, Metro, and the Blue Stack</title><content type="html">&lt;p&gt;Many eyes will be focused on Barcelona on February 29, 2012 when Microsoft releases the &lt;a href="http://www.zdnet.com/blog/microsoft/microsoft-to-launch-windows-8-consumer-preview-at-mwc/11856" target="_blank"&gt;Windows 8 Consumer Preview&lt;/a&gt; or what many are calling the beta version of the new platform. You’ve probably heard quite a bit about the Metro interface. It has design roots in Zune, Windows Media Center, and Windows Phone. It presents content-rich tiles and is designed to focus on a touch-first experience. Metro provides a unique experience and involves a specific set of tools and technologies. When you read that Internet Explorer 10 doesn’t support plug-ins, you aren’t getting the full story because it’s really only the Metro version that has this restriction. &lt;/p&gt; &lt;p&gt;Of course, we’ve just learned about the experience for &lt;a href="http://blogs.msdn.com/b/b8/archive/2012/02/09/building-windows-for-the-arm-processor-architecture.aspx" target="_blank"&gt;Windows 8 on ARM machines&lt;/a&gt;. Probably the most revealing quote for me was this one: &lt;/p&gt; &lt;p&gt;&lt;em&gt;“WOA will not support any type of virtualization or emulation approach, and will not enable existing x86/64 applications to be ported or run.”&lt;/em&gt;&lt;/p&gt; &lt;p&gt;There’s quite a bit that can be read into that statement, so let’s break it down for a second. Here’s what I understand:&lt;/p&gt; &lt;h2&gt;1. Regular Desktop Applications will NOT run on ARM Machines&lt;/h2&gt; &lt;p&gt;I never imagined this would be the case because ARM is simply a different architecture. Fundamentally, the instructions used by the CPU at the lower level are different instructions than the ones on x86 and x64 machines. Microsoft bridged the gap between x86 and x64 somewhat by introducing an emulation layer called WOW64 (Windows on Windows 64-Bit) that enables 32-bit (x86) code to run in the x64 environment. I speculated that a possibility might be that Microsoft would create a similar engine for ARM but that is clearly not the case. So all of those programs compiled to x86 and x64 simply won’t work.&lt;/p&gt; &lt;p&gt;It is possible that some applications may make it over. Microsoft was clear, for example, that they will provide special versions of Microsoft Office 15. This appears to be part of the “blue stack” or desktop mode for ARM, which raises some interesting questions. If I were to try to draw the architecture of the Windows 8 stack based on the latest announcement, it would look something like this. Keep in mind this is a typical “stack” diagram that is not a true architecture and there are some obvious issues (for example, Win32 technically extends beneath the Metro stack but I’ve kept it out to keep it simple). Here’s what I am picturing:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-B_oLXuxKNLs/TzScQmUfdaI/AAAAAAAAAdk/uUeSZaORi50/s1600-h/stacks%25255B3%25255D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="stacks" border="0" alt="stacks" src="http://lh6.ggpht.com/-qhW3FfZ7vXI/TzScQ_3eEEI/AAAAAAAAAds/3en8ijjglEg/stacks_thumb%25255B1%25255D.jpg?imgmax=800" width="652" height="512"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Notice that the entire Metro stack sits on top of the full suite of processors, while there is a definite dividing line between the x86 and x64 sides versus the ARM side. So What does it mean? Here is the first thing I can infer: &lt;/p&gt; &lt;h2&gt;2. The .NET Framework will not target ARM devices&lt;/h2&gt; &lt;p&gt;Notice there is no CLR layer in the blue stack side for ARM. From what I read I don’t think this is the case because if the framework were available, Microsoft would explain that a whole suite of existing applications should run fine. Ironically, one of the early points about the .NET Framework was that it contained an abstraction layer with MSIL (Microsoft Intermediate Language) that should allow it to target different platforms, including ARM. It doesn’t appear this effort was made. However, this does raise a point of confusion that I look forward to learning more about and clarifying as more information becomes available. Take a look here: &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-BGSLv8a3DyA/TzScRFa8LEI/AAAAAAAAAd0/hTPT7uopKO4/s1600-h/stackclr%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="stackclr" border="0" alt="stackclr" src="http://lh5.ggpht.com/-mUJv5DN5sOQ/TzScRSjHfJI/AAAAAAAAAd8/XErEJslVnKI/stackclr_thumb%25255B1%25255D.png?imgmax=800" width="278" height="288"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I know that on x86/64 machines, the C# version of Metro applications actually runs on the CLR. It uses the .NET Framework. There is a “core profile” that limits a number of Base Class Libraries (BCL) but it uses this nonetheless. There are also projections of the WinRT API that expose themselves as CLR objects. Since the announcement from Microsoft certainly embraced the fact that ARM realizes the full Metro stack, the implication is that this CLR layer exists. So the question is: do they have a version of the framework available? Did they just provide a smaller stub/trimmed down version like Silverlight that just supports the Metro stack needs? Is there a different mechanism altogether on the ARM platform that is something new? I’m sure these questions will be answered but it does make me curious. If we agree that there is not a general framework version available and we also know that there is no emulation/virtual layer, then I can also safely guess that … &lt;/p&gt; &lt;h2&gt;3. .There is No Silverlight on ARM Devices&lt;/h2&gt; &lt;p&gt;This is actually not something I’m disappointed about. It makes sense. The Silverlight runtime might not make sense for a number of reasons including the overhead of building a version that targets ARM (this has been done to support Windows Phone 7, but it is a different version) and battery/memory management concerns. I still think writing applications that target the platform specifically makes sense. There is a reason why iPad devices are so popular. They are fluid, the applications are responsive, and they just work. While an x86/x64 tablet has the perfect architecture to host the full desktop experience, ARM is a different architecture specifically targeting the mobile space and should be optimized that way. &lt;/p&gt; &lt;p&gt;This is why I’m fairly sure (and agree with the decision that) the ARM version of Metro won’t run plug-ins. The plug-ins are hosted on Windows machines and are therefore compiled to x86/x64 machine code which is not compatible with ARM. It simply doesn’t make sense for Microsoft to invest in building, what, a special ARM plug-in just for Silverlight? &lt;/p&gt; &lt;p&gt;However, there is a desktop experience and there will be applications released for this mode. So what makes me very curious is this: &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-YmBpqViCWR0/TzScRqpgkFI/AAAAAAAAAeE/G-TBkh8KLFg/s1600-h/stacklanguage%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="stacklanguage" border="0" alt="stacklanguage" src="http://lh3.ggpht.com/-yCXImOFtSrc/TzScR2uTZ-I/AAAAAAAAAeM/43a7SGj5Uwo/stacklanguage_thumb%25255B1%25255D.png?imgmax=800" width="431" height="353"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;So this is just my educated guess but from the post it is obvious there are desktop experiences like Explorer and &lt;a href="http://www.pcworld.com/businesscenter/article/249679/surprise_windows_8_for_arm_will_come_with_office_15_apps.html" target="_blank"&gt;applications like Office 15&lt;/a&gt; that will target ARM. So what is the platform for building these? Will Microsoft make this available for us to use, so we can do blue-stack development on ARM machines, or will it only host some exclusive products? Is the engine they are using a C++ based engine or do they have a full suite of language options available that can target this area of the platform? Again, right now I can only speculate but it will be interesting to learn. &lt;/p&gt; &lt;p&gt;At this point you might wonder why I’m so calm saying Silverlight on ARM is not a good choice when I just finished a book about Silverlight business applications. The answer is simple. Too many people assume that WinRT is the future for Microsoft and anything that isn’t supported by the Metro stack is going to become extinct. I disagree. In fact, I’ll say … &lt;/p&gt; &lt;h2&gt;4. WinRT is NOT the Future for Microsoft &lt;/h2&gt; &lt;p&gt;Don’t get me wrong. WinRT isn’t going away and is a major part of Microsoft’s future. I just meant it is not THE future for Microsoft. Contrary to speculation, Microsoft is not putting their eggs all in one basket and are not just focusing on Metro for Windows 8. I am still confident we’ll see traditional WPF and Silverlight development on existing Windows 7 machines and Windows 8 machines for the desktop side moving forward. Do you really think ALL complex user interfaces will go away? That certain people will stop doing CRUD data entry applications, or authors will suddenly be happy using the pen tool to write novels when they can type 15 times faster? &lt;/p&gt; &lt;p&gt;I doubt it.&lt;/p&gt; &lt;p&gt;There will still be a need for devices that run a powerful OS capable of building software and allowing us to use big Excel spreadsheets as well as pop open Word to write a document or PowerPoint to prepare a presentation. I don’t think that blue stack is going away any time soon. I also believe if you do find yourself doing Metro development, you’ll be using many of the same skills you are familiar with in Silverlight.&lt;/p&gt; &lt;p&gt;Don’t take my word for the fact that Windows 8 is not just about Metro. Let’s take a quick look at the evidence for the tale of two stacks.There has been plenty of talk about the jarring experience of falling back to the desktop mode. This mode is backwards compatible for applications that are written for previous versions of Windows and I’ve confirmed this by installing applications like Microsoft Office, Amazon Kindle, and several Silverlight-based touch applications including ones I’ve previously helped write. As my current book &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321810414" target="_blank"&gt;Designing Silverlight Business Applications&lt;/a&gt; goes into print, it’s comforting this paradigm is still fully supported on the new platform. So what is the evidence that the desktop mode is not just a mere fallback to Windows 7 that hides behind the Metro stack? &lt;/p&gt; &lt;p&gt;Here are a few announcements from Microsoft and changes with the desktop mode for x86/x64 targets that really stand out:&lt;/p&gt; &lt;h2&gt;Fast Boot and Reduced Memory Footprint&lt;/h2&gt; &lt;p&gt;Windows 8 boots fast. It’s not an illusion either. On an SSD machine you can shut down, press power for a cold boot and be working in your next application within seconds. This is a huge benefit – how many times have you actually delayed firing up your laptop because you dreaded the long boot time? That completely goes away with the new boot.Read about &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/09/08/delivering-fast-boot-times-in-windows-8.aspx" target="_blank"&gt;delivering fast boot times in Windows 8&lt;/a&gt;. Learn more about how these features also &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/10/07/reducing-runtime-memory-in-windows-8.aspx" target="_blank"&gt;reduce the memory footprint&lt;/a&gt;.&lt;/p&gt; &lt;h2&gt;Graphical UEFI Boot&lt;/h2&gt; &lt;p&gt;The boot is not only faster. The boot supports the &lt;a href="http://www.uefi.org/about/" target="_blank"&gt;UEFI standard&lt;/a&gt; and is graphical. Remember those old text-based menus we used to have to navigate when dual-booting? Those are a thing of the past. Not only do you get a nice graphical boot interface, you also benefit from features like touch support so you can use your tablet to navigate the boot options. You can see screenshots of the experience and learn more about it &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/09/20/reengineering-the-windows-boot-experience.aspx" target="_blank"&gt;in this link&lt;/a&gt;. This is not just an illusion, it works and it works with your Windows 7 applications. &lt;/p&gt; &lt;h2&gt;Windows 8 on a Stick&lt;/h2&gt; &lt;p&gt;This is a phenomenal feature that I haven’t seen covered much. It refers to the capability to install your Windows instance on a thumb drive so it can travel with you from work to home. This special version of the OS is capable of recognizing the device/hardware configuration and hosting the instance based on the environment you boot to. Imagine being able to install your favorite applications and configurations, then be able to take them and use them on your work desktop as easily as your personal laptop. You can learn more about &lt;a href="http://mcpmag.com/articles/2011/09/16/microsoft-unveils-windows-to-go-for-the-enterprise.aspx" target="_blank"&gt;this feature here&lt;/a&gt;.&lt;/p&gt; &lt;h2&gt;New Explorer Experience and Features&lt;/h2&gt; &lt;p&gt;The Windows Explorer experience has been &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/08/29/improvements-in-windows-explorer.aspx" target="_blank"&gt;completely revamped&lt;/a&gt;.While remaining familiar to users of the legacy version, it provides more functionality through the expanded ribbon interface. When you manipulate files from within Explorer, you will immediately &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/08/23/improving-our-file-management-basics-copy-move-rename-and-delete.aspx" target="_blank"&gt;experience the improved file management basics&lt;/a&gt;. Operations such as mounting VHD drives or ISO images have been &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/08/30/accessing-data-in-iso-and-vhd-files.aspx" target="_blank"&gt;completely integrated out of the box&lt;/a&gt;.The new concept of &lt;a href="http://blogs.msdn.com/b/b8/archive/2012/01/05/virtualizing-storage-for-scale-resiliency-and-efficiency.aspx" target="_blank"&gt;Storage Spaces&lt;/a&gt; allows you to organize pools of storage and virtual disks that behave like physical disks. Disk support has been extended to allow for &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/11/29/enabling-large-disks-and-large-sectors-in-windows-8.aspx" target="_blank"&gt;larger disks with large sectors&lt;/a&gt;. This is a completely new file system experience that remains compatible with the legacy features you are familiar with. &lt;/p&gt; &lt;h2&gt;Enhanced Task Manager&lt;/h2&gt; &lt;p&gt;Microsoft took a new look at the task manager and completely &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/10/13/the-windows-8-task-manager.aspx" target="_blank"&gt;refreshed its capabilities&lt;/a&gt;.This is substantial because it wasn’t just extended to support the new Metro platform. It now has a simple view for killing applications that does it quickly and efficiently. The grid was enhanced to help diagnose performance issues by providing heat maps and lighting up resource usage. It also groups like processes together.&lt;/p&gt; &lt;p&gt;There are actually many other features that address the non-Metro space for Windows 8 but I’ve gone on far enough in this post. I’m again very excited about Windows 8 on ARM and commend Microsoft for taking a non-compromise approach to making it the best experience possible. Although WinRT and the Metro platform is definitely the future for mobile and touch-based devices with Windows 8, I encourage you to keep pace with the desktop-based enhancements and remember there is an entirely different stack available for line of business applications that might not make sense in the Metro paradigm. &lt;/p&gt; &lt;p&gt;As a developer with XAML and C# skills you are well positioned to navigate both stacks as you build applications and have the freedom to choose what makes the most sense for your end user. Of course, I’m not assuming those are the only languages my readers know – and now there is a first class space for C++ development as well. No, I didn’t forget our HTML5 and JavaScript developers, but to be honest, that is the one block in the stack that I’ve spent the least amount of time in. I’m currently writing my next book on “Building Windows 8 Metro Applications with XAML and C#”. I believe there will be a huge benefit for existing Silverlight developers to work in both worlds. Look for more details from Addison-Wesley soon on that new title.&lt;/p&gt; &lt;p&gt;What are your thoughts about the recent announcements? Are you going to try to be first in line to download the next version when it becomes available?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6933861427457390693?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Th8fv2slPq8:ab7--Rtw1UI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Th8fv2slPq8:ab7--Rtw1UI:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Th8fv2slPq8:ab7--Rtw1UI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=Th8fv2slPq8:ab7--Rtw1UI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Th8fv2slPq8:ab7--Rtw1UI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=Th8fv2slPq8:ab7--Rtw1UI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Th8fv2slPq8:ab7--Rtw1UI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Th8fv2slPq8:ab7--Rtw1UI:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/Th8fv2slPq8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6933861427457390693/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/02/windows-8-facts-about-arm-metro-and.html#comment-form" title="26 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6933861427457390693?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6933861427457390693?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/Th8fv2slPq8/windows-8-facts-about-arm-metro-and.html" title="Windows 8: The Facts about ARM, Metro, and the Blue Stack" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-qhW3FfZ7vXI/TzScQ_3eEEI/AAAAAAAAAds/3en8ijjglEg/s72-c/stacks_thumb%25255B1%25255D.jpg?imgmax=800" height="72" width="72" /><thr:total>26</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/02/windows-8-facts-about-arm-metro-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMBQ3o_eSp7ImA9WhRUFUw.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-3646731473667061894</id><published>2012-01-25T12:42:00.000-05:00</published><updated>2012-01-25T12:44:12.441-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-25T12:44:12.441-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="mvvm" /><category scheme="http://www.blogger.com/atom/ns#" term="mvc" /><category scheme="http://www.blogger.com/atom/ns#" term="html5" /><category scheme="http://www.blogger.com/atom/ns#" term="html" /><category scheme="http://www.blogger.com/atom/ns#" term="knockoutjs" /><title>MVVM on MVC: HTML is not XAML</title><content type="html">&lt;p&gt;I have to admit that I may have rolled my eyes a bit when I first learned about the &lt;a href="http://knockoutjs.com/" target="_blank"&gt;KnockoutJS&lt;/a&gt; library. It sounded too much like forcing a square peg into a round hole. Isn’t Model-View-Controller (MVC) already &lt;a href="http://msdn.microsoft.com/en-us/library/ff649643.aspx" target="_blank"&gt;it’s own pattern&lt;/a&gt;? Does it make sense to apply something like Model-View-ViewModel (&lt;a href="http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html" target="_blank"&gt;MVVM&lt;/a&gt;) to HTML? I already had enough issues dealing with MVVM on the platform it was designed for, XAML and C# (WPF and Silverlight). Some people simply didn’t get the pattern, others were pushing it without really understanding its benefits, and many applications completely and unnecessarily overcomplicated their implementation of the pattern. So before we talk about whether it makes sense in HTML-based applications, we first need to agree on what the benefits of the pattern are.&lt;/p&gt; &lt;p&gt;I’ve heard many opinions regarding this and have not only read lists, but also published my own. You might hear things like “decoupled code” or “best practices” or “modularity.” Many of the benefits often cited are really just good coding practices that should be implemented regardless of the user interface (UI) pattern being followed. After looking at all of the different benefits, coding using different patterns, and spending several years building &lt;a href="http://wintellect.com/Consulting/Case-Studies" target="_blank"&gt;enterprise Line of Business (LOB) Silverlight applications&lt;/a&gt; it really boils down to two specific benefits: &lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;strong&gt;Testability&lt;/strong&gt; – MVVM improves the testability of your application. This is only a benefit if you feel that testing itself provides benefits.  &lt;li&gt;&lt;strong&gt;Designer-Developer Workflow&lt;/strong&gt; – MVVM facilitates a separation of UI and presentation logic concerns from the business layer that makes it easy to streamline the development process by allowing design cycles to happen in parallel with development. A great example of this was the &lt;a href="http://www.wintellect.com//Consulting/Case-Studies/Looking-Glass" target="_blank"&gt;Microsoft Looking Glass project&lt;/a&gt; that had more than 6 designers working on design for over 3 months while we developed it. The total delivery time was around 4 months, instead of the typical 7 (3 + 3 + 1 month of testing) you get when the design process has to happen sequentially and not parallel to the development effort. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The design-time views even without the workflow are useful but not critical in my opinion. So how does this all translate to HTML-based development?&lt;/p&gt; &lt;h2&gt;HTML is Not XAML&lt;/h2&gt; &lt;p&gt;The first distinction that Silverlight and WPF developers need to make is between HTML and XAML. They are often compared, but are they really similar? &lt;/p&gt; &lt;p&gt;XAML is a declarative language for instantiating an object graph. While it is commonly used for UI elements, it can create special objects like styles that apply theming to elements, behaviors, triggers, even code that has no visual artifacts whatsoever. XAML by nature is extensible. You can create new elements that map to custom classes, and extend the attributes of existing elements through attachments and custom markup extensions. This strict relationship between the declaration and the object graph means that invalid XAML is a Bad Thing™ and causes the XAML parser to choke. If it cannot instantiate an object or set a property, the entire visual tree is invalid and that’s that. &lt;/p&gt; &lt;p&gt;HTML is declarative markup. It defines a structure. Most of that structure is simply containers for information. There is minimal behavior. Elements are pre-defined based on an &lt;a href="http://dev.w3.org/html5/spec/Overview.html" target="_blank"&gt;accepted standard&lt;/a&gt; and arbitrary extension or customization is not supported. The containers provide some structure to information, but it is ultimately CSS that defines the UI and to an extent some of the presentation logic and behaviors. JavaScript handles the object graph for the page, but neither CSS nor HTML declaratively instantiate JavaScript objects. It’s the other way around – JavaScript in the context of a page is more like parsing an XML Document in C# code than it is like having XAML and code-behind. The closest thing to XAML in the web world is server-side code that through whatever mechanism emits the HTML and JavaScript code elements of a web page.&lt;/p&gt; &lt;p&gt;Because HTML is just structure, browsers can also be very forgiving in their parsing. They do not have to map an element to an actual class or type that is instantiated. Browsers will close your tags for you and even make substitutions for elements they don’t recognize. There are well-known algorithms for &lt;a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#The_rendering_engine" target="_blank"&gt;rendering HTML&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;So how does this fit into MVC? First, let’s be clear on one important distinction:&lt;/p&gt; &lt;h2&gt;MVC as a Framework, not a Pattern&lt;/h2&gt; &lt;p&gt;Note I didn’t say MVC &lt;em&gt;is&lt;/em&gt; a framework, but in the context of this conversation we’ll have to agree that I’m referring to &lt;a href="http://www.asp.net/mvc" target="_blank"&gt;MVC as a Microsoft Framework&lt;/a&gt; and not the pattern. When you talk about the pattern, it can get very confusing when introducing an entirely separate pattern like MVVM. When you talk about a framework based on the pattern, it’s a little easier to understand. While ASP. NET MVC is based on the MVC pattern, it doesn’t force a strict implementation or interpretation of the pattern and provides quite a bit of flexibility with how you structure your pages. You can choose different &lt;a href="http://www.bing.com/search?q=mvc%20view%20engines" target="_blank"&gt;view engines&lt;/a&gt; and write your code in different languages. &lt;/p&gt; &lt;p&gt;So what about MVVM in the MVC framework? One of the key problems I’ve found when dealing with MVC is markup that looks like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="logoDisplay"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                
   &lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt; Html.RenderPartial(&lt;span class="str"&gt;"LogoControl"&lt;/span&gt;); &lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;            
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                      
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="menuContainer"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ul&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="menu"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;: Html.ActionLink(&lt;span class="str"&gt;"Home"&lt;/span&gt;, &lt;span class="str"&gt;"Index"&lt;/span&gt;, &lt;span class="str"&gt;"Home"&lt;/span&gt;)&lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;span class="asp"&gt;&amp;lt;%&lt;/span&gt;: Html.ActionLink(&lt;span class="str"&gt;"About"&lt;/span&gt;, &lt;span class="str"&gt;"About"&lt;/span&gt;, &lt;span class="str"&gt;"Home"&lt;/span&gt;)&lt;span class="asp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ul&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;                       
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;What’s wrong with this? It compiles and runs perfectly fine, right? Here’s my issue: I’ve just lost my designer-developer workflow. True, I might be able to hire an MVC-savvy designer who can work with this code, or I may be responsible for design myself. I’ve seen this workflow before:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Designer creates Adobe Photoshop assets 
&lt;li&gt;Same designer or someone else turns it into a beautiful HTML web page 
&lt;li&gt;Developer has to rip out the HTML as best as they can and format it into the view and merge into CSS 
&lt;li&gt;QA tester finds some strange nuance where a field wraps and unfortunately the designer doesn’t know how to fix it because their version works fine, it’s only in the runtime that it happens 
&lt;li&gt;It turns out one of the embedded commands emitted some whitespace that the template didn’t account for and was causing the issue 
&lt;li&gt;etc. etc. etc. 
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;This also gives me no design-time experience. If HTML was &lt;em&gt;real&lt;/em&gt; HTML without any embedded markup, I could just drag it into a browser and go to town. This is one place I start to see value with MVVM in MVC. I could do the same thing above, but make it look like this instead: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="menuContainer"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ul&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="menu"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt; &lt;span class="attr"&gt;data-bind&lt;/span&gt;&lt;span class="kwrd"&gt;="foreach: menuItem"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt; &lt;span class="attr"&gt;data-bind&lt;/span&gt;&lt;span class="kwrd"&gt;="text: name"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Name&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;     
   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ul&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;   
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now I’ve got clean HTML that I can hand to a designer. I can even pull it up in a browser and view it to get a preview. Only … there’s still a problem. Can you see it?&lt;/p&gt;
&lt;h2&gt;The Problem with Data-Bind&lt;/h2&gt;
&lt;p&gt;Remember how I mentioned that HTML is not XAML? HTML is not supposed to be arbitrarily extended as in the previous example. In fact, most editors will complain about the &lt;em&gt;data-bind&lt;/em&gt; attribute because it’s not a valid, defined attribute. Sure, you’ll get away with it: browsers are notoriously forgiving when it comes to bad mark-up, but this is what I would call an invasive or intrusive way to mark up HTML. What would really be nice is if we could do this more cleanly and provide pristine HTML with CSS, then provide our behaviors, validations, etc. in a way that is design-time friendly and testable.&lt;/p&gt;
&lt;h2&gt;A Clean Approach &lt;/h2&gt;
&lt;p&gt;For my “clean” approach I decided to model a simple form. It allows for first name and last name, shows the name dynamically as it is edited, and only allows submission when both fields are entered. First, let’s take a look at the HTML. I’m confident I could pass this off to a designer and they could modify it to their heart’s content. The only requirement is that they honor my “contract” which is the specific ids I’ve assigned. We agree there is something called a first name and last name and that they should be consistently referenced as &lt;em&gt;firstName&lt;/em&gt; and &lt;em&gt;lastName&lt;/em&gt; – whatever else they want to change is up to them.&lt;/p&gt;
&lt;p&gt;The full HTML is here:&lt;/p&gt;
&lt;p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="html"&gt;DOCTYPE&lt;/span&gt; &lt;span class="attr"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt; &lt;span class="attr"&gt;lang&lt;/span&gt;&lt;span class="kwrd"&gt;="en"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Example MVVM Form&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;link&lt;/span&gt; &lt;span class="attr"&gt;rel&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet"&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="style.css"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/css"&lt;/span&gt; &lt;span class="attr"&gt;media&lt;/span&gt;&lt;span class="kwrd"&gt;="screen"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt; &lt;span class="attr"&gt;language&lt;/span&gt;&lt;span class="kwrd"&gt;="javascript"&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="jquery-1.7.1.js"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; language=&lt;span class="str"&gt;"javascript"&lt;/span&gt; src=&lt;span class="str"&gt;"knockout-2.0.0.js"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;
   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
      &amp;lt;h1&amp;gt;Example MVVM Form&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;This &lt;span class="kwrd"&gt;is&lt;/span&gt; an example of an MVVM-based form. The HTML &lt;span class="kwrd"&gt;is&lt;/span&gt; &lt;span class="str"&gt;"clean"&lt;/span&gt; markup - there are no custom attributes, tags, or embedded JavaScript. Everything &lt;span class="kwrd"&gt;is&lt;/span&gt; wired separately through code.&amp;lt;/p&amp;gt;
      &amp;lt;form id=&lt;span class="str"&gt;"mainForm"&lt;/span&gt; action=&lt;span class="str"&gt;"#"&lt;/span&gt;&amp;gt;
         &amp;lt;div &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"form-label"&lt;/span&gt;&amp;gt;Full Name:&amp;lt;/div&amp;gt;
         &amp;lt;div &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"form-field"&lt;/span&gt;&amp;gt;&amp;lt;span id=&lt;span class="str"&gt;"fullName"&lt;/span&gt;&amp;gt;&amp;lt;/span&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;
         &amp;lt;div &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"form-label"&lt;/span&gt;&amp;gt;First Name:&amp;lt;/div&amp;gt;
            &amp;lt;div &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"form-field"&lt;/span&gt;&amp;gt;
               &amp;lt;input id=&lt;span class="str"&gt;"firstName"&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"textField"&lt;/span&gt; type=&lt;span class="str"&gt;"text"&lt;/span&gt;/&amp;gt;
               &amp;lt;span id=&lt;span class="str"&gt;"firstNameValidation"&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"field-validation"&lt;/span&gt;&amp;gt;&amp;lt;/span&amp;gt;
            &amp;lt;/div&amp;gt;
         &amp;lt;/div&amp;gt;
         &amp;lt;div &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"form-label"&lt;/span&gt;&amp;gt;Last Name:&amp;lt;/div&amp;gt;
            &amp;lt;div &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"form-field"&lt;/span&gt;&amp;gt;
               &amp;lt;input id=&lt;span class="str"&gt;"lastName"&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"textField"&lt;/span&gt; type=&lt;span class="str"&gt;"text"&lt;/span&gt;/&amp;gt;
               &amp;lt;span id=&lt;span class="str"&gt;"lastNameValidation"&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"field-validation"&lt;/span&gt;&amp;gt;&amp;lt;/span&amp;gt;
            &amp;lt;/div&amp;gt;
         &amp;lt;/div&amp;gt;
         &amp;lt;input type=&lt;span class="str"&gt;"submit"&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt;=&lt;span class="str"&gt;"formButton"&lt;/span&gt; value=&lt;span class="str"&gt;"Save"&lt;/span&gt;&amp;gt;
      &amp;lt;/form&amp;gt;
      &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; language=&lt;span class="str"&gt;"javascript"&lt;/span&gt; src=&lt;span class="str"&gt;"./viewModel.js"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; language=&lt;span class="str"&gt;"javascript"&lt;/span&gt; src=&lt;span class="str"&gt;"./mvvm.validations.js"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; language=&lt;span class="str"&gt;"javascript"&lt;/span&gt; src=&lt;span class="str"&gt;"./bindings.js"&lt;/span&gt;&amp;gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
Now that we have a page we can easily edit, let’s make it a little prettier with some simple CSS: &lt;pre class="csharpcode"&gt;body {
    font-family: arial, helvetica, sans serif;
}

h1 {
   color: maroon; font-size: 20pt; font-weight: bold;
}
p {
   font-size: 12pt; 
}
.form-label {
   font-weight: bold;
   float: left;
   width: 200px;
   padding: 10px; 
}
.form-field {
   padding: 10px;
}
input.textField {
   width: 300px;
}
input.formButton {
   width: 100px;
   background-color: lightgreen;
   border: 2px solid green;
}
input.formButton:hover {
   background-color: lightred;
   border: 2px solid red;
}
.field-validation {
   font-weight: bold;
   padding-left: 10px;
   color: red;
}&lt;/pre&gt;
&lt;p&gt;The view model is easy enough, it simply defines fields for the first and last names and a computed field that shows the full name. I’ve even been kind enough to humbly supply a default first name: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;function&lt;/span&gt; NameViewModel() {

   &lt;span class="kwrd"&gt;var&lt;/span&gt; self = &lt;span class="kwrd"&gt;this&lt;/span&gt;;

   &lt;span class="kwrd"&gt;this&lt;/span&gt;.firstName = ko.observable(&lt;span class="str"&gt;'Jeremy'&lt;/span&gt;);
   &lt;span class="kwrd"&gt;this&lt;/span&gt;.lastName = ko.observable(&lt;span class="str"&gt;''&lt;/span&gt;);

   &lt;span class="kwrd"&gt;this&lt;/span&gt;.fullName = ko.computed(&lt;span class="kwrd"&gt;function&lt;/span&gt;() {
      &lt;span class="kwrd"&gt;if&lt;/span&gt; (self.lastName()) {
         &lt;span class="kwrd"&gt;if&lt;/span&gt; (self.firstName()) {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; self.lastName() + &lt;span class="str"&gt;', '&lt;/span&gt; + self.firstName();
         }
         &lt;span class="kwrd"&gt;return&lt;/span&gt; self.lastName();
      }
      &lt;span class="kwrd"&gt;return&lt;/span&gt; self.firstName();
   });
}

&lt;span class="kwrd"&gt;var&lt;/span&gt; viewModel = &lt;span class="kwrd"&gt;new&lt;/span&gt; NameViewModel();&lt;/pre&gt;
&lt;p&gt;What’s nice about the MVVM approach is that I can easily extend the view model to provide validation. I will eventually use the &lt;a href="http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript" target="_blank"&gt;JavaScript module pattern&lt;/a&gt; to create the validations so they can be easily attached and extended, but for this simple example I just used a simple object instead. In this case there is simply a required validation. In a full production system, I would have a library of these validations and also keep a collection on the target object to allow multiple validations to attach to the same attribute.&lt;/p&gt;&lt;pre class="csharpcode"&gt;ko.extenders.required = &lt;span class="kwrd"&gt;function&lt;/span&gt; (target, overrideMessage) {
    
    target.hasError = ko.observable();
    target.validationMessage = ko.observable();

    &lt;span class="kwrd"&gt;function&lt;/span&gt; validate(newValue) {
        target.hasError(newValue ? &lt;span class="kwrd"&gt;false&lt;/span&gt; : &lt;span class="kwrd"&gt;true&lt;/span&gt;);
        target.validationMessage(newValue ? &lt;span class="str"&gt;""&lt;/span&gt; : 
             overrideMessage || &lt;span class="str"&gt;"This field is required."&lt;/span&gt;);
    }

    validate(target());
    target.subscribe(validate);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; target;
};

&lt;span class="kwrd"&gt;function&lt;/span&gt; MvvmValidations() {
    
    &lt;span class="kwrd"&gt;this&lt;/span&gt;.required = &lt;span class="kwrd"&gt;function&lt;/span&gt;(target, overrideMessage) {
        target.extend({ required: overrideMessage });
    };

}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now I have a view model specific to my view and a validation library that I can reuse across multiple views. I tie them all to the HTML like this – note that what is important is that the contracts were honored for the identifiers of the various elements, but everything else can be simply attached and declared.&lt;/p&gt;&lt;pre class="csharpcode"&gt;$(document).ready(&lt;span class="kwrd"&gt;function&lt;/span&gt;() {

   $(&lt;span class="str"&gt;'#firstName'&lt;/span&gt;).attr(&lt;span class="str"&gt;'data-bind'&lt;/span&gt;,&lt;span class="str"&gt;'value: firstName, valueUpdate: "afterkeydown"'&lt;/span&gt;);
   $(&lt;span class="str"&gt;'#lastName'&lt;/span&gt;).attr(&lt;span class="str"&gt;'data-bind'&lt;/span&gt;,&lt;span class="str"&gt;'value: lastName, valueUpdate: "afterkeydown"'&lt;/span&gt;);
   $(&lt;span class="str"&gt;'#fullName'&lt;/span&gt;).attr(&lt;span class="str"&gt;'data-bind'&lt;/span&gt;, &lt;span class="str"&gt;'text: fullName'&lt;/span&gt;);
 
   &lt;span class="kwrd"&gt;var&lt;/span&gt; validations = &lt;span class="kwrd"&gt;new&lt;/span&gt; MvvmValidations();

   validations.required(viewModel.firstName);
   $(&lt;span class="str"&gt;'#firstNameValidation'&lt;/span&gt;)
   .attr(&lt;span class="str"&gt;'data-bind'&lt;/span&gt;,&lt;span class="str"&gt;'visible: firstName.hasError, text: firstName.validationMessage'&lt;/span&gt;);

   validations.required(viewModel.lastName, &lt;span class="str"&gt;"Last name is required."&lt;/span&gt;); 
   $(&lt;span class="str"&gt;'#lastNameValidation'&lt;/span&gt;)
   .attr(&lt;span class="str"&gt;'data-bind'&lt;/span&gt;,&lt;span class="str"&gt;'visible: lastName.hasError, text: lastName.validationMessage'&lt;/span&gt;);

   viewModel.saveName = &lt;span class="kwrd"&gt;function&lt;/span&gt;() {
      &lt;span class="kwrd"&gt;if&lt;/span&gt; (viewModel.firstName.hasError() || viewModel.lastName.hasError()) {
         alert(&lt;span class="str"&gt;'Errors exist.'&lt;/span&gt;); 
         &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;
      }
      alert(&lt;span class="str"&gt;'Looks good!'&lt;/span&gt;);
      &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;
   };

   $(&lt;span class="str"&gt;'form'&lt;/span&gt;).attr(&lt;span class="str"&gt;'data-bind'&lt;/span&gt;, &lt;span class="str"&gt;'submit: saveName'&lt;/span&gt;); 
 
   ko.applyBindings(viewModel);

});

&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;You can view the end result and download the source here: &lt;a href="http://apps.jeremylikness.com/samples/knockout-mvvm/mvvm.html" target="_blank"&gt;http://apps.jeremylikness.com/samples/knockout-mvvm/mvvm.html&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Quod Erat Demonstrandum&lt;/h2&gt;
&lt;p&gt;So what have we achieved? I think quite a bit. This format has allowed me to build out a website using data-binding. The source HTML is clean and can be edited easily by a designer. While I muck around with the DOM at runtime, this is done programmatically and doesn’t require that I invade the HTML or CSS. The JavaScript is separate, reusable, and &lt;a href="http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript" target="_blank"&gt;testable&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;The thing I haven’t shown is how this fits into the MVC framework. In the framework you’ll likely go ahead and use some of those helper methods to specify the path to the JavaScript but you should be able to maintain a nice, clean HTML core. And if the view models seem like a lot of work, you’re not thinking about the bigger picture. With a strongly-typed view (one that correlates to a typed model) you can easily create a view helper that emits the necessary JavaScript for the view model. You could probably even emit the code to generate the bindings, and the only step you would need to take as a developer would be to write the controller to return the model and apply any validates specific to the view.&lt;/p&gt;
&lt;p&gt;At the end of the day, I’m a believer that MVVM can work in MVC if we remember that HTML is not XAML and approach the code the right way.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-3646731473667061894?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AaxNqPUmzqQ:Qu4Xx626sac:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AaxNqPUmzqQ:Qu4Xx626sac:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AaxNqPUmzqQ:Qu4Xx626sac:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=AaxNqPUmzqQ:Qu4Xx626sac:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AaxNqPUmzqQ:Qu4Xx626sac:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=AaxNqPUmzqQ:Qu4Xx626sac:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AaxNqPUmzqQ:Qu4Xx626sac:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=AaxNqPUmzqQ:Qu4Xx626sac:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/AaxNqPUmzqQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/3646731473667061894/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/01/mvvm-on-mvc-html-is-not-xaml.html#comment-form" title="11 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3646731473667061894?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3646731473667061894?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/AaxNqPUmzqQ/mvvm-on-mvc-html-is-not-xaml.html" title="MVVM on MVC: HTML is not XAML" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>11</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/01/mvvm-on-mvc-html-is-not-xaml.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04BQnY7cCp7ImA9WhRUEks.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-3622601889870400349</id><published>2012-01-22T14:52:00.001-05:00</published><updated>2012-01-22T14:52:33.808-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T14:52:33.808-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mvvm" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="Jounce" /><title>Video: Getting Started with Jounce MVVM and MEF for Silverlight 5</title><content type="html">&lt;p&gt;I created a quick video to help you get started with using Jounce. The video starts with a blank slate, steps through installation of Jounce and the creation of a sample view model for a simple contact record that includes validation. 
&lt;p&gt;You can access the video directly at &lt;a href="http://vimeo.com/jeremylikness/jounce-getting-started" target="_blank"&gt;http://vimeo.com/jeremylikness/jounce-getting-started&lt;/a&gt;, or view it below: 
&lt;p&gt;&lt;iframe src="http://player.vimeo.com/video/35466218?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="601" height="451" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/35466218"&gt;Jounce: Getting Started&lt;/a&gt; from &lt;a href="http://vimeo.com/jeremylikness"&gt;Jeremy Likness&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-3622601889870400349?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Bk0ycQmGbS0:QzHjl2F6sXA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Bk0ycQmGbS0:QzHjl2F6sXA:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Bk0ycQmGbS0:QzHjl2F6sXA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=Bk0ycQmGbS0:QzHjl2F6sXA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Bk0ycQmGbS0:QzHjl2F6sXA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=Bk0ycQmGbS0:QzHjl2F6sXA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Bk0ycQmGbS0:QzHjl2F6sXA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=Bk0ycQmGbS0:QzHjl2F6sXA:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/Bk0ycQmGbS0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/3622601889870400349/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/01/video-getting-started-with-jounce-mvvm.html#comment-form" title="15 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3622601889870400349?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3622601889870400349?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/Bk0ycQmGbS0/video-getting-started-with-jounce-mvvm.html" title="Video: Getting Started with Jounce MVVM and MEF for Silverlight 5" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>15</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/01/video-getting-started-with-jounce-mvvm.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EHQHc6cSp7ImA9WhRUEUU.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-7930923709358725747</id><published>2012-01-21T18:47:00.000-05:00</published><updated>2012-01-21T18:47:11.919-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-21T18:47:11.919-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mvvm" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight 5" /><category scheme="http://www.blogger.com/atom/ns#" term="Jounce" /><title>Jounce 2.0 MVVM with MEF for Silverlight 5 Released</title><content type="html">&lt;p&gt;I'm pleased to announce the official release of Jounce 2.0 for Silverlight 5. There are quite a number of new features available that I'll review in this post. Most significantly, of course, the code base has been updated specifically to target Silverlight 5. A number of bug fixes, feature requests, and Silverlight 5 features have been added. The DLL for Jounce is still just under 100 KB for release so it remains nimble and lightweight. 
&lt;p&gt;There are two ways you can install the latest. Zip over to &lt;a href="http://jounce.codeplex.com/" target="_blank"&gt;Jounce at CodePlex&lt;/a&gt; to download the binaries and/or the full source. Or, jump into &lt;a href="http://nuget.org/" target="_blank"&gt;NuGet&lt;/a&gt; and install the &lt;strong&gt;&lt;a href="http://nuget.org/packages/Jounce" target="_blank"&gt;Jounce package&lt;/a&gt;&lt;/strong&gt;. The package is set up to wire in a default application. To get this functionality, follow these simple steps: 
&lt;ol&gt;&lt;li&gt;Create a new Silverlight application. I recommend the basic "Silverlight Application" template as I haven't tested with any others, and it doesn't matter if you host it in a web site and/or choose to use WCF RIA services.&lt;li&gt;Delete the &lt;code&gt;App.xaml&lt;/code&gt; and &lt;code&gt;MainPage.xaml&lt;/code&gt; files. Trust me on this one.&lt;li&gt;Jump into the package manager console and type &lt;code&gt;Install-Package Jounce&lt;/code&gt;.&lt;li&gt;Hold down CTRL and press F5 and you should see a welcome message. That's it. You are ready to write your Jounce application.&lt;/ol&gt;
&lt;p&gt;&lt;b&gt;What's New&lt;/b&gt; 
&lt;p&gt;The code base is now CLS compliant. 
&lt;p&gt;The application service used to wire Jounce now exposes some configuration properties. You can use this to have Jounce ignore unhandled exceptions (by default, it will intercept these and publish them as a message instead) and also to set the debug level. These used to be parsed from the parameters from the &lt;code&gt;object&lt;/code&gt; tag but obviously this did not make sense for OOB applications. 
&lt;p&gt;When dynamically loading XAP files (i.e. extension or plugin modules) you can specify a callback that Jounce will call to report progress. This allows you to have more control over the extension points and display a progress message to the end user for example.
&lt;p&gt;The processing of the XAP file URL was updated to allow query strings. This is a common method to dynamically serve up XAP files and/or to manage updates for OOB applications. Jounce used to choke on this but the code was updated to gracefully handle this when you specify the URL to the XAP to download.
&lt;p&gt;You no longer have to derive your view model from the &lt;code&gt;BaseViewModel&lt;/code&gt; class. The only requirement for the framework to work is for you to implement the &lt;code&gt;IViewModel&lt;/code&gt; interface. This will help developers who wanted to provide their own base class services and found it difficult due to the face you cannot derive from more than one base class (hey, I managed to sneak in a basic interview question). 
&lt;p&gt;You can specify an option using metadata to automatically call &lt;code&gt;Deactivate&lt;/code&gt; on your view model when the corresponding view is unloaded (i.e. if the &lt;code&gt;Unloaded&lt;/code&gt; event fires). This allows you to perform clean up automatically when the view goes out of scope.
&lt;p&gt;You can now map a view to a view model in three ways. You can export a &lt;code&gt;ViewModelRoute&lt;/code&gt;, you can fluently bind them using a new interface, and you can specify the view model in XAML. The new &lt;code&gt;MapToViewModel&lt;/code&gt; custom markup extension allows you to specify the view model name, whether you want a shared or non-shared copy, and whether the &lt;code&gt;Deactivate&lt;/code&gt; method should be called when the view is unloaded. This makes it possible to use templates that bind to new instances of view models. 
&lt;p&gt;There is additional support for the OOB windows. You can append parameters to the navigation payload or use some fluent extension methods to specify the title and size of a view and have it loaded into a separate window instead of a region. You can also raise events with a title to set the title of the HTML page (in browser) or OOB application (out of browser). To further support OOB, there are additional attributes you can query on the base view model to determine if the application is running out of browser and whether or not it is installed on the user machine. 
&lt;p&gt;There is a new class available called &lt;code&gt;CustomType&lt;/code&gt; that allows you to construct a dynamic type that is bindable to view models. For example, you might parse a JSON object and use this type to build up the object. It features methods to add new properties and fetch them and will also act as a dictionary with an indexer. It uses an underlying helper class that takes advantage of Silverlight 5's &lt;code&gt;ICustomTypeProvider&lt;/code&gt;. You can use the source as a template to build your own custom types (or derive from it instead). 
&lt;p&gt;I will update documentation and examples as I can moving forward. My book, &lt;a href="http://amzn.to/lobsl" target="_blank"&gt;Designing Silverlight Business Applications&lt;/a&gt;, has many examples of building applications using Jounce including WCF RIA. Thanks everyone for their patience and support of this project!
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-7930923709358725747?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=BG19Jbsh2o0:aE6enb81OxA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=BG19Jbsh2o0:aE6enb81OxA:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=BG19Jbsh2o0:aE6enb81OxA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=BG19Jbsh2o0:aE6enb81OxA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=BG19Jbsh2o0:aE6enb81OxA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=BG19Jbsh2o0:aE6enb81OxA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=BG19Jbsh2o0:aE6enb81OxA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=BG19Jbsh2o0:aE6enb81OxA:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/BG19Jbsh2o0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/7930923709358725747/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/01/jounce-20-mvvm-with-mef-for-silverlight.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7930923709358725747?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7930923709358725747?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/BG19Jbsh2o0/jounce-20-mvvm-with-mef-for-silverlight.html" title="Jounce 2.0 MVVM with MEF for Silverlight 5 Released" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/01/jounce-20-mvvm-with-mef-for-silverlight.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UBQn4yfip7ImA9WhRWGUo.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-6919125036714531900</id><published>2012-01-07T18:33:00.001-05:00</published><updated>2012-01-07T18:34:13.096-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-07T18:34:13.096-05:00</app:edited><title>CRUD it’s now CQRS … or is it?</title><content type="html">&lt;p&gt;In 1983 author James Martin published a book called &lt;a href="http://www.amazon.com/gp/product/0135505828/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0135505828" target="_blank"&gt;Managing the Data-Base Environment&lt;/a&gt;. It’s interesting the term &lt;em&gt;database&lt;/em&gt; is hyphenated in the title; it hadn’t quite settled down as a mainstream term yet. I have not read this book myself, but my understanding is that he presented the concept of the “CRUD Matrix” for engineering how an application performs Create, Read, Update, and Delete operations against the database. Regardless of how the term was first coined, it has gained popularity and is in widespread use today.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-YJpSCGBRp0E/TwjWO4HCLxI/AAAAAAAAAcg/qWJ4OpePcr8/s1600-h/crudmatrix%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="crudmatrix" border="0" alt="crudmatrix" src="http://lh5.ggpht.com/-jo91d95ekeA/TwjWPG3854I/AAAAAAAAAco/3i48_LSt9UI/crudmatrix_thumb%25255B2%25255D.png?imgmax=800" width="556" height="203"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;CRUD is a model that has existed for decades. A large number of software systems can be classified as a simple combination of CRUD + validation. This is why so many scaffold frameworks provide nearly the same pattern: list records, select record, view detail, edit or delete, and validate a bit along the way. If you are working on an application that follows the pattern of view data, pull it in, do stuff with it, then push it back out, you have an amazing number of options to build it quickly and easily with little ritual or ceremony involved. I see this approach quite often in the development of consumer-facing applications. One track focuses on the engine to present the content to the consumer while the backend system to configure and set up content is quickly generated using a data-driven tool.&lt;/p&gt; &lt;p&gt;If all software operated in CRUD mode many of us might not be employed because it would be so easy to pull CRUD instances out of the assembly line. Software can be quite complex, however, and often models more complex business processes that introduce workflows and state machines that aren’t easily captured with the traditional CRUD model. This fact has led to movements like DDD or Domain-Driven Design, which according to the &lt;a href="http://domaindrivendesign.org/resources/what_is_ddd" target="_blank"&gt;community website&lt;/a&gt; is &lt;em&gt;not&lt;/em&gt; a framework or technology but a “way of thinking and a set of priorities.” You focus on the business model and domain, paying attention to important details such as having a common vocabulary that everyone can use to describe the requirements without ambiguity. The source for this concept is defined in the popular “blue book” by Eric Evans called &lt;a href="http://www.amazon.com/gp/product/0321125215/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321125215" target="_blank"&gt;Domain-Driven Design&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;A set of new patterns for manipulating data has also emerged to challenge the traditional CRUD model. You can go back to Bertrand Meyer’s Command Query Separation and then examine more recent Command Query Responsibility Segregation (CQRS) pattern by Greg Young to start digging into these principles. A number of implementations exist, including the concept of Event Sourcing. All of these are great patterns to learn and understand as part of your software development toolbox. &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-s34fofOYAgc/TwjWPWYHtdI/AAAAAAAAAcw/nNwgftoIwec/s1600-h/cqrs%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="cqrs" border="0" alt="cqrs" src="http://lh3.ggpht.com/-UG2XgGxilaY/TwjWPnbU74I/AAAAAAAAAc4/ia4alzDjqs0/cqrs_thumb%25255B1%25255D.png?imgmax=800" width="490" height="239"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;While the paradigm shift away from traditional CRUD approaches is refreshing, it can also be problematic. There is always the risk of falling victim to the “flavor of the day.” When I began building Silverlight applications, I was reluctant to fully embrace the MVVM pattern because it was consistently hyped as “the way to go” without very much substance around &lt;em&gt;why&lt;/em&gt; it was the way to go. I kept sorting through the catchy phrases like “decoupled code” and “SOLID principles” trying to find the value and bottom line for using this pattern, but it wasn’t until I implemented it myself and observed it in practice through several projects that I was able to finally decide it made sense. My teams were able to develop software faster through parallel workflows and the fact that I could engage an entire design team at the same time I was building the application rather than forcing the project into a sequential workflow was the real benefit I found in addition to the support for testing.&lt;/p&gt; &lt;p&gt;I’ve watched a similar trend with CQRS. Like MVVM, many people are declaring it “too complex” when in fact a proper implementation can be quite simple. Just like the MVVM cops appeared one day and starting writing tickets when developers didn’t completely eliminate their code-behind files, I see some CQRS police saying “if you’re not doing it this way, it’s not CQRS.” In many cases that may be correct, but I think it also undermines the spirit of the pattern. In some cases the pure implementation is exactly what is needed … but is it a new rule that everything must go this route? &lt;/p&gt; &lt;p&gt;I think you’ll find the strongest proponents and advocates for the pattern will be the first to say you should use the right tool for the right job. In my &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321810414" target="_blank"&gt;book about designing LOB Silverlight applications&lt;/a&gt; I added a controller class to an application that is mostly based on the MVVM model. I also include examples with logic in the code-behind. To some this may seem like sacrilege but in fact these cases were the right tool for the right job: they solved the problem while keeping it simple without compromising the ability to test the application. &lt;/p&gt; &lt;p&gt;I learned about the danger of “either-or” thinking back when I was a personal trainer and had an online coaching practice. I found many clients would get stuck in the either-or mentality. For example, “either I completely eliminate soda or my diet is blown.” Rather than, say, cutting back to just one glass a day for awhile. When traveling, I’d hear, “I can’t get my steamed chicken breast and broccoli so I’m just going to get a big pile of junk from a fast food restaurant” instead of looking for healthier options. “The only thing we had to eat was pizza.” Well, sometimes that happens – but instead of eating fifteen slices, why not just eat one? When I taught clients it is okay to compromise – if your workout calls for free weights but your hotel only has dumbbells, go ahead and train with what you have and get a workout done rather than using it as an excuse to sit in the hot tub for an hour – they had tremendous breakthroughs and were able to achieve a true lifestyle change rather than getting stuck in a diet cycle that was doomed to fail and send them back into old habits.&lt;/p&gt; &lt;p&gt;What does this have to do with software? I think quite a bit. You don’t have to take an either-or approach to building applications, either. For example, it’s not a question of using the entire Prism library or Enterprise Library in an application. It’s perfectly valid to pull out the parts you need – maybe the command implementation from Prism and the logging application block from the Enterprise Library – without overcomplicating the project. When you are looking at patterns, it’s fine to create something that is a hybrid if it fits the needs of your application.&lt;/p&gt; &lt;p&gt;Back to CQRS. I think Microsoft has provided some incredible tools for exposing data as services. With the combination of the &lt;a href="http://www.asp.net/entity-framework" target="_blank"&gt;Entity Framework&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/data/bb931106" target="_blank"&gt;WCF Data Services&lt;/a&gt; I can create a set of REST-based services within minutes that are consumable by Silverlight, Windows 8 applications, iPads, iPhones, Windows Phones, RIM devices and Android phones and tablets. It’s just that easy. Unfortunately, while the tools also support CRUD operations (and even provide places you can hook into for validation) it doesn’t always integrate well with a domain-driven approach to the application design. That means it’s off the table, right? CQRS is about having different databases, right? &lt;/p&gt; &lt;p&gt;I’d say, “Wrong” on both counts. If the model works well for querying data, configure it to allow queries and get your read operations up and running in minutes. Sometimes over 80% of your application may be about querying and displaying data, so why not keep it simple and expose it in a way that is easy to expand to other platforms when and if needed? &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-1PI9SHUPQRQ/TwjWP5Ewv8I/AAAAAAAAAdA/-DKMVz8NLH0/s1600-h/dataflow%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="dataflow" border="0" alt="dataflow" src="http://lh5.ggpht.com/-rwe8ktYRMU0/TwjWQJ-MOVI/AAAAAAAAAdI/y8uk4CrlTt4/dataflow_thumb%25255B1%25255D.png?imgmax=800" width="358" height="241"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;But what about updates? &lt;/p&gt; &lt;p&gt;The updates don’t have to follow the same set of interfaces if you don’t want them to. It’s perfectly valid to expose a REST interface or even a RPC-based interface that takes commands rather than “update operations.” Why not? You may have a workflow engine backed by state machines and queues that implement Event Sourcing, and that still doesn’t mean you can’t expose the read interface for your data using WCF Data Services out of the box. &lt;/p&gt; &lt;p&gt;My point is that CQRS provides what I think is a very valuable insight: that how you read and query data is probably very different from how you manage, update, and manipulate data. You don’t have to have a picture-perfect implementation of CQRS to take advantage of this concept – it may be as simple as looking at a different set of interfaces and implementing them using different technologies in the stack. I’ve built implementations based on this philosophy that still have one database and one data model using the Entity Framework but provide multiple implementation paths. They allow me to quickly and easily update the model while keeping the code simple and easy to both understand and maintain. &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-QZF2ziodXKQ/TwjWQZLnqkI/AAAAAAAAAdQ/a4wuDnvuHUM/s1600-h/hybridcqrs%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="hybridcqrs" border="0" alt="hybridcqrs" src="http://lh6.ggpht.com/-gG4YxWVvi8Y/TwjWQ39-BBI/AAAAAAAAAdY/hK1YsV1eyOU/hybridcqrs_thumb%25255B1%25255D.png?imgmax=800" width="439" height="532"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;There are some exciting new patterns and approaches to building software that developers should be aware of, but it’s important to look at these as new tools, not new toolboxes. During decades of enterprise software development I’ve rarely watched the toolbox change – it’s almost always been about adding new tools and throwing old ones out. I still see applications that will benefit from the traditional CRUD model and get overly complicated when someone tries to force them into something different. To make a long blog post short: patterns should not be used to define your software, but rather to help solve the problems your software addresses.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-6919125036714531900?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=25gtA8NAuiE:WFoQNoidVyA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=25gtA8NAuiE:WFoQNoidVyA:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=25gtA8NAuiE:WFoQNoidVyA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=25gtA8NAuiE:WFoQNoidVyA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=25gtA8NAuiE:WFoQNoidVyA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=25gtA8NAuiE:WFoQNoidVyA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=25gtA8NAuiE:WFoQNoidVyA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=25gtA8NAuiE:WFoQNoidVyA:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/25gtA8NAuiE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/6919125036714531900/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2012/01/crud-its-now-cqrs-or-is-it.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6919125036714531900?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/6919125036714531900?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/25gtA8NAuiE/crud-its-now-cqrs-or-is-it.html" title="CRUD it’s now CQRS … or is it?" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-jo91d95ekeA/TwjWPG3854I/AAAAAAAAAco/3i48_LSt9UI/s72-c/crudmatrix_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2012/01/crud-its-now-cqrs-or-is-it.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMBQ344fip7ImA9WhRWEU0.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-65490572431438533</id><published>2011-12-28T08:56:00.001-05:00</published><updated>2011-12-28T16:07:32.036-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-28T16:07:32.036-05:00</app:edited><title>Windows 8 Slate Review</title><content type="html">&lt;p&gt;About a week ago, I purchased a &lt;a href="http://www.amazon.com/gp/product/B005OUQ9WO/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B005OUQ9WO" target="_blank"&gt;Samsung Series 7 Slate PC&lt;/a&gt; to learn more about the Windows 8 operating system and to test applications I will be developing primarily with C# and Xaml. The laptop ships with Windows 7 installed, but I quickly wiped the existing install and overlaid it with Windows 8. The process for the most part went smoothly. I had to acquire some Windows 7 drivers and install them in compatibility mode in order for the tablet to recognize orientation changes, and I still cannot get the hardware Windows start button or the accelerometer to work. I expected some issues like this as Windows 8 is still a preview OS.&lt;/p&gt; &lt;p&gt;I’ve used the combination of the slate and the operating system quite heavily over the past week and I wanted to take the time to share my impressions in a post while they are still fresh. I’m trying to focus this review more on the OS itself and will call out where I think there are substantial hardware differences.&lt;/p&gt; &lt;h2&gt;Summary&lt;/h2&gt; &lt;p&gt;Overall, I like it. I’ll preface that with the statement that I am a developer so my opinion is certainly biased compared to what consumers might think. The OS provides the perfect balance between a “total slate experience” which I consider to be watching movies, casual browsing, email, and news readers, and “power user features” like developing software or drilling into a complex Excel spreadsheet. All it takes is a simple external keyboard to efficiently write books and articles and even build software. While the new OS is in beta form and there are not many native applications to choose from, the backwards compatibility makes it possible to install any number of existing touch solutions. &lt;/p&gt; &lt;p&gt;Let me break down where this opinion comes from. I’ll start with the cons.&lt;/p&gt; &lt;h2&gt;The Bad&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Price&lt;/strong&gt; – this is what I believe still stands as the greatest barrier to general adoption by consumers. The price point is just too high. The idea it can run all of Windows may be appealing to businesses, but not to the average consumer who is comparing this against Android tablets, iPads, and newcomers like the Kindle Fire. If you pay a competitive price for a Windows slate today, you get an inferior product. The Samsung performs well but also is priced well above the nearest competition at well over $1,000.  &lt;li&gt;&lt;strong&gt;Power&lt;/strong&gt; – unfortunately I have yet to work with an Atom-based slate that performs well. My standard is to pull up Netflix and run a high definition movie full screen. On a Windows tablet this does several things. First, it loads the Silverlight plug-in and extends the browser environment, and second, it tests the combination of processing that takes place in the Netflix app and the graphics processing happening through the hardware. Unfortunately most of the devices fail miserably for this, and you have to go to an i-series chip. That gives you the power, but means a thicker tablet with a fan and vents.  &lt;li&gt;&lt;strong&gt;Battery&lt;/strong&gt; – this ties into the issues listed previously. While the battery is certainly longer than a lot of lap tops – I was watching full screen movies in HD and it lasted hours without draining – it does not go anywhere near the 8 – 10 hours users experience with competing tablets. I believe this is due mainly to the processor architecture and while the alternate system-on-chip processors probably will break this barrier, they will need to perform far better than what I’ve seen so far to make the experience worthwhile.  &lt;li&gt;&lt;strong&gt;Start Menu – &lt;/strong&gt;I like the start menu. The concept of live tiles is great, because it turns the start menu into an interactive, “at a glance” dashboard. However, it is not without flaws. First, “grouping” tiles together really doesn’t do anything for me except maybe organize them visually. I want a functional way to group so I can drill in. The idea is as few taps and swipes as possible, which means drilling down, not swiping across. Second, &lt;em&gt;everything&lt;/em&gt; ends up as a tile. This may be fine for me, a developer, who knows how to unpin and organize but will be overwhelming to the average consumer. If an install like Office drops fifteen apps, why not organize into a folder by default and have the folder appear on the start menu, and let me drill down and bring common applications back to the top as needed? After installing everything I needed to make the slate productive for me – Office, Live Essentials, etc. – the start menu became so huge I found myself doing nothing but swiping and swiping to get to what I needed.  &lt;li&gt;&lt;strong&gt;Task Switching&lt;/strong&gt; – Give me a break. Two experiences? The side swipe is fun to demo and cool when you have two applications, but come on, who really only ever runs two applications? After loading up about five or six applications, continuously swiping across to find what I want is ridiculous. What’s worse, there is no integration with the desktop applications. If you have Explorer, Word, and Outlook running, you get one swipe for “Desktop” and then must ALT+TAB to go between your desktop apps, then either swipe or hit the start button to get back into the Metro applications. Not a good experience. Why not provide an aero-like view or cover flow style preview of the applications when I swipe so I can quickly tap on the one I want? Even a grid of thumbs would be preferable to multiple manual swipes.  &lt;li&gt;&lt;strong&gt;Consistency&lt;/strong&gt; – While I like the features and customization options that are available, it’s a little weird that half of the control panel is Metro and the other half dumps you to the desktop and back into the familiar Windows 7 dialogs. Why not finish the experience and make it consistent? You also are shifted to the desktop every time you launch a desktop application, which annoyed me at first but I found I quickly got used to and didn’t mind as much – I’m more irritated about the lame experience trying to swap tasks  &lt;li&gt;&lt;strong&gt;Ribbons&lt;/strong&gt; – I get it. The ribbon is the Microsoft UI widget of the future. It’s appearing everywhere. I like the ribbon, and it makes sense in a lot of applications. While I resisted the newer Office releases in the beginning because of the new interface, after using it for years now I’ve come to enjoy it. But here’s a news flash: it’s not the same on a slate. On a touch-based device I want to have context where I touch. That means if I’m navigating the file system, I want to be able to tap on a file or folder and right there see my options and quickly tap through. It’s not a smooth experience to tap down there and then look up there to the ribbon and then find the right place on the ribbon to tap. May have worked well on the desktop, not so fun on the slate. This is weird too because it gives the impression of OS schizophrenia. In the “Metro” portion I have an experience highly tailored to touch that feels right, responsive, and is enjoyable. In the file system explorer for the same OS, suddenly I’m forced to a completely different paradigm that doesn’t feel natural at all. Was it two entirely different teams working on these features? Why are they so different? I don’t buy that it’s because “it’s part of the desktop experience” – no, it’s not. Anything I can reach in my slate is part of the slate experience, whether or not it happens to fall into what was the traditional desktop. &lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;The Good&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Boot Time – &lt;/strong&gt;while some may say competitive slates boot quickly, the fact that this boots so fast &lt;em&gt;and&lt;/em&gt; provides full-blown Windows capabilities to me is amazing. My slate literally boots in seconds – that’s from a complete shut down. It is fantastic and I no longer dread turning on my machine because I have to figure out something to kill time while it’s booting – it’s that fast.  &lt;li&gt;&lt;strong&gt;Windows&lt;/strong&gt; – some people argue this is not a feature and may be a detriment to slates, but I disagree. The fact it is full-blown Windows and not a trimmed-down version is why many customers want a Windows-based slate. It was a key driver for the project I did with &lt;a href="http://www.microsoft.com/casestudies/Case_Study_Detail.aspx?CaseStudyID=4000010773" target="_blank"&gt;Rooms-to-Go&lt;/a&gt;. I love it. I installed Office and can easily navigate through Word documents, PowerPoint, and Excel. Sure, sometimes it requires using a keyboard, but the option is there. It gives me my built-in Windows security, allows me to use policies and gives me access to a ton of software that simply isn’t available on competing slates.  &lt;li&gt;&lt;strong&gt;Backwards Compatibility&lt;/strong&gt; – while this is just a beta the backwards compatibility so far has been outstanding. I’ve not had an issue installing any Windows 7 productivity software I wish to use. Even drivers for the Slate that aren’t yet available in Windows were successfully installed using compatibility mode. My &lt;a href="http://www.amazon.com/gp/feature.html/?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=ur2&amp;amp;docId=1000426311&amp;amp;camp=1789&amp;amp;creative=390957" target="_blank"&gt;Amazon Kindle for PC&lt;/a&gt; application works beautifully so there’s no need to pick up the hardware, I’ve got my “Kindle” right here. I’ve also had a lot of fun playing with the applications that ship with the &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=17368" target="_blank"&gt;Microsoft Touch Pack for Windows 7&lt;/a&gt; that uses &lt;a href="http://www.microsoft.com/surface/en/us/default.aspx" target="_blank"&gt;Microsoft Surface&lt;/a&gt; technology.  &lt;li&gt;&lt;strong&gt;Silverlight&lt;/strong&gt; – there was a lot of fuss about Silverlight and it being a dead-end but I’m happy to share it is not only fully supported on the slate, but shines. Some of the best applications I have aren’t written for Windows 8; they are written in Silverlight and run fine as Out-of-Browser (OOB) applications on the slate. Some that stand out are the &lt;a href="http://www.usatoday.com/webapps/windowstouch/" target="_blank"&gt;USA Today Windows Touch&lt;/a&gt; application, &lt;a href="http://www.mosaicbytribune.com/" target="_blank"&gt;Mosaic by Tribune&lt;/a&gt;, and &lt;a href="http://www.telerik.com/products/fdeck.aspx" target="_blank"&gt;Telerik’s Facedeck Silverlight Client for Facebook&lt;/a&gt;. Oh, did I mention I can just chill at night with headphones and watch my favorite Netflix movies in full screen high definition?  &lt;li&gt;&lt;strong&gt;Metro&lt;/strong&gt; – I like Metro. There are things that I believe could be improved, but to me the advantages include:  &lt;ul&gt; &lt;li&gt;Live Tiles create a true “dashboard” and at-a-glance experience, showing me insights without having to open an application. The tiles just need a better way to organize them.  &lt;li&gt;The Metro guidelines (no pop-ups, overlapping windows, etc.) make for a very crisp, clean, enjoyable experience. I am able to easily navigate between applications and they are very responsive. The task switching must be improved, however, and better integrated with the desktop experience.  &lt;li&gt;Charms and Application Bars to me make sense and once you understand the gestures make it very easy and consistent to navigate within applications. I really found the slow swipe from the right to get a full menu is something I use a lot, and enjoy the at-a-glance signal, battery, and time in addition to quick-jumps to other areas.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;Keyboard – &lt;/strong&gt;the Windows 8 keyboard is awesome. It’s nice and big and easy to type. I have long, complicated passwords and tapping them out is a breeze. My only gripe is the fact that you have to switch to get the numeric keyboard which can slow that down. The highlights and sound provide just the right amount of feedback to make the typing feel natural. The split keyboard is awesome for some major thumb-typing while grasping the sides of the tablet.  &lt;li&gt;&lt;strong&gt;Pen and Handwriting Recognition&lt;/strong&gt; – the pen is very powerful. I wanted to spend some time with family while I was editing the final chapters of my &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=cei0e-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321810414" target="_blank"&gt;Designing Silverlight Business Applications&lt;/a&gt; book, so I settled down in the family room with my slate and pen. To my surprise, I was able to be very productive. It was easy to highlight with the pen, and the handwriting recognition was superb – I very rarely had to correct it’s interpretation and my handwriting is abysmal. I was able to have a productive, casual editing session without lugging around a laptop or even pulling out a keyboard. The combination of handwriting and touch makes for a very powerful and productive experience.  &lt;li&gt;&lt;strong&gt;Search&lt;/strong&gt; – while I still feel the tiles could be better organized in the start menu, I love the integrated search. It’s fast and easy to use and the fact you can search within a context and even pass searches to other applications is awesome (sorry, can’t think of a better way to say it).  &lt;li&gt;&lt;strong&gt;IE10&lt;/strong&gt; – this may be strange coming from someone who listed Silverlight as an advantage when the IE10 Metro implementation does not allow plug-ins, but let’s face it: 2011 was the year of HTML5 and it is rapidly growing with adoption. I have no qualms about switching to my desktop IE version to run Silverlight applications when most of them are OOB applications that I can launch with a single touch from the start menu anyway. For most web sites, the built-in IE10 browser is all I need. It provides a great browsing experience, renders well, and provides all of the interaction I need. I use the built-in browser often and enjoy the browsing experience – I’ve even started to use YouTube in HTML5 mode although not all videos are available and you have less control over the experience. I especially like being able to pin sites from IE10 to my start menu.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;As you can see, there are a lot of pros to weigh against the cons. In summary, I’m very pleased with where the slate experience is going but I’m also concerned. I’m a power user – a developer – so I like falling back to heavy desktop applications, don’t mind doing a little extra to get around, and also am used to shelling out more dollars for my toys than average consumers might be willing to. I think the biggest obstacle to overcome is providing performance at a lower cost to increase value and get rid of fans and fat form factors. The Metro experience needs a bit of work before I think my grandmother, grandfather, or niece will be as comfortable with it as they are grabbing an iPad, but I don’t think it’s an impossible task. I’m very excited to see the upcoming beta release that is rumored for February 2012 to see how well Microsoft listened and what steps they were willing to take to improve the quality of the product.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-65490572431438533?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=QMutRZforSo:aVaV-w1Dh8Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=QMutRZforSo:aVaV-w1Dh8Q:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=QMutRZforSo:aVaV-w1Dh8Q:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=QMutRZforSo:aVaV-w1Dh8Q:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=QMutRZforSo:aVaV-w1Dh8Q:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=QMutRZforSo:aVaV-w1Dh8Q:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=QMutRZforSo:aVaV-w1Dh8Q:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=QMutRZforSo:aVaV-w1Dh8Q:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/QMutRZforSo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/65490572431438533/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2011/12/windows-8-slate-review.html#comment-form" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/65490572431438533?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/65490572431438533?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/QMutRZforSo/windows-8-slate-review.html" title="Windows 8 Slate Review" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>8</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2011/12/windows-8-slate-review.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4MRHw-cSp7ImA9WhRQFU4.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-7097014024839371275</id><published>2011-12-09T15:10:00.000-05:00</published><updated>2011-12-10T11:03:05.259-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-10T11:03:05.259-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="silverlight 5" /><title>Silverlight 5 Released: Myth vs. Fact</title><content type="html">&lt;p&gt;It is very exciting to see the release of Silverlight 5 today, despite all of the rumors flying around the Web. Read the original release announcement from the Silverlight Team &lt;a href="http://blogs.msdn.com/b/silverlight/archive/2011/12/09/silverlight-5-available-for-download-today.aspx" target="_blank"&gt;here&lt;/a&gt;. This is proof positive the team made a commitment to release a new version by the end of the year and stuck to it. This release offers major functionality over prior releases and is something I believe has the potential to revolutionize development for line of business applications, or I wouldn't be &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321810414" target="_blank"&gt;writing a book about it&lt;/a&gt;. You can download the release &lt;a href="http://www.silverlight.net/downloads" target="_blank"&gt;here&lt;/a&gt; (note that sometimes the servers may take time to synchronize, so if you are not seeing the link, wait a little awhile and refresh ... it will eventually appear for you). 
&lt;p&gt;My blog has been covering this for quite some time so I thought it would make sense to recap the coverage I've already provided as well as address some myths vs. facts about this release.
&lt;p&gt;First, a summary of articles I've posted that relate to Silverlight 5:
&lt;ul&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/09/silverlight-5-rc-using-task-parallel.html" target="_blank"&gt;Using the Task Parallel Library (TPL)&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/07/presentation-silverlight-5-for-line-of.html" target="_blank"&gt;My presentation (video) on LOB applications using Silverlight 5&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/04/creating-markup-extension-for-mef-with.html" target="_blank"&gt;Creating a Markup Extension for the Managed Extensibility Framework&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/08/silverlight-5-incompatibility-play-by.html" target="_blank"&gt;Backwards Compatibility and Playing by the Rules&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/05/using-icustomtypeprovider-in.html" target="_blank"&gt;Using ICustomTypeProvider to Dynamically Display JSON Data&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/10/using-jounce-navigation-to-create.html" target="_blank"&gt;Using Jounce Navigation to create Out-of-Browser Child Windows&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/09/silverlight-5-rc-released-using-pinvoke.html" target="_blank"&gt;Using p/Invoke&lt;/a&gt;&lt;li&gt;&lt;a href="http://csharperimage.jeremylikness.com/2011/04/text-search-with-ancestor-binding-and.html" target="_blank"&gt;Text Search, Ancestor Binding, and Child Windows&lt;/a&gt;&lt;/ul&gt;
&lt;p&gt;I will also be releasing a new version of my &lt;a href="http://jounce.codeplex.com/" target="_blank"&gt;Jounce MVVM+MEF Framework&lt;/a&gt; that fully supports the new capabilities of Silverlight 5 over the next few weeks. You can download the latest source to preview this functionality and I'll consolidate into a 2.0 release probably right after the holidays.
&lt;p&gt;Let's tackle some myths:
&lt;p&gt;&lt;h2&gt;Myth: Silverlight is dead.&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Fact:&lt;/b&gt; Silverlight 5 has just been released. The team has been working hard to implement new features and address issues uncovered through internal and external builds like the beta and release candidates. This release contains significant functionality that make it an ideal platform for building Line of Business applications. Microsoft has also promised to &lt;a href="http://support.microsoft.com/gp/lifean45" target="_blank"&gt;support this version through 2021&lt;/a&gt;. That's quite a bit of life!
&lt;p&gt;&lt;h2&gt;Myth: Silverlight has no Future.&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Fact:&lt;/b&gt; We're not sure if Silverlight will have a future release, as Microsoft has not formally addressed this and that is definitely a possibility. That doesn't mean it doesn't have a future. There are plenty of cases where the current version will meet the demands of users sufficiently to warrant future development. The next IDE slated for release, Visual Studio 11, has Silverlight support so the tools are not going away any time soon. Silverlight runs perfectly fine on the new Windows 8 desktop so applications developed using this version will not be obsolete when users move to Windows 8, although by all predictions Windows 7 is going to be around for a long, long time. The biggest enemy of Silverlight right now is not capability nor support, but speculation and rumor. 
&lt;p&gt;&lt;h2&gt;Myth: The Silverlight team gave up on Mac OSX, this release is for Windows/Internet Explorer only.&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Fact:&lt;/b&gt; Silverlight 5 is fully supported on Mac OSX and across multiple browsers. The new 3D features rely on DirectX and therefore are not available on the Mac OSX platform, and p/Invoke/COM obviously does not make sense because there is no counterpart. All of the core features including interactivity, printing, etc. are all fully supported as demonstrated by the release candidate (RC). You can see the full list of supported browsers and platforms &lt;a href="http://www.microsoft.com/silverlight/what-is-silverlight/" target="_blank"&gt;here&lt;/a&gt;. 
&lt;p&gt;&lt;h2&gt;Myth: Silverlight is no longer the optimal choice for platform reach&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Fact:&lt;/b&gt; I believe this to be true when you extend reach to smartphones. For desktop applications that will traditionally run on Mac OSX, Windows, and Linux, I still see Silverlight 5 as the viable option for the first two. Obviously lack of Linux support rules that out but I have not found that to be an issue for line of business applications. Most businesses are still putting their heavy applications on Windows with a smaller percentage on Mac OSX and Silverlight provides phenomenal capabilities to build the application once and have it run on both platforms, even out-of-browser in occassionally disconnected scenarios. Silverlight is only a viable target for smartphones on the Windows Phone 7 platform. I don't believe this removes Silverlight as a player as it depends on the level of native touch you want for your application. A high-touch application will likely require developing with Silverlight for Windows Phone, Objective-C for iOS devices and Java for Android unless you are using a tool that provides multi-targeting like the Mono suite. On the other hand, if you can get away with less native touch and functionality, HTML5 is certainly a good option for building a mobile footprint once and having it function consistently across those surfaces. Keep in mind however that this does not mean you can build it once and have it run fine on your desktop targets - you'll still be developing different screens. The ability of Silverlight to connect to existing services like REST and WCF end points still makes it a very viable option for the desktop presentation layer even if the mobile footprints are written using an HTML5-based solution.
&lt;p&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;It's out, it's loaded with features, and it still has plenty of life left in it. Go out and grab the latest version of Silverlight and see for yourself! I'm interested in all comments and feedback below. Thanks!
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-7097014024839371275?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=rB9DDI9dUXw:o4RT0NLWK5g:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=rB9DDI9dUXw:o4RT0NLWK5g:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=rB9DDI9dUXw:o4RT0NLWK5g:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=rB9DDI9dUXw:o4RT0NLWK5g:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=rB9DDI9dUXw:o4RT0NLWK5g:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=rB9DDI9dUXw:o4RT0NLWK5g:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=rB9DDI9dUXw:o4RT0NLWK5g:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=rB9DDI9dUXw:o4RT0NLWK5g:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/rB9DDI9dUXw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/7097014024839371275/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2011/12/silverlight-5-released-myth-vs-fact.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7097014024839371275?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7097014024839371275?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/rB9DDI9dUXw/silverlight-5-released-myth-vs-fact.html" title="Silverlight 5 Released: Myth vs. Fact" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>4</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2011/12/silverlight-5-released-myth-vs-fact.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMFRX8zeip7ImA9WhRSGE0.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-7984739274319283020</id><published>2011-11-20T11:08:00.001-05:00</published><updated>2011-11-20T12:00:14.182-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-20T12:00:14.182-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="wcf ria" /><category scheme="http://www.blogger.com/atom/ns#" term="entity framework" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="large data sets" /><category scheme="http://www.blogger.com/atom/ns#" term="odata" /><title>Handling Extremely Large Data Sets in Silverlight</title><content type="html">&lt;p&gt;While writing Chapter 14 of my book, &lt;a target="_blank" href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=0321810414"&gt;Designing Silverlight Business Applications: Best Practices for Using Silverlight Effectively in the Enterprise (Microsoft .NET Development Series)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=cei0e-20&amp;l=as2&amp;o=1&amp;a=0321810414&amp;camp=217145&amp;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; I focused on an area that is quite common with line of business applications: extremely large data sets. In the example I generated almost 1,000,000 contact rows to illustrate how they would be managed by the Silverlight client. Like many software problems, there are many solutions; here is an excerpt of the three I demonstrated in the book.
&lt;p&gt;All of these solutions use the Entity Framework for data access. How that data access is projected to the client is illustrated bythree different patterns: OData (the straight services, not the checkbox on the WCF RIA Services tab), WCF RIA Services, and using the MVVM pattern. To simplify the examples I'm only focused on reads here. Writes do add a layer of complexity and change tracking, but I argue that the problem to solve there is not how to manage a large data set because anything the user actually interacts with is going to be a smaller order of magnitude. 
&lt;p&gt;&lt;h2&gt;RESTful OData&lt;/h2&gt;
&lt;p&gt;It's extremely easy to expose an OData end point from a .NET web application. You can simply add a new &lt;b&gt;WCF Data Service&lt;/b&gt; and then define what it has access to. In this example I have a &lt;code&gt;Contact&lt;/code&gt; table that looks like this:
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-OUWIyiAK0e4/Tskod-dI2CI/AAAAAAAAAbc/S3v4OqY0pjE/s1600/contacTable.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="272" width="400" src="http://3.bp.blogspot.com/-OUWIyiAK0e4/Tskod-dI2CI/AAAAAAAAAbc/S3v4OqY0pjE/s400/contacTable.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;After generating the data model, the Entity Framework provides this in my &lt;code&gt;ContactModel&lt;/code&gt; space:
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-EAqGBN0H53U/Tskow2OAO2I/AAAAAAAAAbo/JJMy1NhHc5o/s1600/contactModel.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="245" width="162" src="http://3.bp.blogspot.com/-EAqGBN0H53U/Tskow2OAO2I/AAAAAAAAAbo/JJMy1NhHc5o/s400/contactModel.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The underlying context that was generated is called &lt;code&gt;ContactEntities&lt;/code&gt; so for my OData service I can simply point to the underlying context and specify which collections are available and what access rights the client should have:
&lt;pre class="brush: csharp;"&gt;
public class ContactOData : DataService&amp;lt;ContactsEntities&gt;
{
    public static void InitializeService(DataServiceConfiguration config)
    {            
        config.SetEntitySetAccessRule("Contacts", EntitySetRights.AllRead);
        config.SetEntitySetPageSize("Contacts", 20);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }
}
&lt;/pre&gt; 
&lt;p&gt;Note I've specified a page size of 20 records so that the service doesn't return all 1,000,000 records at once. When I hit the service endpoint, I get this: 
&lt;pre class="brush: html;"&gt;
&amp;lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&amp;lt;service 
   xml:base="http://localhost:59389/ContactOData.svc/" 
   xmlns:atom="http://www.w3.org/2005/Atom" 
   xmlns:app="http://www.w3.org/2007/app" 
   xmlns="http://www.w3.org/2007/app"&gt;
  &amp;lt;workspace&gt;
    &amp;lt;atom:title&gt;Default&amp;lt;/atom:title&gt;
    &amp;lt;collection href="Contacts"&gt;
      &amp;lt;atom:title&gt;Contacts&amp;lt;/atom:title&gt;
    &amp;lt;/collection&gt;
  &amp;lt;/workspace&gt;
&amp;lt;/service&gt;
&lt;/pre&gt;
&lt;p&gt;This is all a client needs to begin navigating entities as the location of the first collection, &lt;code&gt;Contacts&lt;/code&gt;, is clearly specified. We can now navigate to the contacts and receive something like this: 
&lt;pre class="brush: html;"&gt;
&amp;lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&amp;lt;feed 
   xml:base="http://localhost:59389/ContactOData.svc/" 
   xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
   xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
   xmlns="http://www.w3.org/2005/Atom"&gt;
  &amp;lt;title type="text"&gt;Contacts&amp;lt;/title&gt;
  &amp;lt;id&gt;http://localhost:59389/ContactOData.svc/Contacts&amp;lt;/id&gt;
  &amp;lt;updated&gt;2011-11-20T16:24:05Z&amp;lt;/updated&gt;
  &amp;lt;link rel="self" title="Contacts" href="Contacts" /&gt;
  &amp;lt;entry&gt;
    &amp;lt;id&gt;http://localhost:59389/ContactOData.svc/Contacts(1)&amp;lt;/id&gt;
    &amp;lt;title type="text"&gt;&amp;lt;/title&gt;
    &amp;lt;updated&gt;2011-11-20T16:24:05Z&amp;lt;/updated&gt;
    &amp;lt;author&gt;
      &amp;lt;name /&gt;
    &amp;lt;/author&gt;
    &amp;lt;link rel="edit" title="Contact" href="Contacts(1)" /&gt;
    &amp;lt;category term="ContactsModel.Contact" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /&gt;
    &amp;lt;content type="application/xml"&gt;
      &amp;lt;m:properties&gt;
        &amp;lt;d:Id m:type="Edm.Int32"&gt;1&amp;lt;/d:Id&gt;
        &amp;lt;d:LastName&gt;Alford&amp;lt;/d:LastName&gt;
        &amp;lt;d:FirstName&gt;Lucius&amp;lt;/d:FirstName&gt;
        &amp;lt;d:Address&gt;Ap #363-9702 Sit Rd.&amp;lt;/d:Address&gt;
        &amp;lt;d:City&gt;Jordan Valley&amp;lt;/d:City&gt;
        &amp;lt;d:State&gt;CO&amp;lt;/d:State&gt;
        &amp;lt;d:Email&gt;mi.eleifend.egestas@mauriserateget.com&amp;lt;/d:Email&gt;
      &amp;lt;/m:properties&gt;
    &amp;lt;/content&gt;
  &amp;lt;/entry&gt;
  ...
  &amp;lt;link rel="next" href="http://localhost:59389/ContactOData.svc/Contacts?$skiptoken=20" /&gt;
&amp;lt;/feed&gt;
&lt;/pre&gt;
&lt;p&gt;Notice that it follows the standard Atom format. Every entry has a clear location including where to go to post updates ("edit"). The full data set includes 20 entries and then specifies a link to grab the next page. 
&lt;p&gt;Adding this to the Silverlight client is easy. You can add a service reference, discover it in the current solution and the client will be wired for you automatically. Using a &lt;code&gt;DataGrid&lt;/code&gt; that auto-generates the columns, I can write the following code behind: 
&lt;pre class="brush: csharp;"&gt;
public partial class ODataClient
{
    private readonly DataServiceCollection&amp;lt;Contact&gt; _contacts;
    private readonly ContactsEntities _context;
    private DataServiceQueryContinuation&amp;lt;Contact&gt; _nextPage;

    public ODataClient()
    {
        InitializeComponent(); 
        _context = new ContactsEntities(new Uri("../ContactOData.svc", UriKind.Relative));
        _contacts = new DataServiceCollection&amp;lt;Contact&gt;();
        _contacts.LoadCompleted += ContactsLoadCompleted;
        var query = _context.Contacts.IncludeTotalCount();
        _contacts.LoadAsync(query);
    }

    void ContactsLoadCompleted(object sender, LoadCompletedEventArgs e)
    {
        _nextPage = _contacts.Continuation;

        if (_nextPage == null)
        {
            NextPage.IsEnabled = false;
        }

        TotalCount.Text = e.QueryOperationResponse.TotalCount.ToString();
        Count.Text = _contacts.Count.ToString();
        dgContacts.ItemsSource = _contacts;
        dgContacts.UpdateLayout();            
    }

    void Button_Click(object sender, RoutedEventArgs e)
    {
        _contacts.LoadNextPartialSetAsync();
    }
}
&lt;/pre&gt;
&lt;p&gt;The fields hold references to the service. It is instantiated with a relative path to the end point. The query is extended to include a total count of records so it can be used to calculate page sizes, and the link to the next page is retrieved and stored for the continuation. When the user clicks the button to load the next block of records, the continuation is called to fetch the next page. The grid and button look like this:
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-bnnAefEwiFo/TskrdDAIwGI/AAAAAAAAAb0/8zShfp-a_Y4/s1600/contactsodata.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="296" width="400" src="http://4.bp.blogspot.com/-bnnAefEwiFo/TskrdDAIwGI/AAAAAAAAAb0/8zShfp-a_Y4/s400/contactsodata.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The example is a quick-and-dirty way to parse the OData stream but can be extended to include a proper paging control (instead of simply expanding the grid) as well as edit and update functionality. Now I'll show you how to do the same thing using WCF RIA. The obvious advantage with WCF RIA is that the code projection removes most of the manual steps you need to take. 
&lt;p&gt;&lt;h2&gt;WCF RIA Services&lt;/h2&gt;
&lt;p&gt;The domain service for WCF RIA simply maps operations like queries to the corresponding LINQ-to-Entities commands. This example is read-only so the full implementation looks like this:
&lt;pre class="brush: csharp;"&gt;
[EnableClientAccess]
public class ContactService : LinqToEntitiesDomainService&amp;lt;ContactsEntities&gt;
{       
    public IQueryable&amp;lt;Contact&gt; GetContacts()
    {
        return ObjectContext.Contacts.OrderBy(c =&gt; c.Id);
    }
}
&lt;/pre&gt;
&lt;p&gt;The service derives from the context for the contact database and the query simply orders the items to allow paging (the result set must be deterministic for paging to work). That's it on the server side. A metadata class is also generated that you can use to apply data annotations to specify column names, validations, etc.
&lt;p&gt;The client automatically has the WCF RIA classes "projected" which is a fancy way of saying the code is generated for the client. In fact, WCF RIA handles so much plubming that the WCF RIA client doesn't have to have a single line of code-behind. Instead, you can drop in a domain data source:
&lt;pre class="brush: html;"&gt;
&amp;lt;riaControls:DomainDataSource 
   AutoLoad="true" 
   d:DesignData="{d:DesignInstance Web:Contact, CreateList=true}"                             
   Height="0" 
   Name="contactDataSource" 
   QueryName="GetContacts" 
   Width="0"
   LoadSize="60" 
   PageSize="20"&gt;
    &amp;lt;riaControls:DomainDataSource.DomainContext&gt;
        &amp;lt;Web:ContactContext/&gt;
    &amp;lt;/riaControls:DomainDataSource.DomainContext&gt;
&amp;lt;/riaControls:DomainDataSource&gt; 
&lt;/pre&gt;
&lt;p&gt;By convention, &lt;code&gt;ContactService&lt;/code&gt; is renamed to &lt;code&gt;ContactContext&lt;/code&gt; on the client. The domain data service uses context as its data source. It is given some design-time data to generate the grid properly, the query to get the list of contacts is specified along with how many records to pre-fetch and how many to show on a page. A &lt;code&gt;DataGrid&lt;/code&gt; simply binds to this as the data source along with a &lt;code&gt;DataPager&lt;/code&gt;:
&lt;pre class="brush: html;"&gt;
&amp;lt;sdk:DataGrid AutoGenerateColumns="True" 
   ItemsSource="{Binding ElementName=contactDataSource, Path=Data}"/&gt;
&amp;lt;sdk:DataPager 
   Source="{Binding ElementName=contactDataSource, Path=Data}"/&gt;
&lt;/pre&gt;
&lt;p&gt;And that is it! It will handle computing total records, managing pages, and generating the grid. The result looks like this:
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-FIFya4azKyQ/TsktUmgT5BI/AAAAAAAAAcA/21iT6-ecuwo/s1600/contactswcfria.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="311" width="400" src="http://1.bp.blogspot.com/-FIFya4azKyQ/TsktUmgT5BI/AAAAAAAAAcA/21iT6-ecuwo/s400/contactswcfria.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;That provides what I would call the ultimate rapid development experience. It can literally take just five minutes to create the Entity Framework model, map the domain service, then drop the domain data source and grid controls on the client to have a fully functional application. Of course, as a developer you may want more control over how the application works and perhaps need to make sure this fits within your existing patterns. The most popular pattern for Silverlight development is Model-View-ViewModel (MVVM) so here is a quick view model to make it work:
&lt;p&gt;&lt;h2&gt;MVVM&lt;/h2&gt; 
&lt;p&gt;Instead of relying on WCF RIA you can abstract the data access layer using a pattern such as repository. This isn't a full implementation but the simple interface looks like this: 
&lt;pre class="brush: csharp;"&gt;
public interface IRepository
{
    void ProcessPage(int page, int pageSize, 
       Action&amp;lt;IEnumerable&amp;lt;Contact&gt;&gt; callback);
    int GetTotalPages(int pageSize);
}
&lt;/pre&gt;
&lt;p&gt;Now you can use a mock to test access to the repository and even swap layers if or when it is necessary. Here is an implementation that works directly with WCF RIA: 
&lt;pre class="brush: csharp;"&gt;
public class Repository : IRepository
{
    private int _totalCount;
    private readonly ContactContext _contactContext = new ContactContext();

    public Repository()
    {
        var query = (
                        from c
                            in _contactContext.GetContactsQuery()
                        select c).Take(1);
        query.IncludeTotalCount = true;
        _contactContext.Load(
            query,
            callback =&gt; { _totalCount = callback.TotalEntityCount; }, null);
    }

    public void ProcessPage(int page, int pageSize, 
        Action&amp;lt;IEnumerable&amp;lt;Contact&gt;&gt; callback)
    {
        var take = pageSize;
        var skip = pageSize*(page - 1);
        var query = (from c in _contactContext.GetContactsQuery()
                        select c).Skip(skip).Take(take);
        query.IncludeTotalCount = true;
        _contactContext.Load(
            query,
            cb =&gt;
                {
                    _totalCount = cb.TotalEntityCount;
                    callback(cb.Entities);
                }, null);
    }

    public int GetTotalPages(int pageSize)
    {
        return (_totalCount/pageSize) + 1;
    }
}
&lt;/pre&gt;
&lt;p&gt;Note when the repository is created, it queries for a single item just to grab the full count for computing the page size. This is updated each subsequent call for a page. The call to grab the page computes how many records to skip and take for a page and then executes the query. 
&lt;p&gt;A simple view model can be constructed that uses the repository: 
&lt;pre class="brush: csharp;"&gt;
public class ViewModel : INotifyPropertyChanged
{
    private List&amp;lt;Contact&gt; _contacts = new List&amp;lt;Contact&gt;();
    private readonly IRepository _repository;

    public int CurrentPage { get; set; }

    public int TotalPages { get; set; }

    public IActionCommand NextPage { get; set; }

    public IActionCommand PreviousPage { get; set; }

    public IEnumerable&amp;lt;Contact&gt; Contacts
    {
        get
        {
            if (_contacts.Count == 0)
            {
                Refresh();
            }

            return _contacts;
        }

        set { _contacts = new List&amp;lt;Contact&gt;(value); }
    }
}
&lt;/pre&gt;
&lt;p&gt;It exposes current page, total pages, commands to paginate and a list of the current contacts. The constructor sets up the initial conditions and sets a dummy page and page size in the design view:
&lt;pre class="brush: csharp;"&gt;
public ViewModel()
{
    Contacts = new List&amp;lt;Contact&gt;();
    NextPage = new ActionCommand&amp;lt;object&gt;(obj =&gt; GoToNextPage(),
                                            obj =&gt; CurrentPage &amp;lt; TotalPages);
    PreviousPage = new ActionCommand&amp;lt;object&gt;(obj =&gt; GoToPreviousPage(),
                                            obj =&gt; CurrentPage &gt; 1);

    if (!DesignerProperties.IsInDesignTool)
    {
        CurrentPage = 1;
        _repository = new Repository();                
    }
    else
    {
        CurrentPage = 2;
        TotalPages = 10;
    }
}
&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;Refresh&lt;/code&gt; method fetches the current page:
&lt;pre class="brush: csharp;"&gt;
private void Refresh()
{
    _repository.ProcessPage(
        CurrentPage,
        20,
        cb =&gt;
            {
                TotalPages = _repository.GetTotalPages(20);
                _contacts = new List&amp;lt;Contact&gt;(cb);
                RaiseChanges();
            });
}       
&lt;/pre&gt;
&lt;p&gt;The commands simply change the current page and call refresh. For example, the command to advance by one page:
&lt;pre class="brush: csharp;"&gt;
private void GoToNextPage()
{
    CurrentPage++;
    Refresh();
}
&lt;/pre&gt;
&lt;p&gt;Now the view model can be bound to a grid. In this example, the current page and page count are used to construct a very simple paging control. All of the information you need to make a full-blown control is available. The MVVM-based view looks like this: 
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-u9qqxSssWmU/TskwLbJksmI/AAAAAAAAAcM/l1JLfa1MX6s/s1600/contactmvvm.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="314" width="400" src="http://1.bp.blogspot.com/-u9qqxSssWmU/TskwLbJksmI/AAAAAAAAAcM/l1JLfa1MX6s/s400/contactmvvm.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;The ease with which it is possible to navigate a large data set from the client is one of the reasons I believe Silverlight is still a strong player in the Line of Business application space. More details and the full source code for this example will be available when my book publishes. As of this writing on November 20, 2011 it is discounted over 40% on Amazon when you pre-order a copy &lt;a href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=0321810414" target="_blank"&gt;from here&lt;/a&gt;. Thanks! 
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-7984739274319283020?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=D_p7wrT3qJk:HT7cyVjjSZY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=D_p7wrT3qJk:HT7cyVjjSZY:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=D_p7wrT3qJk:HT7cyVjjSZY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=D_p7wrT3qJk:HT7cyVjjSZY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=D_p7wrT3qJk:HT7cyVjjSZY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=D_p7wrT3qJk:HT7cyVjjSZY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=D_p7wrT3qJk:HT7cyVjjSZY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=D_p7wrT3qJk:HT7cyVjjSZY:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/D_p7wrT3qJk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/7984739274319283020/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2011/11/handling-extremely-large-data-sets-in.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7984739274319283020?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/7984739274319283020?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/D_p7wrT3qJk/handling-extremely-large-data-sets-in.html" title="Handling Extremely Large Data Sets in Silverlight" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-OUWIyiAK0e4/Tskod-dI2CI/AAAAAAAAAbc/S3v4OqY0pjE/s72-c/contacTable.png" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2011/11/handling-extremely-large-data-sets-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4BRHc-cSp7ImA9WhdaEk8.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-3982052249003413188</id><published>2011-10-21T15:20:00.001-04:00</published><updated>2011-10-21T15:22:35.959-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-21T15:22:35.959-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="silverlight navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="silverlight 5" /><category scheme="http://www.blogger.com/atom/ns#" term="out of browser" /><category scheme="http://www.blogger.com/atom/ns#" term="Jounce" /><category scheme="http://www.blogger.com/atom/ns#" term="child window" /><category scheme="http://www.blogger.com/atom/ns#" term="OOB" /><category scheme="http://www.blogger.com/atom/ns#" term="navigation" /><title>Using Jounce Navigation to Create OOB Child Windows in Silverlight 5</title><content type="html">&lt;p&gt;One of the reasons I prefer to manage navigation as an event, rather than a strongly typed interface or handler, is because it allows for so much flexibility and extensibility in the navigation pipeline. In my &lt;a href="http://jounce.codeplex.com/" target="_blank"&gt;Jounce framework&lt;/a&gt;, for example, the basic navigation event simply wires up an instance of a view to a view model and makes no presumptions about where that view belongs - it leaves positioning the view to the developer. The region manager simply listens for navigation events and passes the views off to region adapters without worrying about how they are wired, so it automatically handles the view simply by extending the pipeline by listening for the message as well. This same model makes it incredibly simple to place views in child windows using the new Silverlight 5 Out-of-Browser feature.
&lt;p&gt;The first thing I'll do is create a controller to listen to navigation messages. It will expect a specific parameter to be passed that indicates when the view should be passed to a window. If that parameter exists, it will use parameters for height, width, and title to spin up the new window. A more complete implementation would store those literals as constants. Here is the shell for the class that implements the listener and subscribes to it: 
&lt;pre class="brush: csharp;"&gt;
[Export]
public class WindowController : IEventSink&amp;lt;ViewNavigationArgs&gt;,
                                IPartImportsSatisfiedNotification
{
    [Import]
    public IEventAggregator EventAggregator { get; set; }

    [Import]
    public IViewModelRouter Router { get; set; }
    
    public void OnImportsSatisfied()
    {
        EventAggregator.SubscribeOnDispatcher(this);
    }
&lt;/pre&gt;
&lt;p&gt;Now the handler. The handler will check the parameters for a special "OpenInWindow" parameter that must be set to true. It will only respond when that's the case, and everything else goes through the normal view routing. Because the project uses region management, there is no conflict because these views will not be routed to specific regions. First, if the parameter doesn't exist, the method simply returns. Note the use of the Jounce extension methods that conveniently cast the parameter to a specific type:
&lt;pre class="brush: csharp;"&gt;
public void HandleEvent(ViewNavigationArgs publishedEvent)
{
    var parms = publishedEvent.ViewParameters;
    if (!parms.ContainsKey("OpenInWindow") ||
        !parms.ParameterValue&amp;lt;bool&gt;("OpenInWindow"))
    {
        return;
    }
}
&lt;/pre&gt;
&lt;p&gt;Next, the router is used to get the view model that is mapped to the view, then spin up a non-shared instance of the view and view model. This allows multiple instances to be created and therefore supports multiple windows with the same view/view model combination. The method to get the view takes an object for a parameter that it will set to the data context of the view. Jounce is smart enough to recognize when that object is a Jounce view model, and will take the additional steps of wiring in visual states and calling the &lt;code&gt;InitializeVm&lt;/code&gt; and &lt;code&gt;ActivateView&lt;/code&gt; methods on the view model. Notice that the parameters are passed into the view model as well - Jounce will pass these in when it attaches the view model to the view.
&lt;pre class="brush: csharp;"&gt;
var viewModelTag = Router.GetViewModelTagForView(
    publishedEvent.ViewType);
var viewModel = Router.GetNonSharedViewModel(viewModelTag);
var view = Router.GetNonSharedView(
    publishedEvent.ViewType,
    viewModel,
    publishedEvent.ViewParameters 
    as Dictionary&amp;lt;string, object&gt;);
&lt;/pre&gt;
&lt;p&gt;Finally, the window is opened with the view set as the content: 
&lt;pre class="brush: csharp;"&gt;
new Window
        {
            Title = parms.ParameterValue&amp;lt;string&gt;("WindowTitle"),
            Width = parms.ParameterValue&amp;lt;int&gt;("WindowWidth"),
            Height = parms.ParameterValue&amp;lt;int&gt;("WindowHeight"),
            Content = view,
            Visibility = Visibility.Visible
        };
&lt;/pre&gt;
&lt;p&gt;That's all there is to it. The controller must be imported somewhere to begin listening for events. Then you can simply export the view with a tag like &lt;code&gt;[ExportAsView("MyView")]&lt;/code&gt; and publish the navigation using the Jounce extension methods to turn the view tag into a navigation event and add parameters:
&lt;pre class="brush: csharp;"&gt;
var window = "MyView".AsViewNavigationArgs()
    .AddNamedParameter("OpenInWindow", true)
    .AddNamedParameter("WindowTitle", "My View Title")
    .AddNamedParameter("WindowHeight", 300)
    .AddNamedParameter("WindowWidth", 600);
EventAggregator.Publish(window);
&lt;/pre&gt;
&lt;p&gt;Of course you can get even more clever with how you obtain the title or set the sizes, and now opening a child window is not only as easy as publishing an event, but also fully testable in your view models because you can mock the controller for testing.This technique is demonstrated in detail in the chapter about OOB applications in &lt;a target="_blank" href="http://www.amazon.com/gp/product/0321810414/ref=as_li_ss_tl?ie=UTF8&amp;tag=cei0e-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399373&amp;creativeASIN=0321810414"&gt;Designing Silverlight Business Applications: Best Practices for Using Silverlight Effectively in the Enterprise (Microsoft .NET Development Series)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=cei0e-20&amp;l=as2&amp;o=1&amp;a=0321810414&amp;camp=217145&amp;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;.
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-3982052249003413188?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=VulUWjTzscQ:_Nfpc6mc9I0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=VulUWjTzscQ:_Nfpc6mc9I0:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=VulUWjTzscQ:_Nfpc6mc9I0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=VulUWjTzscQ:_Nfpc6mc9I0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=VulUWjTzscQ:_Nfpc6mc9I0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=VulUWjTzscQ:_Nfpc6mc9I0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=VulUWjTzscQ:_Nfpc6mc9I0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=VulUWjTzscQ:_Nfpc6mc9I0:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/VulUWjTzscQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/3982052249003413188/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2011/10/using-jounce-navigation-to-create.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3982052249003413188?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/3982052249003413188?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/VulUWjTzscQ/using-jounce-navigation-to-create.html" title="Using Jounce Navigation to Create OOB Child Windows in Silverlight 5" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2011/10/using-jounce-navigation-to-create.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UARH4_eyp7ImA9WhdbE0U.&quot;"><id>tag:blogger.com,1999:blog-8944256652433533647.post-8736114784895238506</id><published>2011-10-11T22:07:00.000-04:00</published><updated>2011-10-11T22:07:25.043-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-11T22:07:25.043-04:00</app:edited><title>Quick Tip: Design-Time Views for Regions</title><content type="html">&lt;p&gt;If you've worked with the &lt;a href="http://csharperimage.jeremylikness.com/2010/10/jounce-part-4-region-management.html" target="_blank"&gt;Region Management&lt;/a&gt; pattern before, one source of frustration can be the lack of a design-time view. While you can compose individual views to be designer-friendly, the aggregate views that mark regions often end up devoid of anything useful. A simple little trick, however, can change that. 
&lt;p&gt;You may be familiar with creating &lt;a href="http://csharperimage.jeremylikness.com/2011/03/clean-design-time-friendly-viewmodels.html" target="_blank"&gt;design-friendly view models&lt;/a&gt;, but the extensions for Blend work the same with views. For example, consider a main page that has a layout divided into regions that are marked by content controls, like this: 
&lt;pre class="brush: html;"&gt;
&amp;lt;ContentControl  VerticalAlignment="Center" Margin="20 0 0 0" region:ExportAsRegion.RegionName="SortRegion"/&gt;
&lt;/pre&gt;
&lt;p&gt;There may be one or many views that can fit in the content control, but having it completely empty just doesn't make a good design experience as you cannot tell how components will fit together. With just a little tweak, however, you can change that. Consider this approach instead: 
&lt;pre class="brush: html;"&gt;
&amp;lt;ContentControl  d:DataContext="{d:DesignInstance Views:SortView,IsDesignTimeCreatable=True}" Content="{Binding}"
VerticalAlignment="Center" Margin="20 0 0 0" region:ExportAsRegion.RegionName="SortRegion"/&gt;
&lt;/pre&gt;
&lt;p&gt;This simple change has done a few things. First, it binds an instance of a reference view to the data context of the control. The binding will only be invoked in the designer and will not be impacted during runtime. Second, the content control is set to the binding, which is the view in the designer, causing it to render the content. With just that simple tweak you now can see how a view will fit into the region!
&lt;p&gt;The view is created directly and is not recursively wired into the design-time experience, so any design-time data within the referenced view will &lt;i&gt;not&lt;/i&gt; appear. To get around that you'll need to create a mock view instead and create an instance of that. If the view isn't activated right away, the content control will end up hosting whatever it inherits from the data context of its parents, which may have undesired side effects, but in most cases you will likely activate the view that routes to the region before any artifacts are visible to the end user. If you need to, you can also manually set the data context (the "real" data-context, not the design-time one) to &lt;code&gt;{x:Null}&lt;/code&gt; to prevent it from inheriting anything at runtime.
&lt;p&gt;Finally, there is always the option to use a custom markup extension if you really need a more robust view. For me, the trade-off of making a simple tweak is worthwhile. 
&lt;p&gt;Here's the design-time view of a small control, showing sample data: 
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-gHWCMHBlmho/TpT07UI1VqI/AAAAAAAAAac/PYGu7cdrIiM/s1600/designview1.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="56" width="289" src="http://1.bp.blogspot.com/-gHWCMHBlmho/TpT07UI1VqI/AAAAAAAAAac/PYGu7cdrIiM/s400/designview1.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Here's the main page with nothing but regions and design-time views. While the design-time data isn't wired, the views fall into place and I can get a sense of the overall layout (click to see a larger image): 
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-gkPSMGVllEg/TpT1Ht8TtPI/AAAAAAAAAao/lirofopTkkg/s1600/designview2.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="118" width="400" src="http://4.bp.blogspot.com/-gkPSMGVllEg/TpT1Ht8TtPI/AAAAAAAAAao/lirofopTkkg/s400/designview2.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;And finally this is the same application at runtime: 
&lt;p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-mS4ZiD_5hkw/TpT1REPcKvI/AAAAAAAAAa0/cjd_gkLKKUY/s1600/designview3.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="104" width="400" src="http://3.bp.blogspot.com/-mS4ZiD_5hkw/TpT1REPcKvI/AAAAAAAAAa0/cjd_gkLKKUY/s400/designview3.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;So now you don't have to suffer from regions turning their backs on your designer. Enjoy!
&lt;p&gt;&lt;a href="http://jeremylikness.com/" title="Jeremy Likness"&gt;&lt;img border="0" src="http://jeremylikness.com/signature.gif" alt="Jeremy Likness" title="Jeremy Likness"/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;(c) 2011-2012 Jeremy Likness.&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8944256652433533647-8736114784895238506?l=csharperimage.jeremylikness.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=oJIFWWp_wAk:gDISZiztE9s:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=oJIFWWp_wAk:gDISZiztE9s:YwkR-u9nhCs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=YwkR-u9nhCs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=oJIFWWp_wAk:gDISZiztE9s:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=oJIFWWp_wAk:gDISZiztE9s:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=oJIFWWp_wAk:gDISZiztE9s:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?i=oJIFWWp_wAk:gDISZiztE9s:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=oJIFWWp_wAk:gDISZiztE9s:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/CSharperImage?a=oJIFWWp_wAk:gDISZiztE9s:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/CSharperImage?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/CSharperImage/~4/oJIFWWp_wAk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://csharperimage.jeremylikness.com/feeds/8736114784895238506/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://csharperimage.jeremylikness.com/2011/10/quick-tip-design-time-views-for-regions.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/8736114784895238506?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8944256652433533647/posts/default/8736114784895238506?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CSharperImage/~3/oJIFWWp_wAk/quick-tip-design-time-views-for-regions.html" title="Quick Tip: Design-Time Views for Regions" /><author><name>Jeremy Likness</name><uri>https://profiles.google.com/104681642850492486855</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-zVEO4BsSOjc/AAAAAAAAAAI/AAAAAAAAAAA/ocZyKfGEY-Y/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-gHWCMHBlmho/TpT07UI1VqI/AAAAAAAAAac/PYGu7cdrIiM/s72-c/designview1.png" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://csharperimage.jeremylikness.com/2011/10/quick-tip-design-time-views-for-regions.html</feedburner:origLink></entry></feed>

