<?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" gd:etag="W/&quot;A0QBSHk7fCp7ImA9WhRQGUw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228</id><updated>2011-12-14T22:22:39.704-05:00</updated><category term="SMF" /><category term="C#" /><category term="WindowsAPI" /><category term="Mobile" /><category term="Productivity" /><category term="MVVM" /><category term="SQL" /><category term="WCF" /><category term="Motivation" /><category term="OpenSearch" /><category term="Delphi" /><category term="Microsoft Tag" /><category term="Tools" /><category term="XML" /><category term="Encryption" /><category term="MetroStack" /><category term="Google Voice" /><category term="WPF" /><category term="CodeCamp" /><category term="Mercurial" /><category term="ASP.NET MVC" /><category term="Silverlight" /><title>Steven Hook's Blog</title><subtitle type="html">&amp;lt;%: Model.CleverDescription %&amp;gt;</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>29</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/StevenHook" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="stevenhook" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CEEDRXo9fyp7ImA9Wx9VFUs.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-1970479450643823571</id><published>2011-02-01T07:17:00.001-05:00</published><updated>2011-02-01T07:17:54.467-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-01T07:17:54.467-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>MVVM for non MVVM people : Part 2</title><content type="html">Picking up after &lt;a href="http://stevenhook.blogspot.com/2011/01/mvvm-for-non-mvvm-people-part-1.html" target="_blank"&gt;part 1&lt;/a&gt;, where our artistically challenged software developer just finished writing a view model. We will continue with the user interface designer where he will&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Create a beautiful and eye catching user interface.&lt;/li&gt;
&lt;li&gt;Use Blend Behaviors to handle button click events&lt;/li&gt;
&lt;li&gt;Define a special behavior that passes a property to the view model&lt;/li&gt;
&lt;/ul&gt;The UI artist is using Expression Blend. After several months of designing he ends up with this:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_W3WFfs_0QgY/TUf5TYV26ZI/AAAAAAAAAIQ/d_ul0B5-oWE/s1600-h/VideoPlayerView3.png"&gt;&lt;img alt="VideoPlayerView" border="0" height="341" src="http://lh4.ggpht.com/_W3WFfs_0QgY/TUf5UIYMOsI/AAAAAAAAAIU/-GQLEeIR3kY/VideoPlayerView_thumb1.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="VideoPlayerView" width="444" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
With a layout like this:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_W3WFfs_0QgY/TUf5U-DICGI/AAAAAAAAAIY/wy93a1mbWM4/s1600-h/VideoPlayerLayers3.png"&gt;&lt;img alt="VideoPlayerLayers" border="0" height="179" src="http://lh3.ggpht.com/_W3WFfs_0QgY/TUf5VddOOEI/AAAAAAAAAIc/avjmnWTKVig/VideoPlayerLayers_thumb1.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="VideoPlayerLayers" width="343" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Our artist did not graduate at the top of his class.&lt;br /&gt;
&lt;h3&gt;&lt;br /&gt;
&lt;/h3&gt;&lt;h3&gt;Wiring Up Commands on the View&lt;/h3&gt;&lt;br /&gt;
You need to first attach a DataContext to the UserControl. A DataContext will help the application bind to the commands we created and it is even helpful at design time when setting the bindings. You want to set the DataContext at the highest level you can so that all the child controls will have access to the DataContext as well. Select the [UserControl] or LayoutRoot in your layout and create a new DataContext from the properties window. You will see your view model (VideoPlayerViewModel) in the list of choices. This class was created in &lt;a href="http://stevenhook.blogspot.com/2011/01/mvvm-for-non-mvvm-people-part-1.html" target="_blank"&gt;part one&lt;/a&gt; of this post. Now we can reference those commands we created in the model.&lt;br /&gt;
To allow those commands to be executed you need to add a behavior to the element you want to make the command call. Click the PlayButton and add a behavior asset called “InvokeCommandAction”. Notice that it will become a child of the PlayButton.&lt;br /&gt;
&lt;br /&gt;
Click on the command in your layout. Set the EventName that will invoke the command to be “Click”. Now all you need to tell it is what command to invoke. Click the tiny box on the right of the command property and click “Data Binding”. The Data Context tab reveals the relevant properties you can bind to. In this case you want to bind to the PlayCommand on your model. You can just as easily edit commands straight through Xaml if you prefer. Repeat these steps for your Pause and Stop buttons.&lt;br /&gt;
&lt;br /&gt;
Now you have some great buttons but no media element source to control. The last command to hook up to the view is the MediaOpenedCommand. As you would expect, it is done the same way as the buttons only&lt;br /&gt;
with a different EventName. Select your MediaElement in the layout and add an InvokeCommandAction so that it is a child of the MediaElement. Change the EventName to be “MediaOpened” and set the command to be “MediaOpenedCommand” just as you did with the buttons. This just means as soon as the MediaElement has successfully loaded the source defined, invoke this action.&lt;br /&gt;
&lt;br /&gt;
This command will have a catch though. If you remember, our developer is expecting us to provide our MediaElement so that it knows how to control the video. We can send this information to the model with this “MediaOpenedCommand”. You need to send the loaded media element as parameter. In the InvokeCommandAction properties, click the show advanced properties arrow in Common Properties to get more info. Click the tiny advanced options box to the right of the “CommandParameter” property. This time, we want to bind using the element tab and select the MediaElement in your view. Not a property on the MediaElement, just the MediaElement object.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/_W3WFfs_0QgY/TUf5WA26seI/AAAAAAAAAIg/-34s_V51qQ0/s1600-h/VideoPlayerMediaOpenedParameter4.png"&gt;&lt;img alt="VideoPlayerMediaOpenedParameter" border="0" height="516" src="http://lh4.ggpht.com/_W3WFfs_0QgY/TUf5Zdof8RI/AAAAAAAAAIk/5BC1jxyc2LM/VideoPlayerMediaOpenedParameter_thum.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="VideoPlayerMediaOpenedParameter" width="549" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Once the command parameter is defined you are finished.&lt;br /&gt;
&lt;br /&gt;
You have just made the worst video player ever created, but you can feel good that you did it without writing any code behind and you were able to separate concerns between the developer and the user interface designer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-1970479450643823571?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/1970479450643823571/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2011/02/mvvm-for-non-mvvm-people-part-2.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1970479450643823571?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1970479450643823571?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2011/02/mvvm-for-non-mvvm-people-part-2.html" title="MVVM for non MVVM people : Part 2" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_W3WFfs_0QgY/TUf5UIYMOsI/AAAAAAAAAIU/-GQLEeIR3kY/s72-c/VideoPlayerView_thumb1.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DEcMQ309eyp7ImA9Wx9VFEw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-8559878835258892249</id><published>2011-01-30T14:34:00.000-05:00</published><updated>2011-01-30T14:34:42.363-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-30T14:34:42.363-05:00</app:edited><title>Mix11 Picks</title><content type="html">I just made my picks for &lt;a href="http://live.visitmix.com/"&gt;MIX 2011&lt;/a&gt; sessions. It is interesting to see the massive number of Silverlight sessions available. This MIX looks like it will have some great sessions that are going to be relevant to the work I am interested in.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/44"&gt;Advanced Styling and Templating for Silverlight and WPF&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/131"&gt;WCF Patterns and Practices for Silverlight&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/161"&gt;Microsoft Surface v2 – designing for the new form factor&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/34"&gt;It's Only A Game&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/169"&gt;Using Metro Motion Design To Improve App Performance&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/197"&gt;HTML 5 for .NET Pros&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/171"&gt;Building an ASP.NET MVC 3 Mobile Application&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/10"&gt;Fun with ASP.NET MVC 3 and MEF&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/122"&gt;WebMatrix, ASP.NET &amp;amp; Razor - The easiest and fastest way to creating websites and dynamic webpages for beginners &amp;amp; professionals.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://live.visitmix.com/OpenCall/Vote/Session/11"&gt;Coding Animation Across Silverlight, WPF, XNA and HTML5&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
Open Call voting closes February 4, 2011. What were your picks?&amp;nbsp;I wish I could make it in person this year but that ticket price is just a bit too much for me. I'm still really looking forward to the web sessions though.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-8559878835258892249?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/8559878835258892249/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2011/01/mix11-picks.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/8559878835258892249?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/8559878835258892249?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2011/01/mix11-picks.html" title="Mix11 Picks" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DEICRns_cSp7ImA9Wx9VEkw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-6828548607088533515</id><published>2011-01-28T07:08:00.001-05:00</published><updated>2011-01-28T07:09:27.549-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-28T07:09:27.549-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>MVVM for non MVVM people : Part 1</title><content type="html">In my recent explosion of Silverlight development I have seen the term &lt;a href="http://en.wikipedia.org/wiki/MVVM"&gt;Model View ViewModel&lt;/a&gt; being thrown around a lot. I really enjoy writing Silverlight apps so I am interested in technologies that make that experience better/easier.&lt;br /&gt;
&lt;br /&gt;
The MVVM pattern is easy to pick up for an ASP.NET MVC developer because both are working towards the same separation goals. While my use with MVVM has been relatively limited so far, I have found some great applications for it and I also recognize that it may not be the right tool for every Silverlight application.&lt;br /&gt;
I recently created a Silverlight Video Player from scratch for a presentation that follows the MVVM pattern and I thought it worked out great. I want to take you through that process now.&lt;br /&gt;
&lt;br /&gt;
It is easy to visualize the result. I just want a way to wire up a video player. When the user presses play on the video player I want it to invoke some command and execute some code. Knowing that, I want to make a command for each button or each action that might normally have code behind in Silverlight.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_W3WFfs_0QgY/TUKwaQ2nIzI/AAAAAAAAAIE/hMlongLatAQ/s1600-h/VideoPlayerMockup3.png"&gt;&lt;img alt="VideoPlayerMockup" border="0" height="272" src="http://lh5.ggpht.com/_W3WFfs_0QgY/TUKwa50jQ3I/AAAAAAAAAII/s2ZyG8STZEw/VideoPlayerMockup_thumb1.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="VideoPlayerMockup" width="474" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;br /&gt;
&lt;/h3&gt;&lt;h3&gt;Why Would You Do This?&lt;/h3&gt;&lt;br /&gt;
Because MVVM is a buzz word and employers like it when you know buzz words! That may be true, but some people are turned off of by buzz word topics. If you are one of those people, just try and think of MVVM as a separation of concerns between a UI &lt;i&gt;artist&lt;/i&gt; and a developer. You don’t want the artist messing around with your code, but if your code is in the code behind you do not have a choice. Your UI artist will be editing the xaml directly which will affect how the code behind file is generated. Alternatively, the UI developer does not want the untrained eye of the software engineer to alter the artist’s work.&lt;br /&gt;
There are also benefits with testing. Some may not find value in that benefit but you do if you regularly test code. MVC developers should appreciate and completely understand.&lt;br /&gt;
&lt;h3&gt;&lt;br /&gt;
&lt;/h3&gt;&lt;h3&gt;Getting Started&lt;/h3&gt;&lt;br /&gt;
There are a few general thoughts on how to get started. Some say to start with your view and create your model off of the components you can see that you need to wire up. For example, if you drop on a play, stop and pause button on your UI, you know that your model needs to support a play, stop, and pause command that the UI will call.&lt;br /&gt;
Others prefer to create the model before creating the UI. This way you can build the UI off of the public exposure of the model.&lt;br /&gt;
I actually prefer creating the view before the model, but in this case I will be creating the model before the UI.&lt;br /&gt;
&lt;h3&gt;&lt;br /&gt;
&lt;/h3&gt;&lt;h3&gt;Creating the Model&lt;/h3&gt;&lt;br /&gt;
To create the model you need to remember that the model is just a collection of commands that the view will be calling. Literally, they are commands! The command object descends from the ICommand interface. That means each of our commands will be implementing &lt;i&gt;CanExecute&lt;/i&gt; and &lt;i&gt;Execute&lt;/i&gt;. You’ll need to create a class that implements these (which is not difficult) or use a third party command. Either way, you need a way to create an ICommand descendant. I will be using the &lt;a href="http://www.galasoft.ch/mvvm/getstarted/" target="_blank"&gt;Mvvm Light Toolkit&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
As you have probably figured out by now, your model will be doing the direct &lt;i&gt;two way&lt;/i&gt; communication with the view. Because of this, the model class will need to descend from the &lt;i&gt;INotifyPropertyChanged&lt;/i&gt; interface. From there you can just go nuts and define your public interface. Just think of whatever you might need to do in your player. If you’re new to MVVM you might think it will only take a few simple video navigation commands to get this working, but you need to remember that the goal is to not have code behind. That means, you should not be writing code for loading or initializing either. If your model needs to grow to accommodate, that is fine.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:e6c03d9a-ef40-4623-aeb0-654274ca7f69" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 117px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ICommand PlayCommand { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ICommand PauseCommand { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ICommand StopCommand { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ICommand MediaOpenedCommand { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ICommand SetVideoSourceCommand { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Then your constructor can create the concrete implementation or you can use dependency injection or an Inversion of Control container if you prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:5aeddc93-a079-4d13-9feb-144b73bd9d69" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 148px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;PlayCommand &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; RelayCommand(PlayVideo, CanPlayVideo);
PauseCommand &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; RelayCommand(PauseVideo, CanPauseVideo);
StopCommand &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; RelayCommand(StopVideo, CanStopVideo);
MediaOpenedCommand &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; RelayCommand&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MediaElement&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;(MediaOpened, CanMediaOpened);
SetVideoSourceCommand &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; RelayCommand&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;(SetVideoSource, CanSetVideoSource);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Now we can get down to writing some code for those fancy commands. When conceptually thinking about how to tell the video how to play, you have to wonder, what is &lt;i&gt;the video&lt;/i&gt;? Video in Silverlight is displayed in a &lt;i&gt;MediaElement&lt;/i&gt;.&lt;i&gt; &lt;/i&gt;We will need one of those in our class.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:445876f7-46e5-4865-8881-f10089d4ffe0" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 38px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; MediaElement _mediaElement;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;The PlayVideo() method has a really easy implementation!&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:d6ef48a2-52d0-4895-af18-a72b38029d2d" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 88px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; PlayVideo()
{
    _mediaElement.Play();
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;If you want to make it more complicated you can… I like this implementation. From that I am guessing you can figure out what the implementation of the pause and stop buttons will be. One last thing to do for the play button, you will want to implement the CanPlayVideo() method. For me, I only want to play the video if it is not already playing.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:369ea2ec-8335-4512-81c1-0c5c521dbc78" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 118px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt;&lt;span style="color: black;"&gt; CanPlayVideo()
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    return&lt;/span&gt;&lt;span style="color: black;"&gt; (_mediaElement &lt;/span&gt;&lt;span style="color: black;"&gt;!=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;null&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="color: black;"&gt; 
            _mediaElement.CurrentState &lt;/span&gt;&lt;span style="color: black;"&gt;!=&lt;/span&gt;&lt;span style="color: black;"&gt; MediaElementState.Playing)
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;MediaOpenedCommand is intended to be invoked when the MediaElement has been loaded with a video. This code will need to remember what MediaElement has been loaded so the other commands can work properly. You can assume that the view will be passing in the MediaElement as the parameter. We set this requirement in the view models constructor when we passed the MediaElement type to the RelayCommand.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ecdbf4e8-b0b0-4725-a0d4-cfddf6e4062f" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 88px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; MediaOpened(MediaElement mediaElement)
{
    _mediaElement &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; mediaElement;
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;One command that may not be intuitive is the SetVideoSource() method. It is still simple though.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:cad938be-9c2f-429b-adf8-0bdc9a011a6a" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 94px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; SetVideoSource(&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; source)
{
    MediaSource &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; Uri(source, UriKind.Relative);
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;When the view calls the SetVideoSource command it will be passing a video source location in the form of string. This code will convert that to a Uri and set it to a public property on our model that we have not defined yet. Here it is:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:66bcc823-4b8d-4e96-bf36-faae64ea6fe9" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 281px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; Uri _mediaSource;
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; Uri MediaSource
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    get&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        return&lt;/span&gt;&lt;span style="color: black;"&gt; _mediaSource;
    }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    set&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
        _mediaSource &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; value;
        NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;MediaSource&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;);
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;This code makes me angry. It is so close to being an automatic property using { get; set; } but the NotifyPropertyChanged messes everything up! Not only that, but I do not like having to pass in “MediaSource” as a string to the changed method. I think there is a lambda equivalent but I have a short attention span and I lost interest when Googling it.&lt;br /&gt;
&lt;br /&gt;
Now for the confession: you do not really need to bind all UI elements to a command on a view model. You can bind the UI to anything on your model. It can be a string, Uri, a custom Silverlight type, or whatever you want as long as your view knows how to interpret the result. The commands are used for more of a method call where you are expecting an action to be performed (like the play button). You can use other types of binding to determine:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The duration of the video source &lt;/li&gt;
&lt;li&gt;The current location in the video timeline &lt;/li&gt;
&lt;li&gt;Does the video currently require buffering &lt;/li&gt;
&lt;li&gt;If the video is buffering, how much longer will it be buffering &lt;/li&gt;
&lt;/ul&gt;The list goes on, but really any information you want to show or bind to on your player is what you can define in your model.&lt;br /&gt;
&lt;br /&gt;
As a developer you can now tell the UI artist to slap on their squiglies, rainbows, and unicorns… or whatever it is they do. The cool part is that they can use your model and it is simple enough that they can even wire it up without writing code. That is sweet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-6828548607088533515?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/6828548607088533515/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2011/01/mvvm-for-non-mvvm-people-part-1.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/6828548607088533515?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/6828548607088533515?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2011/01/mvvm-for-non-mvvm-people-part-1.html" title="MVVM for non MVVM people : Part 1" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/_W3WFfs_0QgY/TUKwa50jQ3I/AAAAAAAAAII/s2ZyG8STZEw/s72-c/VideoPlayerMockup_thumb1.png?imgmax=800" height="72" width="72" /><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;AkEER3k_eyp7ImA9Wx9VEU4.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-5681713262844100654</id><published>2011-01-27T09:30:00.000-05:00</published><updated>2011-01-27T09:30:06.743-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-27T09:30:06.743-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="SMF" /><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><category scheme="http://www.blogger.com/atom/ns#" term="WCF" /><title>Watching Movies with WCF and Silverlight</title><content type="html">I had a request from a member of the &lt;a href="http://smf.codeplex.com/" target="_blank"&gt;Silverlight Media Framework&lt;/a&gt; community to write a Silverlight application that retrieves a list of videos from a WCF service and plays the video using SMFPlayer. The member also had a requirement where he wanted to be able to have a separate Listbox show his available movies and when you click on a movie in the list it should load the movie into the player. This all started when I made a suggestion in the “&lt;a href="http://smf.codeplex.com/Thread/View.aspx?ThreadId=237150" target="_blank"&gt;How to change Video Source&lt;/a&gt;” thread and I said:&lt;br /&gt;
&lt;blockquote&gt;&lt;em&gt;“I store information about videos in a SQL Server database. I have a large number of available videos that get loaded at various times in my application. To do this I am using WCF RIA Services. The idea is that I can make a call to a WCF Service to return me a list of my videos. Then my Silverlight assembly can process those videos into PlaylistItems that get fed to the SMF player.” –Steve Hook&lt;/em&gt;&lt;/blockquote&gt;I’m always happy to help if I can, and in this case I certainly can. Here is what you will learn in this tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/_W3WFfs_0QgY/TUF7uABC7DI/AAAAAAAAAHk/tm_YpQE_z5M/s1600-h/MoviePlayerNoTheme3.png"&gt;&lt;img alt="MoviePlayerNoTheme" border="0" height="287" src="http://lh3.ggpht.com/_W3WFfs_0QgY/TUF7uokPCZI/AAAAAAAAAHo/Iv6TRGq-8Ng/MoviePlayerNoTheme_thumb1.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="MoviePlayerNoTheme" width="676" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Using the Silverlight Media Framework player. &lt;/li&gt;
&lt;li&gt;Retrieve a list of Movies from a WCF service. &lt;/li&gt;
&lt;li&gt;Creating a playlist outside of the SMFPlayer. &lt;/li&gt;
&lt;li&gt;Changing the movie selection with a ListBox. &lt;/li&gt;
&lt;li&gt;Keeping a strong separation of concerns when retrieving movies for playback in Silverlight. &lt;/li&gt;
&lt;li&gt;Using data transfer objects to limit transfer sizes. &lt;/li&gt;
&lt;li&gt;Know when to use a Silverlight Class Library and when not to. &lt;/li&gt;
&lt;li&gt;Using ItemTemplates for generated ListBox items &lt;/li&gt;
&lt;li&gt;Basic MVVM using &lt;a href="http://mvvmlight.codeplex.com/" target="_blank"&gt;MVVMLight&lt;/a&gt; via &lt;a href="http://nuget.codeplex.com/" target="_blank"&gt;NuGet&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;The full code is also available at &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;&lt;a href="https://bitbucket.org/swhook52/stevenhookblogcode/src/e2c921606dee/MoviePlayer/" target="_blank"&gt;my blog’s bitbucket repository&lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;.&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;The Player&lt;/h3&gt;Create a Silverlight Application using Silverlight 4 and call it &lt;em&gt;MoviePlayer&lt;/em&gt;. Host it in a web application when you are prompted. The web project will default to being named &lt;em&gt;MoviePlayer.Web&lt;/em&gt;. It does not matter if you use ASP.NET or ASP.NET MVC or any other options. We will not be writing any web code. The test pages that are provided in the templates will be enough to demonstrate this example.&lt;br /&gt;
Make sure you already have the Silverlight Media Framework setup. You can download the binaries from their &lt;a href="http://smf.codeplex.com/releases/view/57991" target="_blank"&gt;download page&lt;/a&gt; or grab them from my &lt;a href="https://bitbucket.org/swhook52/stevenhookblogcode/src/e2c921606dee/MoviePlayer/" target="_blank"&gt;repository&lt;/a&gt;. Anyone who does Silverlight or WPF work knows that life is easier with &lt;a href="http://www.microsoft.com/expression/products/blend_overview.aspx" target="_blank"&gt;Expression Blend&lt;/a&gt;. I will be using Blend for most of my XAML but it will not be necessary for this tutorial. Now, you can open either Blend or Visual Studio and start working on the &lt;em&gt;MoviePlayer&lt;/em&gt; project. Open &lt;em&gt;MainPage.xaml&lt;/em&gt; and define two columns on the LayoutRoot. The first column will hold the video player. The second column will hold our external playlist. Drop on the SMFPlayer in the first column. Drop a GridSplitter and Grid with a listListBox in the second column.&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:774af2d8-9d5f-4b7d-a206-7ddf674436ec" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 300px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid &lt;/span&gt;&lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="LayoutRoot"&lt;/span&gt;&lt;span style="color: red;"&gt; Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="Black"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ColumnDefinition &lt;/span&gt;&lt;span style="color: red;"&gt;Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="0.673*"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ColumnDefinition &lt;/span&gt;&lt;span style="color: red;"&gt;Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="0.327*"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;smf:SMFPlayer &lt;/span&gt;&lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Player"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid
&lt;/span&gt;&lt;span style="color: red;"&gt;        Grid.Column&lt;/span&gt;&lt;span style="color: blue;"&gt;="1"&lt;/span&gt;&lt;span style="color: red;"&gt;
        Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="10,0,0,0"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ListBox &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;sdk:GridSplitter
&lt;/span&gt;&lt;span style="color: red;"&gt;        HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Left"&lt;/span&gt;&lt;span style="color: red;"&gt;
        Grid.Column&lt;/span&gt;&lt;span style="color: blue;"&gt;="1"&lt;/span&gt;&lt;span style="color: red;"&gt;
        Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="10"&lt;/span&gt;&lt;span style="color: red;"&gt;
        Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="#FF323232"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Those namespaces are pulled from:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:b2077d37-3ec3-49e3-ab6e-a75f99850ed9" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 56px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;xmlns:smf="http://schemas.microsoft.com/smf/2010/xaml/player"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;This will get you the basic layout of the page and we can come back to do the binding. If you were to run the application now you would see the video player with no video as well as a grid splitter that can change the size of the two columns. We know that we want to be using MVVM to bind our data to our views, so we can write some XAML in preparation for this. I like to write the view first because I feel that it creates a better, cleaner view model when you define the data the way the view would want to reference it. We know we want to provide the player a few things…&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;The playlist&lt;/strong&gt; – The SMFPlayer needs a playlist of every movie you want it to play even if you are not using the built in playlist viewer. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The current playlist item&lt;/strong&gt; – If you intend to change the currently playing movie from an external control (not from the built in playlist viewer from SMFPlayer) you will need some way of telling the player what movie you want to be watching. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Movies&lt;/strong&gt; – The list of movies you have available to watch. This is not to be confused with the playlist. Perhaps you store more information about each movie than you provide in a playlist item. This list of movies can be your external playlist as demonstrated in the right column of the example screenshot above. &lt;/li&gt;
&lt;/ul&gt;Writing binding support for the playlist items is simple. Modify your SMFPlayer to bind to these imaginary properties on our imaginary view model.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:8dc3d9fb-7507-4767-b0af-bbc1be0a29d3" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 94px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;smf:SMFPlayer
&lt;/span&gt;&lt;span style="color: red;"&gt;    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Player"&lt;/span&gt;&lt;span style="color: red;"&gt;
    CurrentPlaylistItem&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding CurrentPlaylistItem, Mode=TwoWay}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Playlist&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding Playlist}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;We bound the SMFPlayer property &lt;em&gt;CurrentPlaylistItem&lt;/em&gt; to the view model’s &lt;em&gt;CurrentPlaylistItem&lt;/em&gt; property (which does not exist yet). Since the player can also change the current playlist item we have defined the binding to be two way so that the player can notify the view model that the item has changed. We bound the SMFPlayer property &lt;em&gt;Playlist&lt;/em&gt; to the view model’s &lt;em&gt;Playlist&lt;/em&gt; property so we can provide the player a list of PlaylistItems it is permitted to show.&lt;br /&gt;
&lt;br /&gt;
Binding the list of movies to the ListBox can be a bit more tricky to really show each movie in a way that you want. You can quickly just bind the ItemsSource property of the ListBox to the view model’s property &lt;em&gt;Movies&lt;/em&gt; (which does not exist yet) but that only gets you halfway there. What is a Movie? We have not really defined that yet. I envision a Movie to be a class with some basic properties on it such as title and a path to the movie’s video file. The ListBox is not going to know how to display that class. You need to define a template for what each item looks like. In Blend, this is done by selecting the ListBox, right click &amp;gt; Edit Additional Templates &amp;gt; Edit Generated Items &amp;gt; Create Empty. Outside of blend you would need to write the code.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ec2a5ec1-9e2c-42af-843b-58dd20e68702" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 315px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;DataTemplate &lt;/span&gt;&lt;span style="color: red;"&gt;x:Key&lt;/span&gt;&lt;span style="color: blue;"&gt;="MovieListItem"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextBlock
&lt;/span&gt;&lt;span style="color: red;"&gt;                Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding Title}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
                Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;

&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ListBox
&lt;/span&gt;&lt;span style="color: red;"&gt;    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="listBox"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{x:Null}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    BorderBrush&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{x:Null}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: red;"&gt;
    BorderThickness&lt;/span&gt;&lt;span style="color: blue;"&gt;="0"&lt;/span&gt;&lt;span style="color: red;"&gt;
    ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{StaticResource MovieListItem}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    ItemsSource&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding Movies}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;In this code I created a local resource then used it later in the ListBox by binding the ItemTemplate to the resource. You can also see the ItemsSource binding to the view model’s &lt;em&gt;Movies&lt;/em&gt; property. My template is very basic, but know that this could be anything you want. Your template needs to have a Grid, but inside that grid it can be however you would like to show what a Movie is. My template simply has a TextBlock that binds a Movie property &lt;em&gt;Title&lt;/em&gt; (that does not exist yet). Notice in my binding of Title that I did not need to say it is Movie.Title or Movie[x].Title. The application knows that because I bound my ItemsSource of my ListBox to be a list of Movies and the template is for one item of the ListBox, that the template will only be dealing with one Movie. Therefore, I can write my binding code directly off of a Movie class. That’s pretty awesome.&lt;br /&gt;
&lt;br /&gt;
I think we have a good idea of what our models will look like now, but we still don’t know what this movie class is and where it comes from.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;The Domain&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Your domain and data access layer should be separated from your implementation. Start by creating a new .NET class library project called &lt;em&gt;MovieLibraryData. &lt;/em&gt;This project is to demonstrate a layer that you may not have much control over. This is likely driven by Entity Framework models or some other form of connecting to a database of Movies. In my case this will contain a basic Movie class.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:75f9c17d-6834-448d-bb74-c91fa3b294ae" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 189px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt;&lt;span style="color: black;"&gt; Movie
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; Title { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; Path { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; public IEnumerable&amp;lt;Comment&amp;gt; Comments { get; set; }
&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; public IEnumerable&amp;lt;Review&amp;gt; Reviews { get; set; }
&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; public IEnumberable&amp;lt;CastMember&amp;gt; Cast { get; set; }
&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; public byte[] Poster { get; set; }&lt;/span&gt;&lt;span style="color: green;"&gt;
&lt;/span&gt;&lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;You should envision this class as having several complex types and possibly some methods/business logic. This could have collections of reviews or comments. Links to actors/actresses, producers, directors, etc. The point is, this could potentially be a complicated class.&lt;br /&gt;
&lt;br /&gt;
For our movie player we really do not care about all that data. we just want the movie path and a little info about the movie. If you start thinking about where this data will come from you will realize it will be coming over an http request through a web service we have not created yet. So we know we need a simple class that is light weight and serializable. We need a data transfer object.&lt;br /&gt;
&lt;br /&gt;
Create a new .NET class library project called &lt;em&gt;MovieLibraryDto&lt;/em&gt;. This project will hold all of our light weight versions of the classes from &lt;em&gt;MovieLibraryData&lt;/em&gt; so that we only have to send the properties we care about on the client. In the &lt;em&gt;MovieLibraryDto&lt;/em&gt; project, create the class MovieDto.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ea73b94a-8dbe-4841-b56b-9465d430d78c" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 150px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;[DataContract]
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt;&lt;span style="color: black;"&gt; MovieDto
{
    [DataMember]
&lt;/span&gt;&lt;span style="color: blue;"&gt;    public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; Title { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
    [DataMember]
&lt;/span&gt;&lt;span style="color: blue;"&gt;    public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; Path { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;You’ll notice I did not use the [Serializable] attribute on the class. Instead I used a DataContract with DataMembers which comes from &lt;em&gt;System.Runtime.Serialization&lt;/em&gt;. I have found this is a better approach. DataContracts give you control over the name and the namespace of the class and its properties as seen from the client. If you were to mark the class [Serializable] you will find many strange member names on the class when you get it on the client through a WCF service.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;The Service&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We need a way to get the movies from our domain/database to the client. Picture all of your movie watchers accessing a server out there somewhere that needs to give them the movies they want to watch. You need to create a service that can send those movies back to them. Then we’ll get into how Silverlight can call this service.&lt;br /&gt;
&lt;br /&gt;
Create a new WCF Service Application project and call it &lt;em&gt;MovieService&lt;/em&gt;. Add a reference to &lt;em&gt;MovieLibraryData&lt;/em&gt; and &lt;em&gt;MovieLibraryDto.&lt;/em&gt; If you look at what you get with this template you will see an interface and a svc file that implements that interface. Open the interface and rename it (using ReSharper or Visual Studio refactor rename) to &lt;em&gt;IMovieRetrievalService.cs. &lt;/em&gt;Clear out the sample code Visual Studio adds so that your class looks like this&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:474bea69-e01d-4a27-a259-73e7b9244322" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 126px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;[ServiceContract]
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;interface&lt;/span&gt;&lt;span style="color: black;"&gt; IMovieRetrievalService
{
    [OperationContract]
    IEnumerable&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MovieDto&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; GetMovies();
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;We just want a simple method to get all of our movies. Your method could get specific movies if you wanted. You should notice a few things about our interface.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;This interface is defining what we want our service to be capable of. &lt;/li&gt;
&lt;li&gt;We are using those ServiceContracts again. These are required by WCF. &lt;/li&gt;
&lt;li&gt;We are sending back a Dto. This is great because they are so light weight. &lt;/li&gt;
&lt;/ul&gt;Open the .svc file and rename it to MovieRetrievalService and have it implement our new interface &lt;em&gt;IMovieRetrievalService&lt;/em&gt;. Even Resharper can get confused when renaming a service file. You should check the markup of the svc file to make sure it reads &lt;em&gt;Service="MovieService.MovieRetrievalService"&lt;/em&gt;. In the &lt;em&gt;MovieRetrievalService.svc.cs&lt;/em&gt; file we can write code to pull out our movies from the domain level. Once we pull out the movies (IEnumerable&amp;lt;Movie&amp;gt;) we need to convert them to data transfer objects (IEnumberable&amp;lt;MovieDto&amp;gt;). Here is my code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:776c3b2c-178d-4c0b-8f4e-734bf7ebdec2" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 220px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; IEnumerable&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MovieDto&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; GetMovies()
{
    IEnumerable&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;Movie&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; movies &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; GetMoviesFromDatabase();

&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; You could also use AutoMapper to map the domain model
&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; to the data transfer objects&lt;/span&gt;&lt;span style="color: green;"&gt;
&lt;/span&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;&lt;span style="color: black;"&gt; movies.Select(movie &lt;/span&gt;&lt;span style="color: black;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; MovieDto
    {
        Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; movie.Title,
        Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; movie.Path
    });
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;I call a mysterious GetMoviesFromDatabase() method that returns domain level Movie objects where I project each movie into a new MovieDto object and return that list. Mapping the Movie class to the MovieDto class is tedious in this case because the field names match one to one. A cleaner approach may be to use &lt;a href="http://automapper.codeplex.com/" target="_blank"&gt;AutoMapper&lt;/a&gt; to do that mapping for us.&lt;br /&gt;
&lt;br /&gt;
My GetMoviesFromDatabase() method call is just creating a static list of movies because I did not want to go through the trouble of creating a database in this example. You could replace this with retrieving data from your favorite database provider or repository that likely lives on the domain side.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:db44d63f-4551-4c72-96a6-72c87e00e87d" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 510px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; IEnumerable&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;Movie&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; GetMoviesFromDatabase()
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    return&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; List&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;Movie&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        new&lt;/span&gt;&lt;span style="color: black;"&gt; Movie
        {
            Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Microsoft Wildlife sample&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
            Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://smf.vertigo.com/videos/wildlife.wmv&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
        },
&lt;/span&gt;&lt;span style="color: blue;"&gt;        new&lt;/span&gt;&lt;span style="color: black;"&gt; Movie
        {
            Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;We're All In at PDC10&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
            Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://ecn.channel9.msdn.com/o9/ch9/2497/0e8a5166-3984-4a91-925d-9e1500f92497/SharePointSideshow02_ch9.wmv&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
        },
&lt;/span&gt;&lt;span style="color: blue;"&gt;        new&lt;/span&gt;&lt;span style="color: black;"&gt; Movie
        {
            Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Silverlight TV 50&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
            Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://ecn.channel9.msdn.com/o9/ch9/d274/e69539b7-2e75-462d-a614-9e150175d274/sltv50_ch9.wmv&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
        },
&lt;/span&gt;&lt;span style="color: blue;"&gt;        new&lt;/span&gt;&lt;span style="color: black;"&gt; Movie
        {
            Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Silverlight TV 16&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
            Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://ecn.channel9.msdn.com/o9/ch9/6/7/5/6/3/5/SLTV16SL4RCPanel_ch9.wmv&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
        }
    };
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;It just so happens that each of my videos I selected are wmv files. This is not a requirement. Silverlight has several other &lt;a href="http://msdn.microsoft.com/en-us/library/cc189080(v=vs.95).aspx" target="_blank"&gt;supported video formats&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Before we move on you should be aware of &lt;a href="http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx" target="_blank"&gt;access policies&lt;/a&gt;. You have the option to define who can see and call your service. This is done through a &lt;em&gt;ClientAccessPolicy.xml &lt;/em&gt;file. Create this file with that exact name in root of the &lt;em&gt;MovieService&lt;/em&gt; project. You can start with a base that gives everyone access to this service by using this code:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:33dc87a6-5950-49ca-88a8-b93eaedba0a0" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 250px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: magenta;"&gt;xml version="1.0" encoding="utf-8"&lt;/span&gt;&lt;span style="color: blue;"&gt;?&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;access-policy&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;cross-domain-access&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;policy&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;allow-from &lt;/span&gt;&lt;span style="color: red;"&gt;http-request-headers&lt;/span&gt;&lt;span style="color: blue;"&gt;="*"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;domain &lt;/span&gt;&lt;span style="color: red;"&gt;uri&lt;/span&gt;&lt;span style="color: blue;"&gt;="*"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;allow-from&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;grant-to&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;resource &lt;/span&gt;&lt;span style="color: red;"&gt;path&lt;/span&gt;&lt;span style="color: blue;"&gt;="/"&lt;/span&gt;&lt;span style="color: red;"&gt; include-subpaths&lt;/span&gt;&lt;span style="color: blue;"&gt;="true"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;grant-to&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;policy&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;cross-domain-access&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;access-policy&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;You should now be able to right click the &lt;em&gt;MovieService&lt;/em&gt; project and debug run the service to open a port. If you are looking for the traditional welcome page from other types of web services you can click on the MovieRetrievalService.svc in the directory listing when the web page comes up.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;Calling The Service&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now that you are capable of retrieving the list of movies, you just need to find something to call the service. Your first thought might be just add a service reference from &lt;em&gt;MoviePlayer&lt;/em&gt; so that you can call the service from the Silverlight assembly. Unfortunately you cannot do this. You will get several errors:&lt;br /&gt;
&lt;blockquote&gt;&lt;em&gt;“Custom tool error: Failed to generate code for the service reference ‘ServiceReference1’.”&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;“No endpoints compatible with Silverlight 4 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.”&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;“Cannot import wsdl: binding …”&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/blockquote&gt;The point is, Silverlight is upset. You cannot call a WCF service directly from the Silverlight application. In fact, your Silverlight application can only interact with Silverlight class libraries. Create a new Silverlight class library project called &lt;em&gt;MovieServiceClient&lt;/em&gt;. Right click the references in this new project and add a service reference. If you click discover you should see your localhost web service running from the previous steps. Name this reference &lt;em&gt;MovieServiceReference&lt;/em&gt;. Once you click OK and get your service reference you will notice a new file called &lt;em&gt;ServiceReferences.ClientConfig.&lt;/em&gt; This is an evil file. It stores all the connection information for if you ever need to update your service reference. This is evil because this information can change depending on your build configuration but it’s not in the web config so you cannot really do a web config transform. We’ll get back to that.&lt;br /&gt;
&lt;br /&gt;
Now you can reference the &lt;em&gt;MovieServiceClient&lt;/em&gt; project from &lt;em&gt;MoviePlayer&lt;/em&gt; because they are two Silverlight assemblies talking to each other. Exciting, I know.&lt;br /&gt;
&lt;br /&gt;
We can revisit the Silverlight UI, but before we do that I want to make sure a few things are clear. You have created six projects. It is important to understand each project and its role:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://lh5.ggpht.com/_W3WFfs_0QgY/TUF7vHp_CzI/AAAAAAAAAHs/XXv86NO_wM8/s1600-h/MoviePlayerProjectRelation5.png" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="MoviePlayerProjectRelation" border="0" height="358" src="http://lh5.ggpht.com/_W3WFfs_0QgY/TUF7vilNh5I/AAAAAAAAAHw/C-JA6LUAqNE/MoviePlayerProjectRelation_thumb3.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="MoviePlayerProjectRelation" width="440" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;strong&gt;MoviePlayer.Web&lt;/strong&gt; - Provides a way to show the Silverlight application in a browser &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MoviePlayer&lt;/strong&gt; - This is our Silverlight application that holds our movie and navigation controls. This is the user interface. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MovieService&lt;/strong&gt; - The service lives on the server. It communicates with the database/domain models to retrieve the movie objects, convert them to data transfer objects (dto) and send the light weight objects back to the client &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MovieServiceClient&lt;/strong&gt; - This is a Silverlight class library that is reverenced by &lt;em&gt;MoviePlayer&lt;/em&gt;. It provides a web reference to &lt;em&gt;MovieService&lt;/em&gt; to allow the Silverlight application to make a WCF service call. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MovieLibraryData&lt;/strong&gt; - A .NET class library to mimic a real and possibly complicated data access layer. The &lt;em&gt;MovieService&lt;/em&gt; will be using the Movie class in this library and convert it to a &lt;em&gt;MovieDto&lt;/em&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MovieLibraryDto&lt;/strong&gt; - A .NET class library that contains light weight object designed to be serialized. The MovieService will be using the &lt;em&gt;MovieDto&lt;/em&gt; class in this library and send it back to the &lt;em&gt;MovieServiceClient&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;h3&gt;Setting up MVVM&lt;/h3&gt;Make sure you have &lt;a href="http://nuget.codeplex.com/" target="_blank"&gt;NuGet&lt;/a&gt; installed and add a reference to Mvvm Light Toolkit in the &lt;em&gt;MoviePlayer&lt;/em&gt; project by right clicking References and selecting “Add Library Package Reference”. If you are not familiar with NuGet, you can think of it as a fancy way to add DLLs to your project.&lt;br /&gt;
&lt;br /&gt;
Create a class called &lt;em&gt;MoviePlayerViewModel.cs&lt;/em&gt; in the &lt;em&gt;MoviePlayer&lt;/em&gt; project. This class will contain all the movie information you will be showing on the view. The view model just organizes this information so the view can simply reference a property on the view model to get its data. This class needs to implement the interface &lt;em&gt;INotifyPropertyChanged&lt;/em&gt; found in System.ComponentModel.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:aa6cd854-31be-40dd-a063-71f5ab7363b4" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 220px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt;&lt;span style="color: black;"&gt; MoviePlayerViewModel : INotifyPropertyChanged
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;event&lt;/span&gt;&lt;span style="color: black;"&gt; PropertyChangedEventHandler PropertyChanged;

&lt;/span&gt;&lt;span style="color: blue;"&gt;    private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; info)
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        if&lt;/span&gt;&lt;span style="color: black;"&gt; (PropertyChanged &lt;/span&gt;&lt;span style="color: black;"&gt;!=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;null&lt;/span&gt;&lt;span style="color: black;"&gt;)
        {
            PropertyChanged(&lt;/span&gt;&lt;span style="color: blue;"&gt;this&lt;/span&gt;&lt;span style="color: black;"&gt;, &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; PropertyChangedEventArgs(info));
        }
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Now you can add public properties to this class. Every public property you provide here will be available to the view. Lets add a few that we know we will need. We know we will have a playlist, and if you look at the SMFPlayer you will see that the Playlist property is expecting a collection of PlaylistItem. MVVM binding works off of a System.Collections.ObjectModel.ObservableCollection&amp;lt;T&amp;gt;. Knowing this we can start to create some properties on our view model.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:e0dae6ea-df10-4179-bb07-0bf4aba59987" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 300px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;PlaylistItem&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; _playlist;
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;PlaylistItem&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; Playlist
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    get&lt;/span&gt;&lt;span style="color: black;"&gt; { &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;&lt;span style="color: black;"&gt; _playlist; }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    set&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
        _playlist &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; value;
        NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Playlist&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;);
    }
}

&lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MovieDto&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; _movies;
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MovieDto&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; Movies { ... }

&lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; PlaylistItem _currentPlaylistItem;
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; PlaylistItem CurrentPlaylistItem { ... }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;See the list of Movies? It is of type MovieDto that we created in the &lt;em&gt;MovieLibraryDto&lt;/em&gt; project. You would think you would need to add a reference to that project to get this type, but remember that you cannot add a reference to a non Silverlight class library within a Silverlight application. You will get this type through the &lt;em&gt;MovieServiceClient&lt;/em&gt; when you created the service reference to &lt;em&gt;MovieService&lt;/em&gt; it recreated those types so the &lt;em&gt;MovieServiceClient&lt;/em&gt; can provide those types to the assemblies that call it.&lt;br /&gt;
&lt;br /&gt;
Create a constructor in the view model and lets get some movies from that service.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:8f2b823e-1dbc-409f-bad3-2ce738cb4c22" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 280px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; MoviePlayerViewModel()
{
    ...
    PopulateMovies();
}

&lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; PopulateMovies()
{
    var movieService &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; MovieRetrievalServiceClient(
&lt;/span&gt;&lt;span style="color: blue;"&gt;        new&lt;/span&gt;&lt;span style="color: black;"&gt; BasicHttpBinding(),
&lt;/span&gt;&lt;span style="color: blue;"&gt;        new&lt;/span&gt;&lt;span style="color: black;"&gt; EndpointAddress(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://localhost:49885/MovieRetrievalService.svc&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;));

    movieService.GetMoviesCompleted &lt;/span&gt;&lt;span style="color: black;"&gt;+=&lt;/span&gt;&lt;span style="color: black;"&gt; GetMoviesCompleted;
    movieService.GetMoviesAsync();
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;We got a &lt;em&gt;MovieRetrievalServiceClient&lt;/em&gt; class from MovieServiceClient.MovieServiceReference. Notice all the parameters on the constructor. You don’t actually need these. Instead you could provide a copy of the &lt;em&gt;ServiceReferences.ClientConfig&lt;/em&gt; file from the &lt;em&gt;MovieServiceClient&lt;/em&gt; in the root of the &lt;em&gt;MoviePlayer&lt;/em&gt; project. Why would you do that though? We have already established that file is evil. Create the bindings in code that way you could extract out that information into a config file or something where you could change the endpoint without rebuilding the solution or ripping apart the XAP file. Make sure your path points to the localhost port that was opened when running your WCF Service.&lt;br /&gt;
&lt;br /&gt;
The client class has a GetMoviesAsync method on it that calls our GetMovies method on the &lt;em&gt;MovieService&lt;/em&gt;. You need to give it a callback to execute once the asynchronous method call completes.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:96bd3575-b82d-4388-ba63-121799eb4ed9" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 280px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; GetMoviesCompleted(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, GetMoviesCompletedEventArgs e)
{
    Movies &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; e.Result;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    if&lt;/span&gt;&lt;span style="color: black;"&gt; (Movies &lt;/span&gt;&lt;span style="color: black;"&gt;==&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;null&lt;/span&gt;&lt;span style="color: black;"&gt;)
&lt;/span&gt;&lt;span style="color: blue;"&gt;        return&lt;/span&gt;&lt;span style="color: black;"&gt;;

    var playlistItems &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; Movies.Select(movie &lt;/span&gt;&lt;span style="color: black;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; PlaylistItem
    {
        Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; movie.Title,
        MediaSource &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; Uri(movie.Path)
    });

    Playlist &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;PlaylistItem&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;(playlistItems);
    CurrentPlaylistItem &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; Playlist.FirstOrDefault();
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;e.Result is our strongly typed list of ObservableCollection&amp;lt;MovieDto&amp;gt; just like we defined on our Service interface. We can save off that list of movies but we also need a list of playlist items to feed to the Silverlight Media Framework player. We can project new playlist items from the list of movies as shown in the code snippet. Then create a new observable collection with this list of playlist items.&lt;br /&gt;
&lt;h3&gt;Connecting the View Model to the View&lt;/h3&gt;If you've been paying attention you know that we have never told the view how it retrieves its data. We have told it what properties to pull from, but never from what object. To do this we can simply add a DataContext to the LayoutRoot of the MainPage.xaml. Before you add the DataContext you should think about what that does when you add it. You are really saying everytime you show the MainPage I want you to create a new MoviePlayerViewModel and use that for your data. This literally calls the default constructor, even when in design mode (Expression Blend and Visual Studio designer). You need to be aware of this and handle it appropriately. For instance, if we are in the designer we do not want our code calling the service and pulling down movies. Although, it would be nice to see some sample data so we can see how the page is organized with data on it. There are mechanisms in place to do just that. You can rewrite your PopulateMovies() method to use &lt;em&gt;DesignerProperties.IsInDesignTool&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:a3517fd7-6419-41f8-a5bb-3a776e680507" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 490px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; PopulateMovies()
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    if&lt;/span&gt;&lt;span style="color: black;"&gt; (DesignerProperties.IsInDesignTool)
    {
        Movies &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MovieDto&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
        {
&lt;/span&gt;&lt;span style="color: blue;"&gt;            new&lt;/span&gt;&lt;span style="color: black;"&gt; MovieDto
            {
                Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Sample Movie 1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
                Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://sample.path&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
            },
&lt;/span&gt;&lt;span style="color: blue;"&gt;            new&lt;/span&gt;&lt;span style="color: black;"&gt; MovieDto
            {
                Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Sample Movie 2&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
                Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://sample.path&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
            },
&lt;/span&gt;&lt;span style="color: blue;"&gt;            new&lt;/span&gt;&lt;span style="color: black;"&gt; MovieDto
            {
                Title &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Sample Movie 3&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
                Path &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;http://sample.path&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;
            }
        };
    }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    else&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
        ...
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Now you can safely attach your view model to your view. In Blend you can select the LayoutRoot of MainPage.xaml. Click new DataContext and select MoviePlayerViewModel.cs from the list. In xaml it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:de8edff4-c7ff-47ac-8747-697e990942ff" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 126px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid &lt;/span&gt;&lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="LayoutRoot"&lt;/span&gt;&lt;span style="color: red;"&gt; Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="Black"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid.DataContext&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;local:MoviePlayerViewModel&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid.DataContext&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
    ...
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;with a namespace of “xmlns:local="clr-namespace:MoviePlayer"” defined. Once you add the DataContext to your xaml and you have your bindings defined from previous steps you will start to see some data in your view!&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_W3WFfs_0QgY/TUF7wKdJo4I/AAAAAAAAAH0/_47pV_64GpA/s1600-h/MoviePlayerDesignData2.png"&gt;&lt;img alt="MoviePlayerDesignData" border="0" height="157" src="http://lh6.ggpht.com/_W3WFfs_0QgY/TUF7wf93WuI/AAAAAAAAAH4/D8hegZYuFhI/MoviePlayerDesignData_thumb.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="MoviePlayerDesignData" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Run the Web application (MoviePlayerTestPage.aspx or MoviePlayerTestPage.html) and you will see even more. Now it knows you are not in the designer and uses the WCF service to pull down the list of movies. It populates a list of playlist items, a current playlist item, and the list of movies on the side just like the screenshot from the beginning of the post.&lt;br /&gt;
&lt;br /&gt;
This is great progress, so congratulations.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;Changing the Current Movie&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you click on the playlist built into the SMFPlayer and select a different movie you can change the currently playing movie. One of the goals of this tutorial was to have an external playlist. If you click on another movie in the list to the right of the SMFPlayer it will not change the currently playing movie. We can fix this.&lt;br /&gt;
&lt;br /&gt;
This time let’s start at the view model and create a new property for handling the change in movie.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ccf60554-833b-41a2-abe6-4b3856da6721" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 39px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ICommand MovieSelectionChangedCommand { &lt;/span&gt;&lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;span style="color: black;"&gt;; &lt;/span&gt;&lt;span style="color: blue;"&gt;set&lt;/span&gt;&lt;span style="color: black;"&gt;; }
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;MVVM commanding works through the ICommand interface. ICommand works off of the idea that you have code you want to execute when this command happens and you also have code you want to execute to determine if you &lt;em&gt;can &lt;/em&gt;execute the command. ICommand can also support parameters that the view can pass you. You could write your own implementation of an ICommand or you could use one from the Mvvm Light Toolkit (which you installed in the MVVM section). This toolkit has an implementation of ICommand called RelayCommand that supports defining the type of CommandParameter you expect the view to be sending you. In this case we want the view to tell us what movie the user selected. We can create a command for this in the constructor of the &lt;em&gt;MoviePlayerViewModel&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:596910ab-d89d-4b55-bfb0-204ba3a0167e" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 120px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; MoviePlayerViewModel()
{
    MovieSelectionChangedCommand &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; RelayCommand&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;MovieDto&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;(MovieSelectionChanged, CanMovieSelectionChange);
    ...
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;I am using the generic version of RelayCommand to say that my view will be providing me a MovieDto as a parameter. The first parameter to the RelayCommand constructor is what method to execute when the command is called. The second parameter is what method to execute to determine if the command can be executed. You will need to implement these methods.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:a2e32848-1409-4e57-adcb-d3b1c976bd46" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 200px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt;&lt;span style="color: black;"&gt; CanMovieSelectionChange(MovieDto movie)
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    return&lt;/span&gt;&lt;span style="color: black;"&gt; movie &lt;/span&gt;&lt;span style="color: black;"&gt;!=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;null&lt;/span&gt;&lt;span style="color: black;"&gt;;
}

&lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; MovieSelectionChanged(MovieDto movie)
{
    var playlistItem &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; Playlist.Where(item &lt;/span&gt;&lt;span style="color: black;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; item.Title &lt;/span&gt;&lt;span style="color: black;"&gt;==&lt;/span&gt;&lt;span style="color: black;"&gt; movie.Title).FirstOrDefault();
    CurrentPlaylistItem &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; playlistItem;
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;I have a rather crude way of finding the playlist item from the playlist. You could change that to something more realistic if you had some unique identifier for a movie. Once you have the playlist item you just set the item to be the current playlist item which is bound to the view. When the CurrentPlaylistItem changes the NotifyPropertyChanged method in the setter will tell the view that it has a new playlist item and the SMFPlayer will change the movie.&lt;br /&gt;
&lt;br /&gt;
Now that we have a command written up in the view model we can attach it to the view. In Blend, select the ListBox, go to Assets &amp;gt; Behaviors &amp;gt; double click InvokeCommandAction. This will nest the action with the ListBox. There are three properties you need to change.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Change the event to be “SelectionChanged”. &lt;/li&gt;
&lt;li&gt;Click the advanced options of the “Command” property in Common Properties. Select “Data Binding…”. Select the &lt;em&gt;MovieSelectionChangedCommand&lt;/em&gt; from the “Data Context” tab and click OK. If you do not see the command in the list you may need to rebuild the solution. &lt;/li&gt;
&lt;li&gt;Click the “Show Advanced Options” arrow in the Common Properties. Click the advanced options of the “Command Parameter” property. Select “Data Binding…”. On the Element Property tab select the ListBox on the left panel and the SelectedItem property on the right panel.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/_W3WFfs_0QgY/TUF7wsB1XXI/AAAAAAAAAH8/FY9cW2O8uQI/s1600-h/MoviePlayerCommandParameter4.png"&gt;&lt;img alt="MoviePlayerCommandParameter" border="0" height="424" src="http://lh6.ggpht.com/_W3WFfs_0QgY/TUF7wxuFG3I/AAAAAAAAAIA/rJh67WfV_2c/MoviePlayerCommandParameter_thumb2.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="MoviePlayerCommandParameter" width="452" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Remember that we used a list of Movies as the ItemsSource for the ListBox. Even though the SelectedItem says it is of type Object, we know that is going to be a MovieDto and that’s awesome. In the end we know that when the ListBox selection changes our command is going to call the view models CanMovieSelectionChanged(movieDto) if that is true it will call MovieSelectionChanged(movieDto) Here is the xaml you just generated.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ef5395b8-cdfd-4c40-bf19-b178a6b7d97f" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 230px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;ListBox &lt;/span&gt;&lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="listBox"&lt;/span&gt;&lt;span style="color: red;"&gt;
    ...
    ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{StaticResource MovieListItem}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    ItemsSource&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding Movies}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt; BorderThickness&lt;/span&gt;&lt;span style="color: blue;"&gt;="0"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;i:EventTrigger &lt;/span&gt;&lt;span style="color: red;"&gt;EventName&lt;/span&gt;&lt;span style="color: blue;"&gt;="SelectionChanged"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;i:InvokeCommandAction
&lt;/span&gt;&lt;span style="color: red;"&gt;                Command&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding MovieSelectionChangedCommand}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
                CommandParameter&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding SelectedItem, ElementName=listBox}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;i:EventTrigger&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;ListBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Once you have the command finished you can run it and see that if you click on a different movie it will change the movie in the player.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;Summary&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The goal of this post was to give you the functionality required to get a list of movies from a WCF service and feed them to a SMFPlayer. This base will allow you to make changes to suit your needs whether it is domain level or UI level. I will write another post showing what sort of UI is possible when starting with a base like this.&lt;br /&gt;
&lt;br /&gt;
You can download the full source from my &lt;a href="https://bitbucket.org/swhook52/stevenhookblogcode/src/e2c921606dee/MoviePlayer/" target="_blank"&gt;bitbucket blog code repository&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-5681713262844100654?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/5681713262844100654/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2011/01/watching-movies-with-wcf-and.html#comment-form" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5681713262844100654?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5681713262844100654?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2011/01/watching-movies-with-wcf-and.html" title="Watching Movies with WCF and Silverlight" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_W3WFfs_0QgY/TUF7uokPCZI/AAAAAAAAAHo/Iv6TRGq-8Ng/s72-c/MoviePlayerNoTheme_thumb1.png?imgmax=800" height="72" width="72" /><thr:total>10</thr:total></entry><entry gd:etag="W/&quot;AkQFQXg8fCp7ImA9Wx9WGUg.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-2558399433987307112</id><published>2011-01-25T07:25:00.000-05:00</published><updated>2011-01-25T07:25:10.674-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-25T07:25:10.674-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="MetroStack" /><title>WPF Borderless Window Controls</title><content type="html">&lt;a href="http://lh4.ggpht.com/_W3WFfs_0QgY/TT682veLW4I/AAAAAAAAAHU/bMgdGUdM9Zc/s1600-h/WPFControlBox5.png"&gt;&lt;img align="right" alt="WPFControlBox" border="0" height="78" src="http://lh5.ggpht.com/_W3WFfs_0QgY/TT683DgOF-I/AAAAAAAAAHY/HXQuWVNpSV8/WPFControlBox_thumb3.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; float: right; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="WPFControlBox" width="260" /&gt;&lt;/a&gt;The first challenge I tackled when writing &lt;a href="http://stevenhook.blogspot.com/2011/01/metro-stack.html" target="_blank"&gt;Metro Stack&lt;/a&gt; was creating that &lt;a href="http://www.zune.net/en-US/products/software/download/default.htm" target="_blank"&gt;Microsoft Zune&lt;/a&gt; player feel with no border while still supporting a draggable and resizable window. I have created an isolated project to demonstrate how you can do this.&lt;br /&gt;
Creating a borderless window that supports resizing is simple. Here is the code:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:85510056-996b-46bc-8ff4-76f83e326ca2" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 161px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Window
&lt;/span&gt;&lt;span style="color: red;"&gt;    ...
    ResizeMode&lt;/span&gt;&lt;span style="color: blue;"&gt;="CanResizeWithGrip"&lt;/span&gt;&lt;span style="color: red;"&gt;
    WindowStyle&lt;/span&gt;&lt;span style="color: blue;"&gt;="None"&lt;/span&gt;&lt;span style="color: red;"&gt;
    AllowsTransparency&lt;/span&gt;&lt;span style="color: blue;"&gt;="True"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
    ...
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Window&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Just three properties can get you a borderless window like you would expect. WindowStyle will remove the standard control box. AllowsTransparency will remove the border. ResizeMode will give you a drag option in the bottom right of the window.&lt;br /&gt;
&lt;br /&gt;
When I initially thought of creating a custom control box for the minimize, maximize, and close buttons I started thinking how annoying it would be to find or create images for each function and possibly for each state of the button. I got less interested in making them the more I thought about it. Then I heard about people doing this using &lt;a href="http://en.wikipedia.org/wiki/Wingdings" target="_blank"&gt;Wingdings&lt;/a&gt; and I thought that was a great idea! This would also allow me to handle different effects for MouseOver and Pressed events easier. Getting this going was rather simple. I just created a TextBlock, changed the font to &lt;a href="http://en.wikipedia.org/wiki/Wingdings" target="_blank"&gt;Wingdings&lt;/a&gt; and entered the appropriate character for the symbol I am looking for. For example, the close button would look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3ef09807-6980-4044-b1f8-44e60710ccf6" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 207px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextBlock
&lt;/span&gt;&lt;span style="color: red;"&gt;    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="CloseButton"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="r"&lt;/span&gt;&lt;span style="color: red;"&gt;
    FontFamily&lt;/span&gt;&lt;span style="color: blue;"&gt;="Webdings"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="Gray"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="5,0,0,0"&lt;/span&gt;&lt;span style="color: red;"&gt;
    HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Right"&lt;/span&gt;&lt;span style="color: red;"&gt;
    VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: red;"&gt;
    MouseLeftButtonUp&lt;/span&gt;&lt;span style="color: blue;"&gt;="CloseButtonMouseLeftButtonUp"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;I decided to go with traditional code behind because I find it appropriate that these controls are the concern of the view.&lt;br /&gt;
&lt;br /&gt;
Accomplishing the window drag was not too bad either. For my application, I wanted just a portion of the window to be dragable. To do this I created a new grid to act as the window drag handle.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:f13ca413-ceb7-4afa-9648-a5c84812d3c5" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 274px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid &lt;/span&gt;&lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="LayoutRoot"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid 
&lt;/span&gt;&lt;span style="color: red;"&gt;        x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="HeaderGrid"&lt;/span&gt;&lt;span style="color: red;"&gt; 
        Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"&lt;/span&gt;&lt;span style="color: red;"&gt; 
        VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid 
&lt;/span&gt;&lt;span style="color: red;"&gt;            x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="DragableAreaGrid"&lt;/span&gt;&lt;span style="color: red;"&gt;
            Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: red;"&gt;
            MouseDown&lt;/span&gt;&lt;span style="color: blue;"&gt;="DragableGridMouseDown"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
        ...
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;There were a few tricks I had to play to get the dragable area working with the control box. Notice that the &lt;em&gt;DragableAreaGrid&lt;/em&gt; has a background of white, which is really just on top of another grid that is white. This is done so that the user actually has some surface area of the &lt;em&gt;DragableAreaGrid&lt;/em&gt; to grab on to. If this were a transparent background you would never be able to invoke the MouseDown event of the grid.&lt;br /&gt;
&lt;br /&gt;
Here is the full XAML code for this sample:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3080a471-0656-4d21-8d1c-685ac8b7b0bb" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 1150px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Window
&lt;/span&gt;&lt;span style="color: red;"&gt;    xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;span style="color: red;"&gt;
    xmlns:x&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;span style="color: red;"&gt;
    xmlns:d&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt;&lt;span style="color: red;"&gt;
    xmlns:mc&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt;&lt;span style="color: red;"&gt;
    mc:Ignorable&lt;/span&gt;&lt;span style="color: blue;"&gt;="d"&lt;/span&gt;&lt;span style="color: red;"&gt;
    x:Class&lt;/span&gt;&lt;span style="color: blue;"&gt;="Metro.CustomControlBox"&lt;/span&gt;&lt;span style="color: red;"&gt;
    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Window"&lt;/span&gt;&lt;span style="color: red;"&gt;
    ResizeMode&lt;/span&gt;&lt;span style="color: blue;"&gt;="CanResizeWithGrip"&lt;/span&gt;&lt;span style="color: red;"&gt;
    WindowStyle&lt;/span&gt;&lt;span style="color: blue;"&gt;="None"&lt;/span&gt;&lt;span style="color: red;"&gt;
    AllowsTransparency&lt;/span&gt;&lt;span style="color: blue;"&gt;="True"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="640"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="480"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid &lt;/span&gt;&lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="LayoutRoot"&lt;/span&gt;&lt;span style="color: red;"&gt;
        Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid 
&lt;/span&gt;&lt;span style="color: red;"&gt;            x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="HeaderGrid"&lt;/span&gt;&lt;span style="color: red;"&gt; 
            Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"&lt;/span&gt;&lt;span style="color: red;"&gt; 
            VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid
&lt;/span&gt;&lt;span style="color: red;"&gt;                x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="DragableArea"&lt;/span&gt;&lt;span style="color: red;"&gt;
                Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: red;"&gt;
                MouseDown&lt;/span&gt;&lt;span style="color: blue;"&gt;="DragableGridMouseDown"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;StackPanel
&lt;/span&gt;&lt;span style="color: red;"&gt;                Orientation&lt;/span&gt;&lt;span style="color: blue;"&gt;="Horizontal"&lt;/span&gt;&lt;span style="color: red;"&gt;
                Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="0,5,5,0"&lt;/span&gt;&lt;span style="color: red;"&gt;
                HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Right"&lt;/span&gt;&lt;span style="color: red;"&gt;
                VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: red;"&gt;
                Background&lt;/span&gt;&lt;span style="color: blue;"&gt;="White"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextBlock 
&lt;/span&gt;&lt;span style="color: red;"&gt;                    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="ChangeViewButton"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="2"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    FontFamily&lt;/span&gt;&lt;span style="color: blue;"&gt;="Webdings"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="Gray"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="0"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Right"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    MouseLeftButtonUp&lt;/span&gt;&lt;span style="color: blue;"&gt;="ChangeViewButtonMouseLeftButtonUp"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextBlock
&lt;/span&gt;&lt;span style="color: red;"&gt;                    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="MinimizeButton"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="0"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    FontFamily&lt;/span&gt;&lt;span style="color: blue;"&gt;="Webdings"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="Gray"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="5,0,0,0"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Right"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    MouseLeftButtonUp&lt;/span&gt;&lt;span style="color: blue;"&gt;="MinimizeButtonMouseLeftButtonUp"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextBlock
&lt;/span&gt;&lt;span style="color: red;"&gt;                    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="MaximizeButton"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="1"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    FontFamily&lt;/span&gt;&lt;span style="color: blue;"&gt;="Webdings"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="Gray"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="5,0,0,0"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Right"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    MouseLeftButtonUp&lt;/span&gt;&lt;span style="color: blue;"&gt;="MaximizeButtonMouseLeftButtonUp"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;TextBlock
&lt;/span&gt;&lt;span style="color: red;"&gt;                    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="CloseButton"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Text&lt;/span&gt;&lt;span style="color: blue;"&gt;="r"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    FontFamily&lt;/span&gt;&lt;span style="color: blue;"&gt;="Webdings"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="Gray"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    Margin&lt;/span&gt;&lt;span style="color: blue;"&gt;="5,0,0,0"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Right"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    VerticalAlignment&lt;/span&gt;&lt;span style="color: blue;"&gt;="Top"&lt;/span&gt;&lt;span style="color: red;"&gt;
                    MouseLeftButtonUp&lt;/span&gt;&lt;span style="color: blue;"&gt;="CloseButtonMouseLeftButtonUp"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;            &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;StackPanel&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Grid&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;    
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Window&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Here is the code behind for this XAML window:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:fed0a973-6b61-453d-91b2-9d0a216c6994" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 710px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt;&lt;span style="color: black;"&gt; System.Windows;
&lt;/span&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt;&lt;span style="color: black;"&gt; System.Windows.Input;

&lt;/span&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt;&lt;span style="color: black;"&gt; Metro
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;partial&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt;&lt;span style="color: black;"&gt; CustomControlBoxWindow : Window
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        public&lt;/span&gt;&lt;span style="color: black;"&gt; CustomControlBoxWindow()
        {
            InitializeComponent();
        }

&lt;/span&gt;&lt;span style="color: blue;"&gt;        private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; CloseButtonMouseLeftButtonUp(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, MouseButtonEventArgs e)
        {
            Close();
        }

&lt;/span&gt;&lt;span style="color: blue;"&gt;        private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; MaximizeButtonMouseLeftButtonUp(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, MouseButtonEventArgs e)
        {
            WindowState &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; WindowState.Maximized;
        }

&lt;/span&gt;&lt;span style="color: blue;"&gt;        private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; ChangeViewButtonMouseLeftButtonUp(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, MouseButtonEventArgs e)
        {
            WindowState &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; WindowState.Normal;
        }

&lt;/span&gt;&lt;span style="color: blue;"&gt;        private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; MinimizeButtonMouseLeftButtonUp(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, MouseButtonEventArgs e)
        {
            WindowState &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; WindowState.Minimized;
        }

&lt;/span&gt;&lt;span style="color: blue;"&gt;        private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; DragableGridMouseDown(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, MouseButtonEventArgs e)
        {
&lt;/span&gt;&lt;span style="color: blue;"&gt;            if&lt;/span&gt;&lt;span style="color: black;"&gt; (e.LeftButton &lt;/span&gt;&lt;span style="color: black;"&gt;==&lt;/span&gt;&lt;span style="color: black;"&gt; MouseButtonState.Pressed)
                DragMove();
        }
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;The code behind is just slap happy code, but really there is not much more to it. Notice the condition in the DragableGridMouseDown event. You will get an exception if you try and call DragMove() if the user was dragging with any other button other than the primary button. &lt;em&gt;InvalidOperationException: Can only call DragMove when primary mouse button is down.&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_W3WFfs_0QgY/TT683QK3G6I/AAAAAAAAAHc/_F_Rih4QzJ8/s1600-h/DragMoveException3.png"&gt;&lt;img alt="DragMoveException" border="0" height="47" src="http://lh3.ggpht.com/_W3WFfs_0QgY/TT683vVOnyI/AAAAAAAAAHg/cnKSTvLjOAA/DragMoveException_thumb1.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="DragMoveException" width="383" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Checking for the LeftButton is probably not the best idea but it demonstrates something to watch out for. I doubt this code would work with a left handed mouse as the input device may consider the RightButton to be the primary button.&lt;br /&gt;
&lt;br /&gt;
Other tricky parts to watch out for is how your &lt;em&gt;DragableAreaGrid&lt;/em&gt; interacts with your new control box. If the controls are within the &lt;em&gt;DragableAreaGrid&lt;/em&gt; the grid will handle your mouse events for the controls. Because of this, I have added my controls side-by-side (rather than the controls in the dragable grid) with my &lt;em&gt;DragableAreaGrid&lt;/em&gt;. You will also run into the same background problem with the control grid if your controls sit on top of your &lt;em&gt;DragableAreaGrid&lt;/em&gt;. Unless you put a background color on your controls you will only get a click event on your controls if you hit it perfectly on the wingding character. Don’t be sad though. There are tricks inside of tricks for that. If you truly do not want a color for your background but you need some surface area to be able to catch that mouse input you can set the alpha channel of the background to be 1% so you can’t even see the background but it’s there as a clickable space.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-2558399433987307112?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/2558399433987307112/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2011/01/wpf-borderless-window-controls.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2558399433987307112?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2558399433987307112?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2011/01/wpf-borderless-window-controls.html" title="WPF Borderless Window Controls" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/_W3WFfs_0QgY/TT683DgOF-I/AAAAAAAAAHY/HXQuWVNpSV8/s72-c/WPFControlBox_thumb3.png?imgmax=800" height="72" width="72" /><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;AkMFRnk9fyp7ImA9Wx9WGUg.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-4549073029207530570</id><published>2011-01-24T12:56:00.001-05:00</published><updated>2011-01-25T07:26:57.767-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-25T07:26:57.767-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="MetroStack" /><title>Metro Stack</title><content type="html">&lt;a href="http://lh4.ggpht.com/_W3WFfs_0QgY/TT27riZEw6I/AAAAAAAAAHA/suRilW2PHr4/s1600-h/logo%5B6%5D.png"&gt;&lt;img align="right" alt="logo" border="0" height="104" src="http://lh3.ggpht.com/_W3WFfs_0QgY/TT27r7pCA6I/AAAAAAAAAHE/uECDq9Mn7RY/logo_thumb%5B4%5D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; float: right; margin: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="logo" width="104" /&gt;&lt;/a&gt;&lt;br /&gt;
I have a low attention span for side projects. I’ve come to find out that if I cannot complete the project in two days, the chances of me finishing that side project rapidly diminish. I am starting to accept this and find ways to increase my two day window. Metro Stack was created out of a challenge from &lt;a href="http://twitter.com/#!/johncoder" target="_blank"&gt;John Nelson&lt;/a&gt; to create a well written &lt;a href="http://en.wikipedia.org/wiki/Metro_Design_Language" target="_blank"&gt;Metro&lt;/a&gt; template. John did a great job on some mockups for a blog he and I are working on that followed the &lt;a href="http://en.wikipedia.org/wiki/Metro_Design_Language" target="_blank"&gt;Metro&lt;/a&gt; theme. I thought I could one-up him and create a template for a WPF application that could work for any list driven content. Knowing fully that I had approximately two days to finish the project, I began.&lt;br /&gt;
&lt;br /&gt;
The thought was to create a simple template with minimal to zero code behind. You would be able to populate a view model that contained all the data that is relevant to your application. Then you could override the styling in &lt;a href="http://www.microsoft.com/expression/products/blend_overview.aspx" target="_blank"&gt;Blend&lt;/a&gt; for whatever different theming or additional behavior you needed. Going into the application I knew of some of the challenges in a Metro design:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://stevenhook.blogspot.com/2011/01/wpf-borderless-window-controls.html"&gt;No window border or title bar while also supporting a mouse drag&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stevenhook.blogspot.com/2011/01/wpf-borderless-window-controls.html"&gt;A custom control box&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Strong use of &lt;a href="http://en.wikipedia.org/wiki/Segoe" target="_blank"&gt;Segoe UI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Docking/Undocking a window with no border&lt;/li&gt;
&lt;li&gt;Drop shadow around the application window&lt;/li&gt;
&lt;li&gt;Animations! Metro is all about subtle slide in animations everywhere.&lt;/li&gt;
&lt;li&gt;Making a pivot control for WPF&lt;/li&gt;
&lt;/ul&gt;As I was writing the themed WPF page I started thinking, “How am I going to show that I am clearly the better programmer over John without some data to show in it?” I needed some interesting sample data to show to a developer. Twitter or Netflix are the usual victims of a sample data feed but why not be different. I wanted to create a Metro themed Stack Overflow.&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;It was at this moment that Metro Stack was born.&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Since then, I have migrated my project to be exclusively Metro Stack and put the Metro templating project on the shelf for another day (or never). Before I made the decision to switch projects I dumped an entire day into the Metro Stack UI and MVVM binding support to start tackling the known challenges. I came up with some pretty impressive results for one day, but more importantly I got to reset my side project timer! Since I switched ideas I am back to zero days of development and have a fresh two days to finish my project. That’s good because there are all new types of challenges when writing a Stack Overflow reader. To ensure that I don’t abandon the project immediately after posting this I registered Metro Stack on &lt;a href="http://stackapps.com/" target="_blank"&gt;StackApps&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
For now, I’ll leave you with a prototype screenshot with real data from Stack Overflow. The application gets inspiration from &lt;a href="http://www.metrotwit.com/" target="_blank"&gt;MetroTwit&lt;/a&gt; and the &lt;a href="http://www.zune.net/en-US/products/software/download/default.htm" target="_blank"&gt;Microsoft Zune&lt;/a&gt; player. Look for more posts explaining how I tackled these challenges.&lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/_W3WFfs_0QgY/TT27sB3_KII/AAAAAAAAAHI/oWTxVAudQnc/s1600-h/Metro%5B6%5D.png"&gt;&lt;img alt="Metro" border="0" height="557" src="http://lh6.ggpht.com/_W3WFfs_0QgY/TT27sr2qQoI/AAAAAAAAAHM/jTypUsbQmq0/Metro_thumb%5B4%5D.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="Metro" width="678" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;em&gt;&lt;span style="font-size: x-small;"&gt;Note: OK, I don’t really stick to a strict two day per side project schedule, but I do tend to get distracted from projects and never go back. I just wanted to make sure that I stick with this one for as long as it is still interesting and useful.&lt;/span&gt;&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-4549073029207530570?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/4549073029207530570/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2011/01/metro-stack.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/4549073029207530570?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/4549073029207530570?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2011/01/metro-stack.html" title="Metro Stack" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_W3WFfs_0QgY/TT27r7pCA6I/AAAAAAAAAHE/uECDq9Mn7RY/s72-c/logo_thumb%5B4%5D.png?imgmax=800" height="72" width="72" /><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;A04ERXg4eSp7ImA9Wx9SGUU.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-3437803604014042060</id><published>2010-12-10T09:05:00.000-05:00</published><updated>2010-12-10T09:05:04.631-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-10T09:05:04.631-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>Silverlight DataGrid Column Binding</title><content type="html">I may be relatively new to Silverlight and MVVM but I know enough that I should be able to bind to a ObservableCollection&amp;lt;DataGridColumn&amp;gt;. What’s up with that?   &lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_W3WFfs_0QgY/TQIyjlLyw1I/AAAAAAAAAGI/BB5T5qc6MIs/s1600-h/ColumnsBinding%5B2%5D.png"&gt;&lt;img alt="ColumnsBinding" border="0" height="244" src="http://lh4.ggpht.com/_W3WFfs_0QgY/TQIykA9JthI/AAAAAAAAAGM/kCf8-khOpU4/ColumnsBinding_thumb.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="ColumnsBinding" width="161" /&gt;&lt;/a&gt;&lt;br /&gt;
I tried forcing the binding in code and it tells be that Columns does not have a setter. What if my columns need to change at runtime? In my case they do! I have a feeling that columns will be bindable in the future so I want a solution that will be easy to swap out into an MVVM solution when this functionality becomes available. I just created a solution that worked for me, hopefully it works for you.&lt;br /&gt;
Starting with my &lt;strong&gt;view model&lt;/strong&gt; I want to add an ObservableCollection to hold my columns I want the &lt;strong&gt;view&lt;/strong&gt; to bind to.    &lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:505c8ff3-d623-4fbc-a2cb-1afea90cbc95" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 279px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;DataGridColumn&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; _columns;
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;DataGridColumn&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; Columns
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    get&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        return&lt;/span&gt;&lt;span style="color: black;"&gt; _columns;
    }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    set&lt;/span&gt;&lt;span style="color: black;"&gt;
    {
        _columns &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; value;
        NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Columns&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;);
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;This is common MVVM code, having a class that implements INotifyPropertyChanged. It is also important to note that this is the same way it would be implemented if binding in xaml actually worked for DataGridColumns. Now I can modify this local list and ideally the Column list would be bound in xaml to the DataGrid.Columns property.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:23e821a7-641b-4b04-9430-728d7608699d" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 369px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; MyViewModel()
{
    ...
    Columns &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;DataGridColumns&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;();
}

&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; ChangeDataGridColumns()
{
    Columns.Clear();
    Columns.Add(&lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; DataGridTextColumn
    {
        Binding &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; Binding(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Column1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;),
        Header &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Column1Header&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;,
        Visibility &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; Visibility.Visible
    });
    ...
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;This code is simply creating a new column collection then eventually some action will call ChangeDataGridColumns which will remove all other columns and create a new column or columns. I am also demonstrating a binding in code. Elsewhere in my view model I am binding the DataGrid.ItemsSource property to an ObservableCollection&amp;lt;Widget&amp;gt;. The binding is the property that says show the column &lt;em&gt;Widget.Column1&lt;/em&gt; as the data for this column.&lt;br /&gt;
&lt;br /&gt;
The interesting thing here is that now I can bind to stuff that even Blend doesn’t allow you to bind to, like Header and Visibility. In my case, this is valuable because my users can specify what they want the Header text to be for each column and I determine its visibility at runtime based on certain criteria.&lt;br /&gt;
&lt;br /&gt;
Now I need to write some view code. MVVM purists might want to stop here.&lt;br /&gt;
&lt;br /&gt;
Since the Columns list on a DataGrid is an ObservableCollection we have a changed event we can access. I wrote some basic code behind to get to a loaded event and wire up an event handler for the Columns CollectionChanged event.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:9ff2e1e6-7d17-44e6-8ff5-2bdaf7d05a64" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 254px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; MainPage()
{
    InitializeComponent();
    Loaded &lt;/span&gt;&lt;span style="color: black;"&gt;+=&lt;/span&gt;&lt;span style="color: black;"&gt; MainPageLoaded;
}

&lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; MainPageLoaded(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, RoutedEventArgs e)
{
    ...
    myViewModel.Columns.CollectionChanged &lt;/span&gt;&lt;span style="color: black;"&gt;+=&lt;/span&gt;&lt;span style="color: black;"&gt; ColumnsCollectionChanged;
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;This is really doing the same thing binding does, only we’re going to see the code. The idea is that in the ColumnsCollectionChanged handler we are going to recognize changes to the view model’s Column collection and make the same changes on the view’s DataGrid control. I just recently wrote this code so I might not have worked out all possible scenarios yet.&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3587d779-58d1-4847-b7f3-1c493a680061" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 480px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; ColumnsCollectionChanged(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, NotifyCollectionChangedEventArgs e)
{
&lt;/span&gt;&lt;span style="color: blue;"&gt;    if&lt;/span&gt;&lt;span style="color: black;"&gt; (e.Action &lt;/span&gt;&lt;span style="color: black;"&gt;==&lt;/span&gt;&lt;span style="color: black;"&gt; NotifyCollectionChangedAction.Reset)
    {
        myDataGrid.Columns.Clear();
    }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    else&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt; (e.Action &lt;/span&gt;&lt;span style="color: black;"&gt;==&lt;/span&gt;&lt;span style="color: black;"&gt; NotifyCollectionChangedAction.Add)
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        foreach&lt;/span&gt;&lt;span style="color: black;"&gt; (DataGridColumn column &lt;/span&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt;&lt;span style="color: black;"&gt; e.NewItems)
        {
            myDataGrid.Columns.Add(column);
        }
    }
&lt;/span&gt;&lt;span style="color: blue;"&gt;    else&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt; (e.Action &lt;/span&gt;&lt;span style="color: black;"&gt;==&lt;/span&gt;&lt;span style="color: black;"&gt; NotifyCollectionChangedAction.Remove)
    {
&lt;/span&gt;&lt;span style="color: blue;"&gt;        foreach&lt;/span&gt;&lt;span style="color: black;"&gt; (DataGridColumn column &lt;/span&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt;&lt;span style="color: black;"&gt; e.OldItems)
        {
            myDataGrid.Columns.Remove(column);
        }
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;It may not be perfect MVVM code but it can’t be. Once the ObservableCollection&amp;lt;DataGridColumn&amp;gt; property can be bound all we need to do is take out this crappy code behind and replace it with:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:abec7a46-f5fb-45a9-8df5-4736340f3260" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 128px; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;sdk:DataGrid
&lt;/span&gt;&lt;span style="color: red;"&gt;    x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="myDataGrid"&lt;/span&gt;&lt;span style="color: red;"&gt;
    ItemsSource&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding Widgets}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;="&lt;/span&gt;&lt;span style="color: olive;"&gt;{Binding Columns}&lt;/span&gt;&lt;span style="color: blue;"&gt;"&lt;/span&gt;&lt;span style="color: red;"&gt;
    AutoGenerateColumns&lt;/span&gt;&lt;span style="color: blue;"&gt;="False"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Until then… the code behind solution will work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-3437803604014042060?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/3437803604014042060/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/12/silverlight-datagrid-column-binding.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3437803604014042060?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3437803604014042060?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/12/silverlight-datagrid-column-binding.html" title="Silverlight DataGrid Column Binding" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_W3WFfs_0QgY/TQIykA9JthI/AAAAAAAAAGM/kCf8-khOpU4/s72-c/ColumnsBinding_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUMDQXk7eip7ImA9Wx9TFE4.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-1545606283630174390</id><published>2010-11-22T09:43:00.003-05:00</published><updated>2010-11-22T09:51:10.702-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-22T09:51:10.702-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>JavaScript Bridge for Silverlight</title><content type="html">I’ve been using JavaScript to send simple messages to and from Silverlight for quite some time now. I have even talked about it in my “&lt;a href="http://stevenhook.blogspot.com/2010/07/aspnet-mvc-and-silverlight-playing-nice.html" target="_blank"&gt;ASP.NET MVC and Silverlight Playing Nice&lt;/a&gt;” talk at the Pittsburgh .NET meeting and most recently at &lt;a href="http://codecamppgh.com/CodeCamp2010_2.aspx" target="_blank"&gt;Pittsburgh Code Camp 2010.2&lt;/a&gt;.&lt;br /&gt;
I added a simple JavaScript/jQuery bridge to the &lt;a href="http://bitbucket.org/swhook52/stevenhookblogcode/src/d43e49e17ee3/MvcSilverlight/" target="_blank"&gt;MVCSilverlight project&lt;/a&gt; I have used in previous posts. If you have not read the other posts, MVCSilverlight demonstrates basic Silverlight integration into a ASP.NET MVC project. This demonstration could also apply to a web forms project with a few minor changes.&lt;br /&gt;
Let’s start off with the view. My index view for my ASP.NET MVC project looks like this…&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:956f6948-b963-47fe-b06d-d1980d428e07" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 153px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;h2&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;Javascript Bridge Example&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;h2&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;input &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="message"&lt;/span&gt;&lt;span style="color: red;"&gt; type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text"&lt;/span&gt;&lt;span style="color: red;"&gt; value&lt;/span&gt;&lt;span style="color: blue;"&gt;="Message"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;input &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="send-message"&lt;/span&gt;&lt;span style="color: red;"&gt; type&lt;/span&gt;&lt;span style="color: blue;"&gt;="button"&lt;/span&gt;&lt;span style="color: red;"&gt; value&lt;/span&gt;&lt;span style="color: blue;"&gt;="Send Message"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; 

&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;h2&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;Silverlight Integration&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;h2&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;p&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="background-color: yellow; color: black;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;: Html.DisplayFor(m &lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; m.SilverightSample) &lt;/span&gt;&lt;span style="background-color: yellow; color: black;"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;p&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/_W3WFfs_0QgY/TOqBjpm5a5I/AAAAAAAAAF4/DDz1L26_l00/s1600-h/JavascriptBridge3.png"&gt;&lt;img align="left" alt="JavascriptBridge" border="0" height="354" src="http://lh4.ggpht.com/_W3WFfs_0QgY/TOqBj9wmGII/AAAAAAAAAF8/riPwHBot-4c/JavascriptBridge_thumb1.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; float: left; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="JavascriptBridge" width="269" /&gt;&lt;/a&gt;I want to start with communication from Silverlight to the web because it is relatively simple. Don’t be afraid of the &lt;em&gt;DisplayFor&lt;/em&gt; in the Silverlight integration. That is the display template I have setup to show my Silverlight Plugin. The idea is that I want to write a message in the Silverlight message input, click the send button and Silverlight sends that message to the web page and processes the message. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
My Silverlight page is still called MainPage and no, this sample is not using &lt;a href="http://en.wikipedia.org/wiki/Model_View_ViewModel" target="_blank"&gt;MVVM&lt;/a&gt; so we will be using good ol’ code behind. On our button click from the Silverlight Send Message button we want to communicate with the html page and access a JavaScript method if it exists. You can write the code just like that. Here’s the Silverlight button click code.&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:f3ed1ae9-8111-4d0c-82c3-fefd347c3fd0" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 127px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; Button_Click(&lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; sender, System.Windows.RoutedEventArgs e)
{
var script &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; (ScriptObject)HtmlPage.Window.GetProperty(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;MessageFromSilverlight&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;);
script.InvokeSelf(MessageTextbox.Text.Trim());
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;It is pretty close to what I said. Access the &lt;em&gt;System.Windows.Browser.HtmlPage&lt;/em&gt; class and get a property (in this case a function) called &lt;em&gt;MessageFromSilverlight&lt;/em&gt;. The one non-intuitive part of this is casting the property to &lt;em&gt;ScriptObject&lt;/em&gt;. Once you have a reference to the script you can invoke it with any number of arguments you want. In my case, I am passing the text from the message textbox.&lt;br /&gt;
On the web page side of this. You can add some JavaScript to the page and define a function that the Silverlight method can see.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:b4d10bf4-55e7-4ff1-af21-c046da4d09a7" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 126px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;
&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: blue;"&gt;function&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; MessageFromSilverlight(message) {
alert(&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;Silverlight tells Web "&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; &lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;+&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; message &lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;+&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; &lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;"&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;);
$(&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;#message&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;).val(message);
};
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If you happen to spell the JavaScript function name incorrectly then try to access the script object you will get a &lt;em&gt;NullReferenceException&lt;/em&gt; so be sure to handle that properly.&lt;br /&gt;
&amp;nbsp;&lt;a href="http://lh4.ggpht.com/_W3WFfs_0QgY/TOqBkc7ohII/AAAAAAAAAGA/CHRtJWldKA0/s1600-h/NullReferenceException%5B2%5D.png"&gt;&lt;img alt="NullReferenceException" border="0" height="140" src="http://lh5.ggpht.com/_W3WFfs_0QgY/TOqBk3un4jI/AAAAAAAAAGE/2Fjyn8NEIko/NullReferenceException_thumb.png?imgmax=800" style="background-image: none; border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="NullReferenceException" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;That is the entire process for sending information from Silverlight to the Web page.&lt;br /&gt;
&lt;h2&gt;Web to Silverlight&lt;/h2&gt;Communication from the web page to Silverlight requires just a little bit more knowledge of how the two can talk to each other. In the MainPage.xaml, define the method you want the web page to call via JavaScript. You can write this just like any other public method. Once that is written, one of the keys to opening that communication is decorating your method with the attribute [ScriptableMember]&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:1868e386-6dae-49cd-9288-7bc198c512d3" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 109px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;[ScriptableMember]
&lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; MessageFromWeb(&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt; message)
{
MessageTextbox.Text &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; message.Trim();
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
You would think that is all you need to do, but there are two more steps in Silverlight. Even though you told the method it can be called by decorating it with [ScriptableMember], you also need to decorate the class with the attribute [ScriptableType]. If you read the description of these two attributes, you will be even more confused, because I have not found the descriptions to be accurate.&lt;br /&gt;
&lt;br /&gt;
[ScriptableMember]&lt;br /&gt;
&lt;em&gt;Indicates that a specific property, method, or event is accessible to JavaScript callers.&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
[ScriptableType]&lt;br /&gt;
&lt;em&gt;Indicates that all public properties, methods, and events on a managed type are available to JavaScript code…&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
From the descriptions, you would think you would only need the [ScriptableMember] or only need [ScriptableType] without [ScriptableMember] and JavaScript would be able to access it. I have not found this to be the case. You need both attributes defined. Additionally, you need to register the class with a name so that JavaScript can call it. You do this in the constructor.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3a59b640-38b1-4365-90f4-510c2bde9456" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 151px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;&lt;span style="color: black;"&gt; MainPage()
{
InitializeComponent();

&lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt; (HtmlPage.IsEnabled)
HtmlPage.RegisterScriptableObject(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Communicator&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;, &lt;/span&gt;&lt;span style="color: blue;"&gt;this&lt;/span&gt;&lt;span style="color: black;"&gt;);
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Notice the &lt;em&gt;RegisterScriptableObject&lt;/em&gt; call. You can name the reference anything you want. This name will be used in JavaScript when you reference the Silverlight plugin.&lt;br /&gt;
&lt;br /&gt;
Let’s take a look at the JavaScript side of calling Silverlight. First I am going to use jQuery to wire up my button click on the html page so that it calls a JavaScript function when I click it.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:75a45f64-7338-43d9-bf52-d08eb36f8550" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 169px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;
    $(document).ready(&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: blue;"&gt;function&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; () {
        $(&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;#send-message&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;).click(&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: blue;"&gt;function&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; () {
&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: blue;"&gt;            var&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; message &lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;=&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt; $(&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;#message&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;'&lt;/span&gt;&lt;span style="background-color: whitesmoke; color: black;"&gt;).val();
            MessageToSilverlight(message);
        });
    });
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;When I click the button on the html page it will call &lt;em&gt;MessageToSilverlight&lt;/em&gt; with the message typed in the html textbox. Now we can define the JavaScript function to call Silverlight. First, we need to reference the html &amp;lt;object&amp;gt; tag that Silverlight uses. I abstract this object tag away so I don’t have to deal with it. If you want to see where it is in my code, it is in my &lt;a href="http://bitbucket.org/swhook52/stevenhookblogcode/src/d43e49e17ee3/MvcSilverlight/MvcSilverlight/Views/Shared/DisplayTemplates/SilverlightObject.ascx" target="_blank"&gt;DisplayTemplates&lt;/a&gt;. Define an id on that tag, something like: &amp;lt;object id=”silverlight-plugin” …&amp;gt;. Now you can reference that object tag and communicate with it. You have a stylistic choice on how you want to get that object control. If you know JavaScript, you can use:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:34253703-a079-4f60-acff-bc79ec9f512d" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 25px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;var&lt;/span&gt;&lt;span style="color: black;"&gt; control &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; document.getElementById(&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;silverlight-plugin&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;If you are afraid of JavaScript, you have a few options. Either way, you need to use JavaScript to get to that “Communicator” scriptable object we created in Silverlight, but you can get there through jQuery if you understand how jQuery selects elements. jQuery selects a list. Even if you select one element, jQuery will consider that a list of one element. You can achieve the same functionality as JavaScript’s &lt;em&gt;getElementById&lt;/em&gt; if you use jQuery’s &lt;em&gt;get&lt;/em&gt; method. It is important to note that once you get a result from jQuery’s &lt;em&gt;get&lt;/em&gt; method you are no longer in jQuery. You can no longer use jQuery methods on that result. Here is the jQuery equivalent.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:6289d028-9152-4df6-9245-5eba59026dc1" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 22px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;var&lt;/span&gt;&lt;span style="color: black;"&gt; control &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; $(&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;#silverlight-plugin&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;).get(&lt;/span&gt;&lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Once you have the control you would think you could just call: &lt;em&gt;control.Communicator.MessageFromWeb(message);.&lt;/em&gt; Unfortunately, there is one more level of complexity. The Communicator scriptable object we defined is off of the control’s &lt;em&gt;context&lt;/em&gt; property. Your end result method call becomes:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:9f89a6eb-c0ec-4180-b550-8d750d6d9170" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 230px; overflow: auto; white-space: pre-wrap; width: 683px; word-wrap: break-word;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; MessageToSilverlight(message) {
    alert(&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;Web tells Silverlight "&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;+&lt;/span&gt;&lt;span style="color: black;"&gt; message &lt;/span&gt;&lt;span style="color: black;"&gt;+&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;);

&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; JavaScript selector&lt;/span&gt;&lt;span style="color: green;"&gt;
&lt;/span&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: green;"&gt;//&lt;/span&gt;&lt;span style="color: green;"&gt;var control = document.getElementById('silverlight-plugin');&lt;/span&gt;&lt;span style="color: green;"&gt;
&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: green;"&gt;    //&lt;/span&gt;&lt;span style="color: green;"&gt; jQuery selector&lt;/span&gt;&lt;span style="color: green;"&gt;
&lt;/span&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;var&lt;/span&gt;&lt;span style="color: black;"&gt; control &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; $(&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;#silverlight-plugin&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;).get(&lt;/span&gt;&lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;);

&lt;/span&gt;&lt;span style="color: blue;"&gt;    if&lt;/span&gt;&lt;span style="color: black;"&gt; (control &lt;/span&gt;&lt;span style="color: black;"&gt;!=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;null&lt;/span&gt;&lt;span style="color: black;"&gt;) {
        control.content.Communicator.MessageFromWeb(message);
    }
};&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
You can view the entire source code for this project at my blog’s &lt;a href="http://bitbucket.org/swhook52/stevenhookblogcode/src/d43e49e17ee3/MvcSilverlight/" target="_blank"&gt;BitBucket&lt;/a&gt; page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-1545606283630174390?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/1545606283630174390/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/11/javascript-bridge-for-silverlight.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1545606283630174390?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1545606283630174390?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/11/javascript-bridge-for-silverlight.html" title="JavaScript Bridge for Silverlight" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_W3WFfs_0QgY/TOqBj9wmGII/AAAAAAAAAF8/riPwHBot-4c/s72-c/JavascriptBridge_thumb1.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0AMRXozfSp7ImA9Wx5bGEw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-3568627694914849363</id><published>2010-11-03T17:24:00.003-04:00</published><updated>2010-11-03T17:29:44.485-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-03T17:29:44.485-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="XML" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Parsing XML using C#</title><content type="html">Time after time I find myself referring to a stack overflow post that I answered when I need to write code to parse XML quickly. I thought I would blog the code instead. If nothing else, it will save me a few clicks.&lt;br /&gt;
Considering I have the following XML:&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:07dc776e-6f3d-4c1f-bfe6-3d582374a985" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 175px; overflow: auto; width: 400px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Changesets&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Changeset&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;185:04dbb0d95f27&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;User&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;shook&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;User&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Date&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;Wed Nov 03&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Date&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Summary&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;Text Here&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Summary&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Changeset&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;Changesets&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Start off with a new using&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:9a24d41f-2243-49b8-a8a4-9f74efee8d31" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 22px; overflow: auto; width: 400px;"&gt;&lt;div&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt;&lt;span style="color: black;"&gt; System.Xml.Linq;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;Write a linq query to open your xml file. Get the descendants of the element that is grouping the elements you want to parse. Then do something with the result. In my case I am populating and returning a container object.&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:253f2543-0dff-4e24-b2e9-96858c4b4676" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 238px; overflow: auto; width: 683px;"&gt;&lt;div&gt;&lt;span style="color: black;"&gt;XDocument changesetXML &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; XDocument.Load(Server.MapPath(&lt;/span&gt;&lt;span style="color: maroon;"&gt;@"&lt;/span&gt;&lt;span style="color: maroon;"&gt;~\changesets.xml&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;));

&lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;&lt;span style="color: black;"&gt; from changeset &lt;/span&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt;&lt;span style="color: black;"&gt; changesetXML.Descendants(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Changeset&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;)
       select &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; ChangeSet
       {
           Id &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; changeset.Element(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;id&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;).Value,
           User &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; changeset.Element(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;User&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;).Value,
           DateAdded &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; changeset.Element(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Date&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;).Value,
           Summary &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; changeset.Element(&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;Summary&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;).Value
       };&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-3568627694914849363?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/3568627694914849363/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/11/parsing-xml-using-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3568627694914849363?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3568627694914849363?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/11/parsing-xml-using-c.html" title="Parsing XML using C#" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEAAR38yfip7ImA9Wx5TEks.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-3530905256162824511</id><published>2010-07-27T16:20:00.001-04:00</published><updated>2010-07-27T16:32:26.196-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-27T16:32:26.196-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><title>ASP.NET MVC 3 Preview 1</title><content type="html">&lt;p&gt;I just upgraded to the &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=cb42f741-8fb1-4f43-a5fa-812096f8d1e8" target="_blank"&gt;MVC 3 preview&lt;/a&gt; that just came out today.&lt;/p&gt;  &lt;p&gt;I did not have time to play around with the &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx" target="_blank"&gt;new features&lt;/a&gt; so I just installed it and kept working on my existing MVC 2 application. Later in the day when I ran my application I found that I was receiving the error&lt;/p&gt;  &lt;h4&gt;&lt;i&gt;No parameterless constructor defined for this object.&lt;/i&gt;&lt;/h4&gt;  &lt;p&gt;** commence freaking out **&lt;/p&gt;  &lt;p&gt;It appears that the install of MVC 3 Preview 1 has affected my existing MVC 2 application. Or so it seemed.&lt;/p&gt;  &lt;p&gt;Uninstalling MVC 3 Preview 1 fixes the problem. Installing it again causes the problem.&lt;/p&gt;  &lt;p&gt;My MVC 2 application is using &lt;a href="http://ninject.org/" target="_blank"&gt;Ninject&lt;/a&gt; 2 so I can inject dependencies into my constructors and they do not require parameterless constructors. This made me think that it had to be a problem with Ninject, but all the proper breakpoints were being hit in my Ninject application to set the default controller factory.&lt;/p&gt;  &lt;p&gt;I attempted to reproduce the problem in a simple project (since I was convinced it was Ninject). After uninstalling MVC 3, I created a simple application that required an interface to be injected into my HomeController using Ninject. I ran it to see that it works. Then I installed MVC 3 just as I did before but this time the sample application worked.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;So what is the difference? More importantly, what is the solution?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;It’s all in your references. Looking side by side at my project files, I can see a difference. Here is the sample MVC 2 project that worked:&lt;/p&gt;  &lt;pre style="background-color: rgb(29,29,37)" class="code"&gt;&lt;span style="color: #ffefca"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Reference &lt;/span&gt;&lt;span style="color: #c4826f"&gt;Include&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&amp;quot;System.Web.Mvc,&lt;br /&gt;                    Version=2.0.0.0,&lt;br /&gt;                    Culture=neutral,&lt;br /&gt;                    PublicKeyToken=31bf3856ad364e35,&lt;br /&gt;                    processorArchitecture=MSIL&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here is the production MVC 2 application that did not work after installing MVC 3 Preview 1:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: rgb(29,29,37)" class="code"&gt;&lt;span style="color: #ffefca"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Reference &lt;/span&gt;&lt;span style="color: #c4826f"&gt;Include&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&amp;quot;System.Web.Mvc,&lt;br /&gt;                    Version=2.0.0.0,&lt;br /&gt;                    Culture=neutral,&lt;br /&gt;                    PublicKeyToken=31bf3856ad364e35,&lt;br /&gt;                    processorArchitecture=MSIL&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;SpecificVersion&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;False&amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;SpecificVersion&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Reference&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The difference being SpecificVersion. The hint text reads…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Specific Version&lt;/strong&gt; &lt;em&gt;Indicates whether this assembly can be resolved without regard to multi-targeting rules for assembly resolution.&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So there you have it. My production application is looking for the latest System.Web.Mvc DLL it could find even though I have specified I want to use 2.0.0.0. By either defaulting this property or explicitly setting SpecificVersion to True will tell the application to use the version you tell it to.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I do not believe this is any fault of MVC 3, MVC 2, Ninject, or anything else. This is just something to look out for when you get brave (as you should) and start looking at MVC 3 Preview 1.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-3530905256162824511?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/3530905256162824511/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/07/aspnet-mvc-3-preview-1.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3530905256162824511?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3530905256162824511?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/07/aspnet-mvc-3-preview-1.html" title="ASP.NET MVC 3 Preview 1" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;C0INQX44cCp7ImA9WxFbFE8.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-7894951467977233305</id><published>2010-07-06T09:00:00.001-04:00</published><updated>2010-07-06T09:06:30.038-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-06T09:06:30.038-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>ASP.NET MVC and Silverlight Playing Nice: Part Two</title><content type="html">&lt;p&gt;Now that I have been using my Silverlight helpers for sometime on my work and fun projects, I thought I would revisit my &lt;a href="http://stevenhook.blogspot.com/2010/04/aspnet-mvc-2-and-silverlight-playing.html" target="_blank"&gt;ASP.NET MVC and Silverlight playing nice&lt;/a&gt; post. I have added just a few features to it and I wanted to give you more code so that others can use this simple way to add Silverlight to ASP.NET MVC. I do not want to repeat myself too much so I’ll just show you some code. Most of it has been explained in the &lt;a href="http://stevenhook.blogspot.com/2010/04/aspnet-mvc-2-and-silverlight-playing.html" target="_blank"&gt;last post&lt;/a&gt; but some will be new.&lt;/p&gt;  &lt;p&gt;The first step is to create your Silverlight partial view. I find it better to write the view before the model for stuff like this. If you write the model first you will write the view to fit the model rather than writing the model to fit the view. This view will replace the test page you get from adding a Silverlight application to your MVC application. Here is my new partial.&lt;/p&gt;  &lt;pre style="background: black" class="code"&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;@ &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Control &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;Language&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #ff5846"&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;Inherits&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;MvcSilverlight.Models.SilverlightObject&amp;gt;&amp;quot; &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;form &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;id&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;form1&amp;quot; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;runat&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;server&amp;quot; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;style&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;height&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;100%&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;div &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;id&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;silverlightControlHost&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;object &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;data&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;data:application/x-silverlight-2,&amp;quot;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;type&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;application/x-silverlight-2&amp;quot;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;width&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.Size.Width &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;height&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.Size.Height &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;param &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;name&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;source&amp;quot;&lt;br /&gt;             &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;value&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Url.Content(&amp;quot;~/ClientBin/&amp;quot; + Model.XapName + &amp;quot;.xap&amp;quot;) &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;param &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;name&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;onError&amp;quot;&lt;br /&gt;             &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;value&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.OnSilverlightError &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;param &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;name&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;background&amp;quot;&lt;br /&gt;             &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;value&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.BackgroundColor.Name &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;param &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;name&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;minRuntimeVersion&amp;quot;&lt;br /&gt;             &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;value&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.MinimumRuntimeVersion &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;param &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;name&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;autoUpgrade&amp;quot;&lt;br /&gt;             &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;value&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.AutoUpgrade &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;if &lt;/span&gt;&lt;span style="color: #ffefca"&gt;(Model.Parameters != &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;null &lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;amp;&amp;amp; Model.Parameters.Count &amp;gt; 0) { &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;          &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;param &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;name&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;initParams&amp;quot; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;value&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Model.ParameterString &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt; } &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;a &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;href&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=4.0.50401.0&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #ff5846"&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;style&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;text-decoration&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;none&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;           &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;img &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;src&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;http://go.microsoft.com/fwlink/?LinkId=161376&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #ff5846"&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;alt&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;Get Microsoft Silverlight&amp;quot; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;style&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;border-style&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;none&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;a&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;object&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;iframe &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;id&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;_sl_historyFrame&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #ff5846"&gt;            &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;style&lt;/span&gt;&lt;span style="color: #ffefca"&gt;=&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;visibility&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;hidden&lt;/span&gt;&lt;span style="color: #ff5846"&gt;;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;height&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;0px&lt;/span&gt;&lt;span style="color: #ff5846"&gt;;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;width&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;0px&lt;/span&gt;&lt;span style="color: #ff5846"&gt;;&lt;/span&gt;&lt;span style="color: #c4826f"&gt;border&lt;/span&gt;&lt;span style="color: #ff5846"&gt;:&lt;/span&gt;&lt;span style="color: #ffefca"&gt;0px&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #ffefca"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;iframe&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;div&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #0e98eb"&gt;form&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you read the last post you will see that I changed my partial a bit.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I added the colon to the code nuggets to get the implied Html.Encode calls. I also added parameters. I found that my Silverlight applications needed to know some info about my MVC applications to work. In one example I have, my file upload Silverlight control needed to know where to store the meta data in my database about the file being uploaded. To do this, I conditionally add the parameter element then add the parameters I want using a name value pair dictionary. Remember that this is going to be a display template so you need to put it in &lt;strong&gt;Views &lt;/strong&gt;&amp;gt; &lt;strong&gt;Shared &lt;/strong&gt;&amp;gt; &lt;strong&gt;DisplayTemplates &lt;/strong&gt;folder and name it with the same name of the type you are strongly typing it to. In this case it will be SilverlightObject.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Next you will want to create a model that will hold the info on how to load your Silverlight control. You’ll see that it is pretty simple. Here is mine.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: black" class="code"&gt;&lt;span style="color: #d8e7fe"&gt;public class &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;SilverlightObject&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public string &lt;/span&gt;&lt;span style="color: #ffefca"&gt;XapName { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Size &lt;/span&gt;&lt;span style="color: #ffefca"&gt;Size { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public string &lt;/span&gt;&lt;span style="color: #ffefca"&gt;OnSilverlightError { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Color &lt;/span&gt;&lt;span style="color: #ffefca"&gt;BackgroundColor { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public string &lt;/span&gt;&lt;span style="color: #ffefca"&gt;MinimumRuntimeVersion { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public bool &lt;/span&gt;&lt;span style="color: #ffefca"&gt;AutoUpgrade { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;IDictionary&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;string&lt;/span&gt;&lt;span style="color: #ffefca"&gt;, &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;string&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt; Parameters { &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;set&lt;/span&gt;&lt;span style="color: #ffefca"&gt;; }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public string &lt;/span&gt;&lt;span style="color: #ffefca"&gt;ParameterString&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;get&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #ffefca"&gt;{&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;StringBuilder &lt;/span&gt;&lt;span style="color: #ffefca"&gt;sb = &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;new &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;StringBuilder&lt;/span&gt;&lt;span style="color: #ffefca"&gt;();&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;foreach &lt;/span&gt;&lt;span style="color: #ffefca"&gt;(&lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;var &lt;/span&gt;&lt;span style="color: #ffefca"&gt;parameter &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;in &lt;/span&gt;&lt;span style="color: #ffefca"&gt;Parameters)&lt;br /&gt;            {&lt;br /&gt;                sb.Append(parameter.Key);&lt;br /&gt;                sb.Append(&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;=&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;);&lt;br /&gt;                sb.Append(parameter.Value);&lt;br /&gt;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;if &lt;/span&gt;&lt;span style="color: #ffefca"&gt;(Parameters.Count &amp;gt; 1)&lt;br /&gt;                    sb.Append(&lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;);&lt;br /&gt;            }&lt;br /&gt;                &lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;return &lt;/span&gt;&lt;span style="color: #ffefca"&gt;sb.ToString();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public &lt;/span&gt;&lt;span style="color: #ffefca"&gt;SilverlightObject()&lt;br /&gt;    {&lt;br /&gt;        OnSilverlightError = &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;onSilverlightError&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;;&lt;br /&gt;        BackgroundColor = &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Color&lt;/span&gt;&lt;span style="color: #ffefca"&gt;.Black;&lt;br /&gt;        MinimumRuntimeVersion = &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;4.0.50524.0&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;;&lt;br /&gt;        AutoUpgrade = &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;true&lt;/span&gt;&lt;span style="color: #ffefca"&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;It is just a container for some very specific options for Silverlight that you plug into your partial view&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Also, there is a property to get a parameter string so that we can simply drop that value into the parameter value if we have any. This is just another way to make the view extremely simple and not require business logic.This class is just saved in your models folder.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You will also want a ViewModel for whatever page you will be showing the Silverlight control on.Typically you would have a bit more in the view model an just the Silverlight control but for my example I will just have the SIlverlight control.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #d8e7fe"&gt;public class &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;IndexViewModel&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;public &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;SilverlightObject &lt;/span&gt;&lt;span style="color: #ffefca"&gt;SilverightSample;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now you just need to wire it up in true MVC fashion!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In my index Action of my home controller I will create a new SilverlightObject and pass it into my ViewModel which will be passed into my Index View.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="color: #d8e7fe"&gt;public &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;ActionResult &lt;/span&gt;&lt;span style="color: #ffefca"&gt;Index()&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;var &lt;/span&gt;&lt;span style="color: #ffefca"&gt;parameters = &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;new &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Dictionary&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;string&lt;/span&gt;&lt;span style="color: #ffefca"&gt;, &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;string&lt;/span&gt;&lt;span style="color: #ffefca"&gt;&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        { &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;MyParameter&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;, &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;123&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;},&lt;br /&gt;        { &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;, &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;123abc&amp;quot; &lt;/span&gt;&lt;span style="color: #ffefca"&gt;},&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;var &lt;/span&gt;&lt;span style="color: #ffefca"&gt;silverlight = &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;new &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;SilverlightObject&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #ffefca"&gt;{&lt;br /&gt;        XapName = &lt;/span&gt;&lt;span style="color: #ff5846"&gt;&amp;quot;SilverlightSample&amp;quot;&lt;/span&gt;&lt;span style="color: #ffefca"&gt;,&lt;br /&gt;        Size = &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;new &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;Size&lt;/span&gt;&lt;span style="color: #ffefca"&gt;(300, 300),&lt;br /&gt;        Parameters = parameters&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;var &lt;/span&gt;&lt;span style="color: #ffefca"&gt;model = &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;new &lt;/span&gt;&lt;span style="color: #0e98eb"&gt;IndexViewModel&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #ffefca"&gt;{&lt;br /&gt;        SilverightSample = silverlight&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #d8e7fe"&gt;return &lt;/span&gt;&lt;span style="color: #ffefca"&gt;View(model);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now you can drop the control in your view that is strongly typed to your view model.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: black" class="code"&gt;&lt;span style="background: #ffff24"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #ffefca"&gt;: Html.DisplayFor(m =&amp;gt; m.SilverightSample) &lt;/span&gt;&lt;span style="background: #ffff24"&gt;%&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This design does not currently have a way to make the Silverlight control full screen.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I have not needed a Silverlight control to be full screen so that is probably why I never added it. If you wanted to make it full screen you could just have a boolean for full screen and change the height and width to be 100% in your partial.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_W3WFfs_0QgY/TDMo_ZPUPxI/AAAAAAAAAFE/dhWeJsQU_FY/s1600-h/MVCSilverlightSample%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="MVCSilverlightSample" border="0" alt="MVCSilverlightSample" src="http://lh4.ggpht.com/_W3WFfs_0QgY/TDMo__G5FPI/AAAAAAAAAFI/i2Kvv3xJDro/MVCSilverlightSample_thumb%5B3%5D.png?imgmax=800" width="496" height="567" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-7894951467977233305?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/7894951467977233305/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/07/aspnet-mvc-and-silverlight-playing-nice.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/7894951467977233305?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/7894951467977233305?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/07/aspnet-mvc-and-silverlight-playing-nice.html" title="ASP.NET MVC and Silverlight Playing Nice: Part Two" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_W3WFfs_0QgY/TDMo__G5FPI/AAAAAAAAAFI/i2Kvv3xJDro/s72-c/MVCSilverlightSample_thumb%5B3%5D.png?imgmax=800" height="72" width="72" /><thr:total>5</thr:total></entry><entry gd:etag="W/&quot;DEADRHc4eip7ImA9WxFVFk0.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-1877609845098357002</id><published>2010-06-14T23:34:00.002-04:00</published><updated>2010-06-15T08:59:35.932-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-15T08:59:35.932-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="OpenSearch" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="CodeCamp" /><title>OpenSearch in ASP.NET MVC</title><content type="html">&lt;div class="MsoNormal"&gt;I got tired of referring to my &lt;a href="http://stevenhook.blogspot.com/2010/04/code-camp-wrap-up.html"&gt;codecamp presentation&lt;/a&gt; every time I wanted to do another implementation of OpenSearch so I figured I would write it down.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;What is OpenSearch&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;OpenSearch is using that search bar that is built into most browsers. Google Chrome uses the address bar. Internet Explorer has a separate textbox for searching. This is defaulted to your default search engine that is setup when you run your browser for the first time, but you can have your browser search other sites if you tell it to. If you go to a site like &lt;a href="http://amazon.com/"&gt;Amazon&lt;/a&gt; and click the down arrow for your search textbox (in IE) you will see the search providers configured for Amazon.com.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;This stuff is easy to write, even if you have never even heard of OpenSearch before. It will literally take you 5 minutes to get running. So let’s do it!&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Step 1&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Do not go to &lt;a href="http://opensearch.org/"&gt;OpenSearch.org&lt;/a&gt; because it will only give you confusion and heartache.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Step 2 and Beyond&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Create a new XML file in the content folder of your site and call it &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;OpenSearch.xml&lt;/span&gt;. Here is the contents of my file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: small;"&gt;&lt;pre style="font-family: consolas;"&gt;&lt;pre style="font-family: consolas;"&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;
&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: small;"&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-family: Consolas; font-size: small;"&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;lt; ?&lt;span style="color: #0e98eb;"&gt;xml&lt;/span&gt;&amp;nbsp;&lt;span style="color: #c4826f;"&gt;version&lt;/span&gt;="1.0"&amp;nbsp;&lt;span style="color: #c4826f;"&gt;encoding&lt;/span&gt;="UTF-8"&amp;nbsp;? &amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;lt; &lt;span style="color: #0e98eb;"&gt;OpenSearchDescription&lt;/span&gt;&amp;nbsp;&lt;span style="color: #c4826f;"&gt;xmlns&lt;/span&gt;="http://a9.com/-/spec/opensearch/1.1/"&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color: #0e98eb;"&gt;ShortName&lt;/span&gt;&amp;gt;My Site’s Asset Finder&lt;span style="color: #0e98eb;"&gt;ShortName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color: #0e98eb;"&gt;Description&lt;/span&gt;&amp;gt;Find all your assets&lt;span style="color: #0e98eb;"&gt;Description&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color: #0e98eb;"&gt;Url&lt;/span&gt;&amp;nbsp;&lt;span style="color: #c4826f;"&gt;type&lt;/span&gt;="text/html"&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;       &lt;span style="color: #c4826f;"&gt;method&lt;/span&gt;="get"&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;       &lt;span style="color: #c4826f;"&gt;template&lt;/span&gt;="http://MySite.com/Home/Search/?q={searchTerms}"/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color: #0e98eb;"&gt;InputEncoding&lt;/span&gt;&amp;gt;UTF-8&lt;span style="color: #0e98eb;"&gt;InputEncoding&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color: #0e98eb;"&gt;SearchForm&lt;/span&gt;&amp;gt;http://MySite.com/&lt;span style="color: #0e98eb;"&gt;SearchForm&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background: black; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-background-themecolor: text1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;&lt;span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;lt; /&lt;span style="color: #0e98eb;"&gt;OpenSearchDescription&lt;/span&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;pre style="font-family: consolas;"&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
Nothing fancy here, but you wouldn’t know how to write it without looking it up. It is OpenSearch specific but the elements are easy to fill in. &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;ShortName &lt;/span&gt;and &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;Description &lt;/span&gt;just write in whatever you want the browser to show. The Url&amp;nbsp; template needs to be your site and point to the action you want it to go to. Alternatively you could write a route that corresponds to the Url you are supplying here. You will also want to supply a search terms parameter to your Url so that the action will be able to filter the results.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Next, you need to link to this XML file in your master page. In site.master, add the link to the header and change some of the attributes to suit your needs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background: black; mso-background-themecolor: text1;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: Consolas;"&gt;&lt;pre style="background: black; mso-background-themecolor: text1;"&gt;&lt;span style="font-family: Consolas;"&gt;&amp;lt; &lt;span style="color: #0e98eb;"&gt;link&lt;/span&gt;&amp;nbsp;&lt;span style="color: #d8e7fe;"&gt;href&lt;/span&gt;=&lt;span style="color: #ff5846;"&gt;"&lt;/span&gt;&lt;span style="background: #FFFF24; color: black;"&gt;&amp;lt; %&lt;/span&gt;=&amp;nbsp;Url.Content("~/Content/OpenSearch.xml")&amp;nbsp;&lt;span style="background: #FFFF24; color: black;"&gt;% &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black; mso-background-themecolor: text1;"&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #ffff24; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #ff5846;"&gt;      &lt;/span&gt;&amp;nbsp;&lt;span style="color: #d8e7fe;"&gt;rel&lt;/span&gt;=&lt;span style="color: #ff5846;"&gt;"search"&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black; mso-background-themecolor: text1;"&gt;&lt;span style="font-family: Consolas;"&gt;       &lt;span style="color: #d8e7fe;"&gt;title&lt;/span&gt;=&lt;span style="color: #ff5846;"&gt;"My Site’s Asset Finder"&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black; mso-background-themecolor: text1;"&gt;&lt;span style="font-family: Consolas;"&gt;       &lt;span style="color: #d8e7fe;"&gt;type&lt;/span&gt;=&lt;span style="color: #ff5846;"&gt;"application/opensearchdescription+xml"&lt;/span&gt; / &amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;The type is another one of those things you are not going to remember. Now that your site has a reference to the xml file and knows how to search your site, all you have to do is implement the action that you promised would be there.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Implementing the Action&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;In your Home controller (or whatever you defined in your &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;OpenSearch.xml&lt;/span&gt;) create a &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;Search &lt;/span&gt;action that can return a view filtering the results with the given query string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: black; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;span style="color: #d8e7fe; font-family: Consolas;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: Consolas;"&gt;&amp;nbsp;&lt;span style="color: #0e98eb;"&gt;ActionResult&lt;/span&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;&amp;nbsp;Search(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #d8e7fe;"&gt;string&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;&amp;nbsp;q)&lt;/span&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;var&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;&amp;nbsp;assets&amp;nbsp;=&amp;nbsp;_assetRepository.FindAll()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Name.Contains(q))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.OrderBy(m&amp;nbsp;=&amp;gt;&amp;nbsp;m.Name.IndexOf(q));
&amp;nbsp;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #d8e7fe;"&gt;var&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;&amp;nbsp;model&amp;nbsp;=&lt;/span&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: #d8e7fe;"&gt;new&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;span style="color: #0e98eb;"&gt;SearchViewModel&lt;/span&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assets&amp;nbsp;=&amp;nbsp;assets,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SearchTerm&amp;nbsp;=&amp;nbsp;q
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #d8e7fe;"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;&amp;nbsp;View(model);&lt;/span&gt;
&lt;span class="Apple-style-span" style="color: white;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;I just wrote a linq query to pull all the assets out of my repository where the asset’s name contains the search term and order the results so that the closest matches are first.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;In my example I am also creating a view model called &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;SearchViewModel&lt;/span&gt; that is just a container class that holds my asset objects and remembers my search term.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Creating the Search View&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;The last thing you need to do is implement the view you are calling in the &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;Search &lt;/span&gt;action. This is where you can write your implementation specific code. It will be strongly typed to whatever structure you use to hold your search results. Mine was &lt;span class="Apple-style-span" style="color: #0b5394;"&gt;SearchViewModel &lt;/span&gt;and this is what I have in my search view.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: #d8e7fe; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: black; font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-weight: normal; white-space: normal;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #d8e7fe; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: black; font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-weight: normal; white-space: normal;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #d8e7fe; font-family: Consolas;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: black; font-family: 'Times New Roman';"&gt;&lt;pre style="background: black;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0e98eb; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;h3&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Found&amp;nbsp;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: #FFFF24; color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;lt; %&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;Model.Assets.Count().ToString()&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;span style="background: #FFFF24;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;% &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;results&amp;nbsp;for&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;"&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;span style="background: #FFFF24;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;lt; %&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;: Model.SearchTerm&amp;nbsp;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: #FFFF24; color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;% &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black;"&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0e98eb; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;h3&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;

&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black;"&gt;&lt;span style="background: #FFFF24; color: black; font-family: Consolas;"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;lt; %&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe; font-family: Consolas;"&gt;foreach&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe; font-family: Consolas;"&gt;var&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;asset&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe; font-family: Consolas;"&gt;in&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Model.Assets)&amp;nbsp;{&amp;nbsp;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: #FFFF24; color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;% &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black;"&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt; &amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0e98eb; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;div&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #d8e7fe; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #ff5846; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;"search-result"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; background: black;"&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;span style="background: #FFFF24;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;lt; %&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;: asset.Name&amp;nbsp;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: #FFFF24; color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;% &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black;"&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0e98eb; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;div&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background: black;"&gt;&lt;span style="background: #FFFF24; color: black; font-family: Consolas;"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;lt; %&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: white; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"&gt;&lt;span style="background: #FFFF24;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;% &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #85ac8d; font-family: Consolas;"&gt;&lt;span class="Apple-style-span" style="color: black; font-family: 'Times New Roman';"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;This is just a basic implementation but now that you have a template you can make it whatever you want.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Build. Run.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Testing in Internet Explorer&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Internet Explorer is actually easier to work with OpenSearch than others are (weird, I know). Go to your site and you will see that the drop down on the search bar is glowing red/orange. If you click it, you will see your search provider! Click on the provider and anything you type into your search bar will be your query string parameter to your action method. Now if you enter in “Bacon” as your search term (as I often do), you will get a view of all assets with the word “Bacon” in the name.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Pretty sweet, or is it savory?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;You can also set your site’s search provider to be your default search provider. This will get you some added benefits when browsing. You can get buttons to search your site anytime you select text in Internet Explorer. You can also use the search bar to search your site even if you are not at your site.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Testing in Google Chrome&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Since Chome does not have a search textbox, it does not have a glowing dropdown button to select your new search provider. You need to be pretty direct with it and add the search provider. Right click the address bar and go to “Edit Search Engines…” Add a new one. I’ll call mine Asset Finder. The keyword is going to be “Asset” and the Url is the same as how I defined it in my OpenSearch.xml file only you add a %s where the search term should go. Mine looks like this: http://www.MySite.com/Home/Search/?q=%s&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now when you type "asset" in your address bar you will see Chrome recommend your search provider. You can tab to select it and start typing your query string. Chrome will insert the query string where you dropped %s in the Url.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Testing on a Mac&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Ha! I’m just kidding. &lt;i&gt;&lt;span style="line-height: 115%;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;I’m so clever&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-1877609845098357002?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/1877609845098357002/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/06/opensearch-in-aspnet-mvc.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1877609845098357002?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1877609845098357002?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/06/opensearch-in-aspnet-mvc.html" title="OpenSearch in ASP.NET MVC" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkMFRXg5cSp7ImA9WxFXGUo.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-8708398166274519486</id><published>2010-05-27T11:33:00.000-04:00</published><updated>2010-05-27T11:33:34.629-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-27T11:33:34.629-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Tag" /><title>Microsoft Tag</title><content type="html">&lt;a href="http://tag.microsoft.com/"&gt;Microsoft Tag&lt;/a&gt; is out of beta as of &lt;a href="http://twitter.com/microsofttag/status/14834484015"&gt;a few hours ago&lt;/a&gt;. If you are not familiar with the technology, you can think of it as a hyperlink for mobile devices. Developers can even get an API to create your own tags or use the web interface in the tag manager.&lt;br /&gt;
&lt;br /&gt;
As long as you have a phone with a camera and web access you can get the reader and start reading tags.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_W3WFfs_0QgY/S_6PEhN1WhI/AAAAAAAAAEs/Xj15RgjtbCY/s1600/Steven_Hook%27s_Blog_201052781834.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="370" src="http://4.bp.blogspot.com/_W3WFfs_0QgY/S_6PEhN1WhI/AAAAAAAAAEs/Xj15RgjtbCY/s400/Steven_Hook%27s_Blog_201052781834.jpeg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Here is a tag for my blog. The great part about tags is it is really up to the tagger to define the future of Microsoft Tag. It is only limited by your creativity on what and how to tag.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-8708398166274519486?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/8708398166274519486/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/05/microsoft-tag.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/8708398166274519486?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/8708398166274519486?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/05/microsoft-tag.html" title="Microsoft Tag" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_W3WFfs_0QgY/S_6PEhN1WhI/AAAAAAAAAEs/Xj15RgjtbCY/s72-c/Steven_Hook%27s_Blog_201052781834.jpeg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEACR3oyfip7ImA9WxFRE00.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-2959879701188543253</id><published>2010-04-26T13:26:00.000-04:00</published><updated>2010-04-26T13:26:06.496-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-26T13:26:06.496-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Productivity" /><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="CodeCamp" /><category scheme="http://www.blogger.com/atom/ns#" term="Mercurial" /><title>Code Camp Wrap Up</title><content type="html">Code camp 2010.1 is in the books.&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I presented on the topic of "&lt;b&gt;ASP.NET MVC Beyond the Project Template&lt;/b&gt;" at the &lt;a href="http://www.phillydotnet.org/"&gt;Philly&lt;/a&gt; and &lt;a href="http://codecamppgh.com/"&gt;Pittsburgh&lt;/a&gt; code camp. This presentation also marked my first contribution to both user groups.&amp;nbsp;The discussion was well received with several great comments from the reviews.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I wanted to take a moment to let everyone know where the content is for the presentation. You won't see any slides because I did not have any. I am a strong believer in code camp being about code and not slides. You can however take a look at the working project that was created in both demonstrations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I am hosting the project on BitBucket just as you saw in the discussion. You can browse it or pull it down at&amp;nbsp;&lt;a href="http://bitbucket.org/swhook52/thisiswhyyourefat"&gt;http://bitbucket.org/swhook52/thisiswhyyourefat&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The project includes a ton of useful practices for working with a remote team, setting up a great development environment from the start, using tools to maximize productivity, using &lt;a href="http://openidportablearea.codeplex.com/"&gt;OpenIdPortableArea&lt;/a&gt;, using &lt;a href="http://www.opensearch.org/"&gt;OpenSearch&lt;/a&gt;, and other interesting practices.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I also had a question from the &lt;a href="http://codecamppgh.com/"&gt;Pittsburgh Code Camp&lt;/a&gt; presentation that I did not have time to address in the discussion. The question was how to add Data Annotations to validate a model. The question was specifically how to get rid of the Id column on the register page when calling Html.EditorForModel(). I have added this to the project under the &lt;a href="http://bitbucket.org/swhook52/thisiswhyyourefat/src/tip/LinqToFat/User.cs"&gt;User.cs&lt;/a&gt;&amp;nbsp;file. So that was for you front row guy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Lastly, I want to say thank you to the organizers of &lt;a href="http://www.phillydotnet.org/"&gt;Philly&lt;/a&gt; and &lt;a href="http://codecamppgh.com/"&gt;Pittsburgh&lt;/a&gt; code camps, the attendees, and the reviewers for making my first contribution to the community one that I will not long forget. I plan to contribute more.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-2959879701188543253?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/2959879701188543253/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/04/code-camp-wrap-up.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2959879701188543253?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2959879701188543253?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/04/code-camp-wrap-up.html" title="Code Camp Wrap Up" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkYHQn0-eyp7ImA9WxFSFkQ.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-2575733276939068082</id><published>2010-04-19T11:28:00.002-04:00</published><updated>2010-04-19T12:22:13.353-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-19T12:22:13.353-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Productivity" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>ASP.NET MVC 2 and Silverlight Playing Nice</title><content type="html">&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;I have been getting into Silverlight quite a bit lately, probably because I have &lt;a href="http://www.microsoft.com/expression/"&gt;Expression Studio&lt;/a&gt; 3 now (and soon to be Expression Studio 4). Originally being a windows developer then moving to an MVC web developer makes me miss some of the windows like stuff I used to do. Silverlight has given that back to me and Expression Blend has made creating a UI fun and easy. I originally found it awkward to inject a Silverlight application into an MVC web app. I even gave up on Silverlight the first time I tried it. Now I have a bit more knowledge about the two and I wanted them to work well together. I found some of the pain points and simplified them a bit.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Recently I needed more control over uploading a file in an ASP.NET MVC application. I outsourced to Silverlight and created a new control library. Since the control library is a separate project I also need to create a Silverlight application to use the new user control. This new Silverlight control also needs to have a web application to use the Silverlight application. When you add the Silverlight application through the MVC project in the project options you get a ClientBin folder off the root that holds an xap file that builds from your Silverlight application. Consider this your DLL from Silverlight. Also, by default, you will get an aspx test page for your Silverlight application. This is really the starting point, you’re done with setup, now let’s begin.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;If you open the test page you will see a lot of scary Html/Javascript code. I have separated this out to make it easier to read. Start with the Javascript. I moved the reference to Silverlight.js out to my master page because my app uses Silverlight in several places.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;script&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;type&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"text/javascript"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;src&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Url.Content("~/Scripts/Silverlight.js") &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;script&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Notice the use of Url.Content to find the script instead of an absolute path. I do this so that the script can be found even if I am using a virtual directory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Next, take the onSilverlightError Javascript function and move it to another script file. I moved mine to my default Javascript file for my website.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;All you are left with is this nasty form and object tag that is incredibly complicated and something you could never recreate if you had to. We will deal with that later. By now you should be realizing that you really don’t want to be using an aspx page in your nice, new MVC project. That is just wrong. Ideally, I want to be dropping Silverlight in a partial view. Especially if it just a file upload control. So let’s do that.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;I want to just drop this Silverlight control on my index page of this new MVC application. So I create a partial view off of my Home controller and call it UploadAsset. In my index view I can call the partial view.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Html&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;RenderPartial&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;(&lt;/span&gt;&lt;span style="color: #c89191; font-family: Consolas; font-size: 10.0pt;"&gt;"UploadAsset"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;); &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;In the UploadAsset partial view all we really want is that scary form and object tag that was in the test page. Copy that and paste that into your partial view. Once that is done you should have a fully functional Silverlight application running in the context of MVC. I accepted this solution for a while. Then I realized it doesn’t feel like I’m writing MVC code. It doesn’t even feel like a good solution. I hate that object tag and I know I could never write that from scratch if I had to and if I had not created a test page I never would have even known how to create the tag.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;I want it to feel like Silverlight is made for MVC; I want to have a Silverlight reference in my model; I want to wire it up in the controller. And ideally I would want to use an Html helper class for Silverlight so that the framework could just &lt;i style="mso-bidi-font-style: normal;"&gt;know&lt;/i&gt; how to display it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Let’s start with the Model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;I created a model that holds the basic information about what a Silverlight reference is and defaulted the basics in the constructor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;SilverlightObject&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;string&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;XapName&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;Size&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Size&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;string&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;OnSilverlightError&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;Color&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;BackgroundColor&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;string&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;MinimumRuntimeVersion&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;bool&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;AutoUpgrade&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;SilverlightObject&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;OnSilverlightError&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;span style="color: #c89191; font-family: Consolas; font-size: 10.0pt;"&gt;"onSilverlightError"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;BackgroundColor&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;Color&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;White&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;MinimumRuntimeVersion&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;span style="color: #c89191; font-family: Consolas; font-size: 10.0pt;"&gt;"3.0.40624.0"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;AutoUpgrade&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;The non-defaulted properties are XapName and Size. The Xap name is the reference name you find under the ClientBin folder of you web project. The Size is just how big you want the Silverlight canvas to be. The rest of the properties are probably the same for every Silverlight application in your web project. If not, you can change the default.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now that I have a new &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt; type, I can use it in a view model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;IndexViewModel&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;SilverlightObject&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;UploadControl&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; { &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;get&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;set&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;In the controller we can now wire this up like we would any view model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;ActionResult&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Index&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;SilverlightObject&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;uploadControl&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;SilverlightObject&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;XapName&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;span style="color: #c89191; font-family: Consolas; font-size: 10.0pt;"&gt;"UploadDemo"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Size&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;System&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Drawing&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;Size&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;(&lt;/span&gt;&lt;span style="color: #8acccf; font-family: Consolas; font-size: 10.0pt;"&gt;400&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;, &lt;/span&gt;&lt;span style="color: #8acccf; font-family: Consolas; font-size: 10.0pt;"&gt;800&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;IndexViewModel&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;model&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt;"&gt;IndexViewModel&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;UploadControl&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; = &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;uploadControl&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 10.0pt;"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;View&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;model&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Then in the index view we can change where we call the partial because now our partial view can be strongly typed to a &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Html&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;RenderPartial&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;(&lt;/span&gt;&lt;span style="color: #c89191; font-family: Consolas; font-size: 10.0pt;"&gt;"UploadAsset"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;, &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Model&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;UploadControl&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;); &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now it feels more like MVC but it doesn’t work. It doesn’t use our settings we wired up for the UploadControl. Ideally we want our partial view to just contain…&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;Html&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 10.0pt;"&gt;DisplayForModel&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;() &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;We can do that by telling the framework what to use when it sees a type of &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt;. To do this, create a partial view under View\Home\DisplayTemplates called SilverlightObject and strongly type it to a &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt;. Go back to your UploadAsset partial and get that scary form and object tag and replace it with the DisplayForModel call. Drop that form and object tag into the SilverlightObject template and now you can start piecing it together with the &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt; model you have strongly typed to. In the end it can be as customizable as you want. Here is what I have.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;form&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;id&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"silverlightForm"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;runat&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"server"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;style&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;height&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;100%&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;div&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;id&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"silverlightControlHost"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;object&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;data&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"data:application/x-silverlight-2,"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;type&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"application/x-silverlight-2"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;width&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Html.Encode(Model.Size.Width) &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;height&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Html.Encode(Model.Size.Height) &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;param&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"source"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Url.Content("~/ClientBin/" + Html.Encode(Model.XapName) + ".xap") &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;param&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"onError"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Html.Encode(Model.OnSilverlightError) &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;param&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"background"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Html.Encode(Model.BackgroundColor.Name) &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;param&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"minRuntimeVersion"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Html.Encode(Model.MinimumRuntimeVersion) &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;param&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"autoUpgrade"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;lt; %&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;= Html.Encode(Model.AutoUpgrade) &lt;/span&gt;&lt;span style="background: #FFEE62; color: black; font-family: Consolas; font-size: 10.0pt;"&gt;% &amp;gt;&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;a&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;href&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40624.0"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;style&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;text-decoration&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;none&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;img&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;src&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"http://go.microsoft.com/fwlink/?LinkId=108181"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;alt&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"Get Microsoft Silverlight"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;style&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;border-style&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;none&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;a&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;object&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;iframe&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;id&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"_sl_historyFrame"&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt; &lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;style&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;visibility&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;hidden&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;height&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;0px&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;width&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;0px&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;;&lt;/span&gt;&lt;span style="color: #c3bf9f; font-family: Consolas; font-size: 10.0pt;"&gt;border&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;:&lt;/span&gt;&lt;span style="color: #dfdfbf; font-family: Consolas; font-size: 10.0pt;"&gt;0px&lt;/span&gt;&lt;span style="color: #cc9393; font-family: Consolas; font-size: 10.0pt;"&gt;"&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;iframe&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;div&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: #2E2E2E; margin-bottom: .0001pt; margin: 0in;"&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;/span&gt;&lt;span style="color: #e3ceab; font-family: Consolas; font-size: 10.0pt;"&gt;form&lt;/span&gt;&lt;span style="color: #efef8f; font-family: Consolas; font-size: 10.0pt;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 10.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;It’s confusing, but look at why it is confusing. Silverlight made it confusing, I only made it so that I never have to see how confusing it is.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;MVC will automatically pick up on this new template when you run it. When it parses the Html.DisplayForModel() it will see that your model has a &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt; and it will look for a view that knows how to handle that type. We created one for it and it will use that one. MVC will pass the view the data for the &lt;span style="color: #2b91af; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;SilverlightObject&lt;/span&gt; and our view will create that scary object tag.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_W3WFfs_0QgY/S8yDDBv3_1I/AAAAAAAAADY/XtYkbEa8xA8/s1600/SilverlightPartial.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S8yDDBv3_1I/AAAAAAAAADY/XtYkbEa8xA8/s400/SilverlightPartial.png" width="343" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align="center" class="MsoNormal" style="text-align: center;"&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;This extension is even reusable for any Silverlight references you might have in your MVC application. It will even &lt;i style="mso-bidi-font-style: normal;"&gt;feel&lt;/i&gt; like Silverlight belongs in MVC!&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-2575733276939068082?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/2575733276939068082/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/04/aspnet-mvc-2-and-silverlight-playing.html#comment-form" title="16 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2575733276939068082?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2575733276939068082?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/04/aspnet-mvc-2-and-silverlight-playing.html" title="ASP.NET MVC 2 and Silverlight Playing Nice" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_W3WFfs_0QgY/S8yDDBv3_1I/AAAAAAAAADY/XtYkbEa8xA8/s72-c/SilverlightPartial.png" height="72" width="72" /><thr:total>16</thr:total></entry><entry gd:etag="W/&quot;Ak4MR38zcSp7ImA9WxFTEUk.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-5337398351102031963</id><published>2010-04-01T15:09:00.000-04:00</published><updated>2010-04-01T15:09:46.189-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-01T15:09:46.189-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Encryption" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Salted Hash</title><content type="html">&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_W3WFfs_0QgY/S7TdILVdn8I/AAAAAAAAAC4/sVDW4TRXrdM/s1600/Hashbrown.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_W3WFfs_0QgY/S7TdILVdn8I/AAAAAAAAAC4/sVDW4TRXrdM/s320/Hashbrown.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Recently, I had a problem beyond the usual problems of having to go downstairs to get coffee and deciding what to eat for dinner.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;My problem was with encrypting passwords. I had never done that before. It just aways turned out that when that step came, someone on my team had always created some sort of architecture to support it. It was abstracted away so I never really knew about how it worked. This time I am a team of one and the problem needs to be addressed. Doing a quick &lt;a href="http://googleblog.blogspot.com/2010/04/different-kind-of-company-name.html"&gt;Topeka&lt;/a&gt; on the subject I found that there are a ton of ways to encrypt passwords in a SQL Server database. Using a combination of different strategies I was able to come up with my solution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The solution is pretty simple to understand (even for an encryption novice like myself).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;My database is just a simple column called "Password" with datatype "nvarchar(50)". For my solution, the encryption is going to happen on the application side.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;To start things off, i knew I eventually had to call some System.Security.Cryptography class. I chose MD5 just for the sake of choosing MD5. Once I have an instance, all I need to do is give the MD5 instance a byte array to hash.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; color: #500050; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;MD5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;md5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;MD5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Create&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;computedHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;md5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;ComputeHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Since I am storing the password as a string, the hash that I calculated needs to eventually be encoded to save in the database. Again, you can choose whatever encoder you want, but I chose to use a UTF8Encoding.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; color: #500050; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;UTF8Encoding&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;UTF8Encoding&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;GetBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;password&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;and eventually return the encoded string&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; color: #500050; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;GetString&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;computedHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;wbr&gt;&lt;/wbr&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Doing those few steps works for encoding passwords in a database. I wasn't really satisfied with this implementation though. The problem is that if I have two users that have the same password, they will have the same hash. If someone ever gets access to your Users database and can see your hash you could run the risk of unintentionally exposing user passwords.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I ultimately want a different hash result for each user. This is where a concept called &lt;a href="http://en.wikipedia.org/wiki/Salt_(cryptography)"&gt;salting&lt;/a&gt; comes in.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;If I can also encrypt a unique identifier with my password, the encrypted password will be different for every user in my database and will deter security attacks looking to decrypt my hash. For my Users table, my username is always unique so I will be adding the username bytes as my salt to my delicious hash.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; color: #500050; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #7a987a; font-family: Consolas; font-size: 12pt;"&gt;// Create a new salt&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;saltBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;GetBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Username&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;wbr&gt;&lt;/wbr&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;You can add as many additional salt bytes that you like, as long as you know how to get back from it. Once I have my salt bytes I can simply added the two byte arrays together and hash the combined byte array. Here is the full method.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; color: #500050; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;CreatePasswordHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;string&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;value&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #7a987a; font-family: Consolas; font-size: 12pt;"&gt;// Create Byte array of password string&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;UTF8Encoding&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;UTF8Encoding&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;GetBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;value&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #7a987a; font-family: Consolas; font-size: 12pt;"&gt;// Create a new salt&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;saltBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;GetBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Username&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;wbr&gt;&lt;/wbr&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #7a987a; font-family: Consolas; font-size: 12pt;"&gt;// append the two arrays&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;toHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Length&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;+&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;saltBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Length&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;];&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Array&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Copy&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #8acccf; font-family: Consolas; font-size: 12pt;"&gt;0&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;toHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #8acccf; font-family: Consolas; font-size: 12pt;"&gt;0&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Length&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Array&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Copy&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;saltBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #8acccf; font-family: Consolas; font-size: 12pt;"&gt;0&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;toHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;passwordBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Length&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;saltBytes&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Length&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;MD5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;md5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;MD5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;Create&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 12pt;"&gt;Byte&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;computedHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;md5&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;ComputeHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;toHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style="color: #aecee8; font-family: Consolas; font-size: 12pt;"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;encoder&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;.&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;GetString&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;(&lt;/span&gt;&lt;span style="color: #f8ffc6; font-family: Consolas; font-size: 12pt;"&gt;computedHash&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;wbr&gt;&lt;/wbr&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #2e2e2e; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #85ac8d; font-family: Consolas; font-size: 12pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Now that I have this super awesome encrypted string I thought the next step was to be able to decrypt this string into a readable password. &lt;b&gt;I was wrong.&lt;/b&gt; Think about it. When do you &lt;i&gt;ever&lt;/i&gt;&amp;nbsp;show an unencrypted password. You don't. You only ever validate if the password supplied is equal to the password in the database. This means you only ever have to encrypt a password and never decrypt it. This actually makes me feel good that I never even store how to get to a real password in my code. Here is how the validation might look like.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style="background: #2e2e2e; color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt; &lt;div style="margin: 0px;"&gt;&lt;span style="color: #aecee8; font-weight: bold;"&gt;if&lt;/span&gt; (&lt;span style="color: #f8ffc6;"&gt;user&lt;/span&gt;.&lt;span style="color: #f8ffc6;"&gt;Password&lt;/span&gt; == &lt;span style="color: #f8ffc6;"&gt;CreatePasswordHash&lt;/span&gt;(&lt;span class="Apple-style-span" style="color: #f8ffc6;"&gt;password&lt;/span&gt;))&lt;/div&gt;&lt;div style="margin: 0px;"&gt;{&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #7a987a;"&gt;// Do something for this user&lt;/span&gt;&lt;/div&gt;&lt;div style="margin: 0px;"&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-5337398351102031963?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/5337398351102031963/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/04/salted-hash.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5337398351102031963?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5337398351102031963?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/04/salted-hash.html" title="Salted Hash" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_W3WFfs_0QgY/S7TdILVdn8I/AAAAAAAAAC4/sVDW4TRXrdM/s72-c/Hashbrown.png" height="72" width="72" /><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CUMARH45eSp7ImA9WxBaEUU.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-8704968123172451446</id><published>2010-03-21T10:57:00.000-04:00</published><updated>2010-03-21T10:57:25.021-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-21T10:57:25.021-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Mercurial" /><title>Career Change</title><content type="html">After three years as a developer in the ticketing industry, I have moved on. I just needed a change. I have never been a person that can follow a routine for very long. Just picking up and leaving is a big deal though! The two jobs are just as far&amp;nbsp;apart&amp;nbsp;from each other as can be.&lt;br /&gt;
&lt;br /&gt;
The old job&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Point of sale and ticketing industry&lt;/li&gt;
&lt;li&gt;Near Philadelphia&lt;/li&gt;
&lt;li&gt;Writing in Delphi and a touch of C#&lt;/li&gt;
&lt;li&gt;Using Visual Source Safe&lt;/li&gt;
&lt;li&gt;Company of about 80 employees&lt;/li&gt;
&lt;li&gt;Development team of about 15&lt;/li&gt;
&lt;li&gt;Working in a cubicle&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The new job&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Sports instant replay industry&lt;/li&gt;
&lt;li&gt;Near Pittsburgh&lt;/li&gt;
&lt;li&gt;Writing ASP.NET MVC and Silverlight&lt;/li&gt;
&lt;li&gt;Using &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Company of about 25 employees&lt;/li&gt;
&lt;li&gt;Development team of 2&lt;/li&gt;
&lt;li&gt;Working in an office&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;It is certainly a change in direction for my career. A direction I have always wanted to go even with the old job.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I am into my first week with the new job and it was been wonderful so far. Of course first week reviews are always a bit skewed, but I did actually develop a lot this week. I think it helps when you can walk in and do File &amp;gt; New Project your first day.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;So it does not look like I would be qualified to do the new job. Thankfully, I have never stopped learning outside of work. I now know how important it is to do that, because I got the new job because I go home and write code for fun. I go home and write ASP.NET MVC 2.0 for fun and create some pretty awesome stuff too. In fact, &lt;a href="http://www.johncoder.com/"&gt;John Nelson&lt;/a&gt; and I are working on something we hope to be releasing to the public soon. I wish I could talk more about it but I will in time. I am also a huge advocate of &lt;a href="http://mercurial.selenic.com/"&gt;mercurial &lt;/a&gt;so that was and easy change.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;It has been so nice to be given every tool I have asked for to do my job right and continually be asked if I have everything I need. Valuing my opinion is high on my list of what it takes for me to be satisfied with my job.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I guess the one bad thing about the new job is that the team size is drastically decreased from the old job. I thrive on other employees challenging me. It makes me want to do more and learn more when another teammate talks about interesting that I know nothing about. I think that in time this will improve when the company gets more team members in development, and what better place to be, than the first one there.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-8704968123172451446?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/8704968123172451446/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/03/career-change.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/8704968123172451446?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/8704968123172451446?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/03/career-change.html" title="Career Change" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkYGRXk8eyp7ImA9WxBbEUU.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-1330129698411690971</id><published>2010-03-09T21:26:00.001-05:00</published><updated>2010-03-09T21:28:44.773-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-09T21:28:44.773-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Productivity" /><category scheme="http://www.blogger.com/atom/ns#" term="Motivation" /><title>Life According To Trine</title><content type="html">&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_W3WFfs_0QgY/S5cAyijr2kI/AAAAAAAAACc/viNyXsvNExI/s1600-h/Trine.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="225" src="http://3.bp.blogspot.com/_W3WFfs_0QgY/S5cAyijr2kI/AAAAAAAAACc/viNyXsvNExI/s400/Trine.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;/h2&gt;&lt;h2 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #0b5394;"&gt;What is Trine&lt;/span&gt;&lt;/strong&gt;&lt;/h2&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;a href="http://trine-thegame.com/site/" style="color: #4c6d7e; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" target="_blank"&gt;Trine&lt;/a&gt;&amp;nbsp;is a three player game available on PC and PS3 that requires all three characters to play a critical role to get the characters through a level full of puzzles and undead enemies.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;A few months ago, I took a day and played through Trine with &lt;a href="http://twitter.com/johncoder"&gt;John &lt;/a&gt;and &lt;a href="http://twitter.com/tbumbarger"&gt;Todd&lt;/a&gt;. Trine is a light purchase costing about $20.00 and giving hours of laughing, hating, and questioning friendships with the the other two players. Trine requires an extremely coordinated group using the talents of each character to achieve the ultimate goal.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h2 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #0b5394;"&gt;The Characters&lt;/span&gt;&lt;/h2&gt;&lt;h3 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The Knight&lt;/strong&gt;&lt;/h3&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Armed with a shield and a sword, the knight is your frontal defenses. He is your primary attacker that ultimately shields the other two from fire, arrows, traps, and pitfalls. The best of groups are led by the knight.&lt;/div&gt;&lt;h3 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The Thief&lt;/strong&gt;&lt;/h3&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;A master of the bow and swinging from platforms, the thief is used as a support attacker and allows the group to uncover treasures that cannot be reached by the other less mobile characters. Nine chances out of ten the thief will swing into some spikes within three seconds of starting the level, so they play a much less vital role in the game than the other two.&lt;/div&gt;&lt;h3 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The Wizard&lt;/strong&gt;&lt;/h3&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The character that gets you results, the wizard is the key to winning. Without a wizard you do not have a group. You might as well give up. The wizard uses magic to create a path for the group by creating boxes, planks, or levitating and moving objects. The draw back to the wizard is that he cannot attack. This creates problems when there are so many undead wanting to kill your wizard.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h2 style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #0b5394;"&gt;Applying the Concept&lt;/span&gt;&lt;/h2&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Now you should have a good understand of the game and who the players are. I want to explain the game from the perspective of software development. You can consider the enemies as anyone that wants to make life difficult for you. Whether it is giving you more work, changing your priorities, or someone wanting to tell you the latest bad news. If you have not already seen it, this game has some solid ties to the software industry. Let me lay out a scenario for you.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Knight&amp;nbsp;&lt;/strong&gt;= Project Manager&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Thief &amp;nbsp;&lt;/strong&gt;= Quality Assurance&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Wizard&amp;nbsp;&lt;/strong&gt;= Developer&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Undead&amp;nbsp;&lt;/strong&gt;= The Customer&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;This scenario is familiar to me and it works well. The wizard is in the back doing what wizards do. He progresses the three through the level. The Knight is out in front protecting the wizard from the undead enemies. The thief finds all those "treasures" that the wizard and knight could never find. The undead enemies are constantly approaching the knight and desperately want to get to the rest of the group to change, redirect, rewrite, and add functionality to whatever it is the wizard is doing.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;If the wizard were on the frontlines with the knight, the wizard would not last long. There needs to be a barrier between the undead and the wizard. That barrier must be the knight. All communication from the outside world goes through the Knight. If it does not, chaos ensues. If that line is breached once it will be breached again, which leads to problems.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;I think we can agree that the previous scenario is a common one and it probably works pretty well. Let's try another scenario.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Knight&amp;nbsp;&lt;/strong&gt;= Lead Employee&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Thief &amp;nbsp;&lt;/strong&gt;= The Process*&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Wizard&amp;nbsp;&lt;/strong&gt;= Employee&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Undead&amp;nbsp;&lt;/strong&gt;= Your Boss&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;* The Thief can help or hurt the group depending on how it is used.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;Is this scenario really so different from the first? Let me get less hypothetical and say that a great example of this scenario in action is when your boss has 37 tasks that your team needs to complete by the end of the week. If the boss came straight to the employee, chaos would ensue (once again). If the boss goes to the lead with 37 tasks the lead can take that information and give it to the wizard in a more positive manner by separating it into manageable chunks. Four or five tasks are a lot easier to handle than 37. The end result is a happy group.&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;The key to all the scenarios is to take care of your wizard. Without them, it is game over.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-1330129698411690971?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/1330129698411690971/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/03/what-is-trine-trine-three-player-game.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1330129698411690971?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1330129698411690971?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/03/what-is-trine-trine-three-player-game.html" title="Life According To Trine" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_W3WFfs_0QgY/S5cAyijr2kI/AAAAAAAAACc/viNyXsvNExI/s72-c/Trine.jpg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D08BRXY9eSp7ImA9WxBVE0o.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-5769541471695075951</id><published>2010-02-16T22:04:00.000-05:00</published><updated>2010-02-16T22:04:14.861-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-16T22:04:14.861-05:00</app:edited><title>Invoke a bug tracking application (part 2)</title><content type="html">Now that I have this &lt;a href="http://stevenhook.blogspot.com/2010/02/invoke-bug-tracking-application.html"&gt;great application&lt;/a&gt; that can open a bug report just by me sending the bug report number as a parameter, I can do some pretty powerful stuff. I can thank &lt;a href="http://www.johncoder.com/"&gt;John Nelson&lt;/a&gt; for coming up with this part of the solution.&lt;br /&gt;
&lt;br /&gt;
This is a solution to the problem of having an executable to do all this isn't that useful. I need a quick way to be able to invoke the executable's functionality. I can't just depend on people using &lt;a href="http://www.launchy.net/"&gt;Launchy&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The answer is a &lt;a href="http://en.wikipedia.org/wiki/URI_scheme"&gt;URI Protocol&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with them, think of a mailto link. Your OS just knows how to handle clicking on a mailto link because it knows what your configured default mail client is. Now I can tell the OS what my default bug tracking application is. You would think this requires some level of application level code or something like that but it's simpler than that. You just need to tell the OS that you want to register a protocol with it in the dreaded registry. You can do this with a straight .reg file or you can do it the way John and I did in the setup project for the application that invokes the bug tracking software.&lt;br /&gt;
&lt;br /&gt;
This setup project is no different than your average Add new project &amp;gt; Other Project Types &amp;gt; Setup Project. You can right click the project and view the registry keys associated with the installer and add your own. The real &lt;i&gt;key&lt;/i&gt;&amp;nbsp;is knowing where to put it.&lt;br /&gt;
&lt;br /&gt;
My work machine uses Win XP. I know, it's so retro! On XP the protocols are defined under the root of HKEY_CLASSES_ROOT. On my home machine running Windows 7 the protocols are under HKEY_CLASSES_ROOT\PROTOCOLS\Handler. If you are interested, you can see all the other protocols that are registered there too. Even the mailto protocol we all know about. From the rest of the protocols you can see that the colon in the protocol is implied. In my case I want to create a protocol named "issue" so that I can write out "issue:12345" and the OS will know I want to call my default bug tracking software by saying "issue:" and I want to open this bug report "12345".&amp;nbsp;To do this I create a folder in this location called "issue" as well as a few others.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3tUCFrwmPI/AAAAAAAAACU/6xS7tTuQI8I/s1600-h/URIProtocolRegistry.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3tUCFrwmPI/AAAAAAAAACU/6xS7tTuQI8I/s320/URIProtocolRegistry.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In the Command folder you will need to specify a default key with the data of:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background: #2e2e2e; color: #fedaa5; font-family: Consolas; font-size: 10pt;"&gt; &lt;div style="margin: 0px;"&gt;&lt;span style="color: #c89191;"&gt;"[TARGETDIR]\BugReportInvoker.exe"&lt;/span&gt; &lt;span style="color: #c89191;"&gt;"%1"&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The installer will fill in the [TARGETDIR] with the executable path.&amp;nbsp;So this is telling the OS that when you use "issue:" call this application and pass it the parameter of whatever is after "issue:". Pretty clever, I know!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;All of a sudden this simple, crappy little application that opens a bug report has more uses. I can go to start &amp;gt; run and type in "issue:12345" and bug report number 12345 opens right up. I can go into an email and create hyperlinks to bug reports by simply typing my new protocol and the bug report number. Now I feel like my application has full exposure. Wherever I want to invoke a bug report, I can do it!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Now all I have left with this project is making it easy to use. As if it were transparent to anyone want to use it or wanting to embed a link into some text. That's the challenging part, right? The user friendly aspect of it? My first hurdle is Office. That's where it's really useful, is embedding links into things like a development schedule. So I can see in a schedule that I will be working on a bug and I know the number, it's right there, so I want to click it to open it. Office gets upset and wants to warn about the potential risk of opening a link. Come on, I'm an adult. I don't get a warning every time I click a link in a web browser so why start now! My coworkers were annoyed by this message popping up and asked if I could do anything about it. I googled my way out of it and found these steps:&lt;/div&gt;&lt;blockquote&gt;1. Click Start, and then click Run.&lt;/blockquote&gt;&lt;blockquote&gt;2. In the Open dialog box, type regedit, and then click OK.&lt;/blockquote&gt;&lt;blockquote&gt;3. In Registry Editor, locate one of the following registry subkeys:&lt;/blockquote&gt;&lt;div&gt;&lt;blockquote&gt;HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common&lt;/blockquote&gt;&lt;blockquote&gt;HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\12.0\Common&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;Note You only have to modify one of these registry subkeys. You do not have to modify both of them.&lt;/blockquote&gt;&lt;blockquote&gt;4. Right click the registry subkey, point to New on the Edit menu, and then click Key.&lt;/blockquote&gt;&lt;blockquote&gt;5. Type Security, and then press ENTER to name the key.&lt;/blockquote&gt;&lt;blockquote&gt;6. On the Edit menu, point to New, and then click DWORD Value.&lt;/blockquote&gt;&lt;blockquote&gt;7. Type DisableHyperlinkWarning, and then press ENTER to name the entry.&lt;/blockquote&gt;&lt;blockquote&gt;8. In the right pane, right-click DisableHyperlinkWarning, and then click Modify.&lt;/blockquote&gt;&lt;blockquote&gt;9. In the Edit DWORD Value dialog box, click Decimal, and then type 1 under Value data.&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Some people are weirded out by taking warnings like that out so I did not include it in the installer and I didn't add an option in the installer because I am lazy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Removing the warning has made several people happy and certainly not a complaint I thought I would hear. Like I said, the user friendly part of it is the hardest part. Who would have thought I would be having user friendly issues in a non GUI application where the user has literally no interaction with the application.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Recently I have had another complaint. The complaint is that when writing a document in Microsoft Word it is too much work to create hyperlinks&amp;nbsp;every time&amp;nbsp;I want to have a bug report link. You might be thinking, "really? Too much work?" but, yes. I totally agree. a productivity tool should be oozing with productivity! If it is not, then what good is it?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Part three will talk about how I addressed it and it might just be my favorite step yet (I get to write code).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-5769541471695075951?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/5769541471695075951/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/02/invoke-bug-tracking-application-part-2.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5769541471695075951?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5769541471695075951?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/02/invoke-bug-tracking-application-part-2.html" title="Invoke a bug tracking application (part 2)" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3tUCFrwmPI/AAAAAAAAACU/6xS7tTuQI8I/s72-c/URIProtocolRegistry.png" height="72" width="72" /><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DkUESH4-eCp7ImA9WxBWGEw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-1933896154509312236</id><published>2010-02-09T18:41:00.001-05:00</published><updated>2010-02-10T10:03:29.050-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-10T10:03:29.050-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Productivity" /><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="WindowsAPI" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Invoke a bug tracking application</title><content type="html">My employer uses a home grown application for bug tracking that is written in Delphi. It works pretty well for their needs but it can be annoying at times when I know what bug report number I want to get to but I need to open the winforms application and search for that number.&lt;br /&gt;
&lt;br /&gt;
I'm a huge fan of productivity tools so I wanted to make some tools that might help people with this annoyance.&lt;br /&gt;
&lt;br /&gt;
I wanted to create a very basic application that I could build tools off of the basic concept. I created a C# application that does some pretty scary stuff to get to the bug tracking software. The bug tracking software only supports windows messaging of passing in a bug report number. This meant I had to know what process to send the message to, but once I know what process, it's easy to write some crap code to send the message and have that bug report open.&lt;br /&gt;
&lt;br /&gt;
I am not an expert on windows messaging, in fact I am not even a fan. I had to use some DLLImports to be able to send the message&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background: #2e2e2e; color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;div style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;DllImport&lt;/span&gt;(&lt;span style="color: #c89191;"&gt;"user32.dll"&lt;/span&gt;, &lt;span style="color: #f8ffc6;"&gt;CharSet&lt;/span&gt; = &lt;span style="color: #2b91af;"&gt;CharSet&lt;/span&gt;.&lt;span style="color: #f8ffc6;"&gt;Auto&lt;/span&gt;)]&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&lt;span style="color: #aecee8; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #aecee8; font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: #aecee8; font-weight: bold;"&gt;extern&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;SendMessage&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;hWnd&lt;/span&gt;, &lt;span style="color: #2b91af;"&gt;UInt32&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;Msg&lt;/span&gt;, &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;wParam&lt;/span&gt;, &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;lParam&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
I also used a FindWindow method to find the bug tracking application. I require my users to already have the bug tracking application open and that is a fair requirement at my employer because we live by it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background: #2e2e2e; color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;div style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;DllImport&lt;/span&gt;(&lt;span style="color: #c89191;"&gt;"user32.dll"&lt;/span&gt;)]&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&lt;span style="color: #aecee8; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #aecee8; font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: #aecee8; font-weight: bold;"&gt;extern&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;FindWindow&lt;/span&gt;(&lt;span style="color: #aecee8; font-weight: bold;"&gt;string&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;lpClassName&lt;/span&gt;, &lt;span style="color: #aecee8; font-weight: bold;"&gt;string&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;lpWindowName&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: auto;"&gt;&lt;br /&gt;
&lt;/div&gt;In my Main method I get the bug report number from the string arguments, find the window, and send the bug report number message to the window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background: #2e2e2e; color: #fedaa5; font-family: Consolas; font-size: 12pt;"&gt;&lt;div style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; &lt;span style="color: #f8ffc6;"&gt;MainWindow&lt;/span&gt; = &lt;span style="color: #f8ffc6;"&gt;FindWindow&lt;/span&gt;(&lt;span style="color: #aecee8; font-weight: bold;"&gt;null&lt;/span&gt;, &lt;span style="color: #f8ffc6;"&gt;settings&lt;/span&gt;.&lt;span style="color: #f8ffc6;"&gt;BugTrackingFormCaption&lt;/span&gt;);&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&lt;span style="color: #aecee8; font-weight: bold;"&gt;if&lt;/span&gt; (&lt;span style="color: #f8ffc6;"&gt;bugReportNumber&lt;/span&gt; &amp;gt; &lt;span style="color: #8acccf;"&gt;0&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style="color: #f8ffc6;"&gt;MainWindow&lt;/span&gt;.&lt;span style="color: #f8ffc6;"&gt;ToInt32&lt;/span&gt;() &amp;gt; &lt;span style="color: #8acccf;"&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: #f8ffc6;"&gt;SendMessage&lt;/span&gt;(&lt;span style="color: #f8ffc6;"&gt;MainWindow&lt;/span&gt;, &lt;span style="color: #f8ffc6;"&gt;WM_USER&lt;/span&gt; + &lt;span style="color: #8acccf;"&gt;1&lt;/span&gt;, (&lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt;)&lt;span style="color: #f8ffc6;"&gt;bugReportNumber&lt;/span&gt;, &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt;.&lt;span style="color: #f8ffc6;"&gt;Zero&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Like I said, I am no expert on windows messaging. I had to google a bit to get the SendMessage syntax. I just know I want to send bugReportNumber that I got from the command line arguments and send it to the window I got from MainWindow. You can see that I also created a settings file in case the form caption changes.&lt;br /&gt;
&lt;br /&gt;
To avoid a flicker of a console window when the executable is invoked, I used a windows application output type but I never create a form or show it so I never see anything pop up other than the bug report.&lt;br /&gt;
&lt;br /&gt;
So now if I run the application at the command line at pass in a bug report number it opens up a new window for the bug report I typed it. That's perfect! But not that useful... however, it is something I can really build on.&lt;br /&gt;
&lt;br /&gt;
Even this executable alone, I can do some pretty cool things with it. I'm a huge &lt;a href="http://launchy.net/"&gt;Launchy&lt;/a&gt;&amp;nbsp;fan. I can train &lt;a href="http://launchy.net/"&gt;Launchy&lt;/a&gt; to find the executable and press tab to pass in a bug report number!&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hw0bu9TpI/AAAAAAAAABo/rMkO_bPEXuI/s1600-h/Launchy.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hw0bu9TpI/AAAAAAAAABo/rMkO_bPEXuI/s320/Launchy.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I have more plans for using this executable in other tools so stay tuned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-1933896154509312236?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/1933896154509312236/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/02/invoke-bug-tracking-application.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1933896154509312236?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/1933896154509312236?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/02/invoke-bug-tracking-application.html" title="Invoke a bug tracking application" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hw0bu9TpI/AAAAAAAAABo/rMkO_bPEXuI/s72-c/Launchy.JPG" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C08DQXszfyp7ImA9WxBQFUo.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-5525363946053270998</id><published>2010-01-15T11:04:00.000-05:00</published><updated>2010-01-15T11:11:10.587-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-15T11:11:10.587-05:00</app:edited><title>Conversion to Blogspot</title><content type="html">I am mostly finished converting my previously internal community server blog over to a public blog on blogger.com. Unfortunately I had to take out most of my posts over the past year because they have been so specific to my employer. I was not getting the response I was expecting from the internal blog so I decided to open it up to the rest of the world.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'm still working on finding a good template that works well with code and images. I also need to find out how I can show code blocks in blogger.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I will eventually move (yet again) to my own domain but until then I need a place to store my thoughts!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-5525363946053270998?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/5525363946053270998/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/01/conversion-to-bloggercom.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5525363946053270998?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/5525363946053270998?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/01/conversion-to-bloggercom.html" title="Conversion to Blogspot" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkUESX45fSp7ImA9WxBQEU4.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-2939032778652265178</id><published>2010-01-10T10:43:00.001-05:00</published><updated>2010-01-10T10:43:28.025-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-10T10:43:28.025-05:00</app:edited><title>£5,000 Cookies</title><content type="html">&lt;p&gt;If you develop web applications you must read &lt;a target="_blank" href="http://out-law.com/page-10510"&gt;this new law&lt;/a&gt;. Europe will require web user consent before allowing cookies in a web page. There are a few exceptions, but for the most part, this changes the way we develop web applications.&lt;/p&gt;&lt;p&gt;Web users that prompt for cookies (like me) should be happy to hear this news that websites should now be asking you to write files to your machine.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-2939032778652265178?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/2939032778652265178/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/01/5000-cookies.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2939032778652265178?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/2939032778652265178?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/01/5000-cookies.html" title="£5,000 Cookies" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkYNRX0_eip7ImA9WxBWGEw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-6968106606563396709</id><published>2010-01-10T10:27:00.001-05:00</published><updated>2010-02-10T10:03:14.342-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-10T10:03:14.342-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Delphi" /><category scheme="http://www.blogger.com/atom/ns#" term="Productivity" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Fresh Eyes</title><content type="html">&lt;div style="text-align: left;"&gt;I am still on the plane. With all the frustrating moments I have had on this flight I think it is time for me to just relax and do some stuff that I would probably get yelled at for doing at work.&lt;/div&gt;&lt;br /&gt;
&lt;i&gt;No, not that.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Stay focused. I'm talking about revitalizing my work environment by designing a new Delphi IDE color scheme. Color schemes bring new life into an otherwise visually dull programming experience. For two years and nine months I have been using the default color scheme for my Delphi IDE. I am bored with it. I need something fresh. I need something that gives me a feeling&lt;br /&gt;
of creativity. I look at my IDE more than I look at myself. Sometimes more than I look at my wife. It's time for a change.&lt;br /&gt;
&lt;br /&gt;
I have never been a fan of white backgrounds. It hurts my eyes to look at it for an extended period of time. I have my brightness on my monitor down to about ten percent but I still squint at the brightness sometimes. I know that I need something dark but not the easy fall back to black background and lime green foreground to let everyone know that I used to write code in &lt;a href="http://en.wikipedia.org/wiki/BASIC" target="_blank"&gt;BASIC&lt;/a&gt;. I need something modern and inspiring.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.johncoder.com/"&gt;John Nelson&lt;/a&gt; has been working with a nice style for Visual Studio that he found from someone else on the web. John and I have been working together on a project in Visual Studio outside of the office so I have had quite a bit of exposure to his IDE style. Before I left for the trip I asked&lt;br /&gt;
John to send me a screenshot of a good sampling of his IDE styling. On the plane, I have been using the Delphi highlighting options to make it look similar to John's but still have a few original colors to set it apart as being my own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to change your color options you do not have too many ways of doing it. Delphi does not have a fancy style importer/exporter that you can pass around styles with. You have the configuration in Tools &amp;gt; Options &amp;gt; Editor Options &amp;gt; Colors. From there you can define an impressive amount of symbol highlighting. The configuration, however, is lacking in its&lt;br /&gt;
ability to be a user friendly experience. I am using custom colors for nearly all of my highlighting. This requires me to go into the custom color dialog and type in the RGB values (I also found a RAD Studio bug on this form). I have chosen all of my background colors to be the same shade of gray/black. That's great, but I'm still going to need to enter in those RGB values every single time because the IDE does not keep my custom colors even when I tell it to save the color. RAD Studio has no consideration for my time. Lucky for RAD Studio, I still have three hours on my flight.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; color: #0000ee;"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5425135358238294306" src="http://1.bp.blogspot.com/_W3WFfs_0QgY/S0nz3V40gSI/AAAAAAAAAAc/Ln8SPn-64Pc/s400/3124.HighlightingSample.JPG" style="cursor: pointer; display: block; height: 279px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: center; width: 400px;" /&gt;&lt;/span&gt;&lt;br /&gt;
Once I was happy with my color scheme and it makes me want to write code I saved the changes and starting playing around with it. I really like it! Usually I do not like anything other than the default color scheme because I feel like I cannot even read the words on the page but I have chosen colors that are very dull, but yet they stand out from each other.&lt;br /&gt;
&lt;br /&gt;
The next step is to figure out where this information is stored for RAD Studio so that I can export it from my laptop and magically import it on my desktop. I look in the obvious places like Program Files, My Documents, and Application Data. Nothing; why are they making this so hard? After digging for quite some time I thought, no, they wouldn't put it in the registry would&lt;br /&gt;
they? That would make me sad. A few moments later I found this path:&lt;br /&gt;
HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Editor\Highlighting&lt;br /&gt;
I'm sad. This plane flight has nothing but &lt;a href="http://stevenhook.blogspot.com/2010/01/11e.html"&gt;bad news&lt;/a&gt;. Anyway, I found the location of the code styling. Now I can test this:&lt;br /&gt;
1. Open "regedit" using the run dialog.&lt;br /&gt;
2. Navigate to &lt;i&gt;HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Editor\Highlighting&lt;/i&gt;&lt;br /&gt;
3. Backup the Highlight entry by right clicking the highlight folder and clicking Export.&lt;br /&gt;
4. Delete the Highlight entry in the registry.&lt;br /&gt;
5. Run the .reg registry entry that has your new color scheme.&lt;br /&gt;
&lt;br /&gt;
This is just a simple way to see that the registry created the tree properly. Now I can go into Delphi and see that it still looks great. I now have a poor man's import/export for my new, fancy IDE styling. &lt;br /&gt;
I recommend changing your style every once in a while. The more I think about how I was afraid to create this style on work time the more I think of how silly I was for being afraid of doing it. It comes down to doing my job better. A better work environment will help me be productive. It is&lt;br /&gt;
really no different than cleaning off my desk at the end of the day so that I am productive the next day. Changing my color scheme is much like one of my steps from the &lt;a href="http://stevenhook.blogspot.com/2010/01/step-it-up.html"&gt;Step It Up&lt;/a&gt; post that talks about improving productivity.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;"&lt;/i&gt;&lt;i&gt;Looking at the problem with fresh eyes can clear up that issue&lt;br /&gt;
that's been bugging you all day."&lt;/i&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
A new color scheme gives you your fresh eyes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-6968106606563396709?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/6968106606563396709/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/01/fresh-eyes.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/6968106606563396709?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/6968106606563396709?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/01/fresh-eyes.html" title="Fresh Eyes" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_W3WFfs_0QgY/S0nz3V40gSI/AAAAAAAAAAc/Ln8SPn-64Pc/s72-c/3124.HighlightingSample.JPG" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUYCSXo8eCp7ImA9WxBQEU4.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-3308226246757680161</id><published>2010-01-10T10:22:00.000-05:00</published><updated>2010-01-10T10:26:08.470-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-10T10:26:08.470-05:00</app:edited><title>11E</title><content type="html">&lt;p&gt;I am sitting on my flight to Anaheim, CA for a two week support trip. I have the exit row all&lt;br /&gt;to myself. My travel buddy did not blink an eye when shouting, "I'll take it" to the only available seat upgrade to first class and leave me deserted with the heathens that live in economy. As I looked at him in disbelief, he could not help but laugh and say, "I'm sorry, I feel bad about&lt;br /&gt;it". I don't think those two things go together. I'll get you back... somehow. After the seat drama, I got settled in and the flight attendant kindly started her routine asking me if I am willing and able to assist a passen... and she stopped. She seemed bothered and asked me, "Are you over the age of fifteen?" She then giggles and says, "You look so young" loud enough that the rows surrounding me are now interested enough to turn around to get a glimpse of the&lt;br /&gt;little youngster without adult supervision.&lt;/p&gt;&lt;p&gt;Most of you know me. You know that I am extremely easy going, and can find a positive aspect to any encounter. There are few things in this world that make me want to physically harm another person. The prioritized list goes:&lt;/p&gt;&lt;p&gt;1.     Talk about how young I look.&lt;/p&gt;&lt;p&gt;2.     Apologize for offending me about my age by saying, "You'll appreciate it when you're older."&lt;/p&gt;&lt;p&gt;3.     American Idol&lt;/p&gt;&lt;p&gt;4.     The phrase, "We need the rain".&lt;/p&gt;&lt;p&gt;...&lt;/p&gt;&lt;p&gt;With a twitching eye, I look down at my wedding ring as I twirl it between my thumb and pinkie as if to gain control of my emotions. I kindly, and with the most respect I could muster, told the flight attendant that I am of age to sit in the exit row.  All the while I am having Scrubs like daydreams of wishing harm upon her. She is now the enemy for the rest of the trip. She will be shunned at every possible moment.&lt;/p&gt;&lt;p&gt;This was a very mild case of someone offending me, but when I talk about other incidents, it is really a form of discrimination that is often overlooked and shrugged off as being a comical discussion about different generations of people. Many times in my life I have thought of creating a website designed to hold the amazing stories I have about people offending me. These stories that I have unwillingly acquired over the years would make you realize why it is my number one social quam. I have dozens of stories that would make you reassess yourself in these seemingly&lt;br /&gt;harmless social situations. Ask me.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-3308226246757680161?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/3308226246757680161/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/01/11e.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3308226246757680161?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/3308226246757680161?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/01/11e.html" title="11E" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkcDQHs7fyp7ImA9WxBWGEw.&quot;"><id>tag:blogger.com,1999:blog-2126038431077583228.post-6077031789200943605</id><published>2010-01-10T10:17:00.001-05:00</published><updated>2010-02-10T10:01:11.507-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-10T10:01:11.507-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Google Voice" /><title>On-Call</title><content type="html">Along the lines of rethinking our current practices I would like to share an idea for convenience, efficiency, and cost cutting.&lt;br /&gt;
&lt;h3&gt;&lt;strong&gt;Back Story:&lt;/strong&gt;&lt;/h3&gt;I recently accepted an invitation to use &lt;a href="https://www.google.com/voice" target="_blank"&gt;Google Voice&lt;/a&gt;. I was excited because it was going to be a way that I could reliably call into meetings for work. I was wrong about what Google Voice was all about. I thought it was going to be a VOIP system that would allow me to make calls from my computer so that I don't need to be hanging on the phone so much when in a meeting at home.&lt;br /&gt;
I continued to play around with Google Voice. I made myself a phone number and added my cell phone number under that Google phone number (still not knowing what Google Voice was for). I click the call button to call my wife. Google calls my phone, I pick up, it then rings my wife's phone and I can talk to her on my phone. At this point I am thinking, "Well, this is stupid!" I have now created a middleman for my phone that still requires me to be &lt;i&gt;at &lt;/i&gt;my phone. How silly.&lt;br /&gt;
I also found that since Google has given me real phone number, I can call that number. What does it do? It forwards the call to all of my phones I have configured. Whoa, that's cool, but I already have that through Vonage. Someone calls my home phone and it gets forwarded to my cell phone after a few rings. This Google Voice is just not working for me. I'm not a fan.&lt;br /&gt;
This week I have the programmer on-call phone. I hate that thing. While I was holding the on-call phone I was talking to a co-worker about Google Voice...&lt;br /&gt;
&lt;h3&gt;My Idea:&lt;/h3&gt;Then, boom, It hit me! &lt;strong&gt;Google Voice eliminates the need for a programmer on-call phone rotation! &lt;/strong&gt;Why stop there, Google Voice eliminates the programmer on-call phone completely. Create a Google phone number and give that phone number to Customer Support. Now from your Google Voice account you can add phone numbers that you would like to forward the phone call to. Here is where an engineer can specifiy the number they would like to be reached at for the on call phone. For me, I would use my mobile number most of the time. If I have the on-call phone over a holiday, I do not get service on my mobile number or the on-call phone when visiting family in western PA. Instead of just chancing it, I could supply a number that I &lt;i&gt;can&lt;/i&gt; be reached at, like my parent's phone number, or an alternate cell number, or even another Google Voice number that rings all my numbers!&lt;br /&gt;
When the on-call rotation changes, we just change the number that the Google Voice number forwards to and we are done. Personally, I hate having to carry around the phone and making sure it is charged when I already do that with my personal cell phone. Plus, we get the added bonus that the company has absolutely no reason to keep the on-call phone or the phone plan which cuts costs. It cuts costs because Google Voice is free to the US and Canada.&lt;br /&gt;
Google Voice can also manage your voicemails if you want it to; it can get transcripts of the call; do conference calls; there is just &lt;a href="http://www.google.com/googlevoice/about.html" target="_blank"&gt;so much&lt;/a&gt; you can do! I think this is a great opportunity for the company and I wanted to share it with everyone, so let me know what you think.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2126038431077583228-6077031789200943605?l=stevenhook.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://stevenhook.blogspot.com/feeds/6077031789200943605/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://stevenhook.blogspot.com/2010/01/on-call.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/6077031789200943605?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2126038431077583228/posts/default/6077031789200943605?v=2" /><link rel="alternate" type="text/html" href="http://stevenhook.blogspot.com/2010/01/on-call.html" title="On-Call" /><author><name>Steven Hook</name><uri>http://www.blogger.com/profile/05155228333252618501</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_W3WFfs_0QgY/S3Hjg0aXf_I/AAAAAAAAABI/2e0IVtSdOdw/S220/Avatar.png" /></author><thr:total>0</thr:total></entry></feed>

