<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Program With .NET</title>
    <link>http://programwith.net/</link>
    <description>Matt Casto's .NET Journal</description>
    <language>en-us</language>
    <copyright>Matt Casto</copyright>
    <lastBuildDate>Sun, 19 Apr 2009 21:05:41 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>mattcasto@gmail.com</managingEditor>
    <webMaster>mattcasto@gmail.com</webMaster>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ProgramWithDotNet" type="application/rss+xml" /><item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.cinnug.org/cododn">
            <img style="border-bottom-style: none; border-right-style: none; display: inline; border-top-style: none; margin-left: 0px; border-left-style: none; margin-right: 0px" border="0" align="right" src="http://www.cinnug.org/images/cododn2009Badge.gif" />
          </a>
        </p>
        <p>
The demo projects and slides from my presentation at the <a href="http://cinnug.org/cododn/" target="_blank">Central
Ohio Day of .NET</a> are now posted to my <a href="http://cid-63a50a5c41970075.skydrive.live.com/home.aspx" target="_blank">Sky
Drive</a>.
</p>
        <p>
          <a href="https://cid-63a50a5c41970075.skydrive.live.com/browse.aspx/CODODN%202009" target="_blank">Creating
Applications using the Model-View-ViewModel Pattern</a>
        </p>
        <p>
 
</p>
        <p>
The demonstration projects are organized into four folders – one for each step of
the demonstration. If you came to my talk and just want to see the finished project,
you should go straight to the fourth step.
</p>
        <p>
Each step folder has the WPF and Silverlight versions in their own folders as well.
</p>
        <p>
I hope everyone enjoyed the talk. If you have any feedback to give, please feel free
to do so at <a href="http://speakerrate.com/talks/644-creating-appliicatons-using-the-model-view-viewmodel-pattern" target="_blank">Speaker
Rate</a>.
</p>
        <p>
Thanks to everyone who organized and volunteered for this great community driven event.
It was a blast again this year!
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0" />
      </body>
      <title>Central Ohio Day of .NET Slides</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0.aspx</guid>
      <link>http://programwith.net/2009/04/19/CentralOhioDayOfNETSlides.aspx</link>
      <pubDate>Sun, 19 Apr 2009 21:05:41 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.cinnug.org/cododn"&gt;&lt;img style="border-bottom-style: none; border-right-style: none; display: inline; border-top-style: none; margin-left: 0px; border-left-style: none; margin-right: 0px" border="0" align="right" src="http://www.cinnug.org/images/cododn2009Badge.gif"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The demo projects and slides from my presentation at the &lt;a href="http://cinnug.org/cododn/" target="_blank"&gt;Central
Ohio Day of .NET&lt;/a&gt; are now posted to my &lt;a href="http://cid-63a50a5c41970075.skydrive.live.com/home.aspx" target="_blank"&gt;Sky
Drive&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="https://cid-63a50a5c41970075.skydrive.live.com/browse.aspx/CODODN%202009" target="_blank"&gt;Creating
Applications using the Model-View-ViewModel Pattern&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The demonstration projects are organized into four folders – one for each step of
the demonstration. If you came to my talk and just want to see the finished project,
you should go straight to the fourth step.
&lt;/p&gt;
&lt;p&gt;
Each step folder has the WPF and Silverlight versions in their own folders as well.
&lt;/p&gt;
&lt;p&gt;
I hope everyone enjoyed the talk. If you have any feedback to give, please feel free
to do so at &lt;a href="http://speakerrate.com/talks/644-creating-appliicatons-using-the-model-view-viewmodel-pattern" target="_blank"&gt;Speaker
Rate&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Thanks to everyone who organized and volunteered for this great community driven event.
It was a blast again this year!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,f5c5ea29-9189-4575-b8f5-ab1c0ad62cd0.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=31941008-466d-4308-a7e8-25d246dcf961</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,31941008-466d-4308-a7e8-25d246dcf961.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,31941008-466d-4308-a7e8-25d246dcf961.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=31941008-466d-4308-a7e8-25d246dcf961</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is part 1 of my <a href="http://programwith.net/2009/03/23/Silverlight3FeatureByFeature.aspx" target="_blank">Silverlight
3 Feature By Feature</a> series of blog posts.
</p>
        <h4>No More Blank Slate
</h4>
        <p align="left">
The first thing you may try after installing the <a href="http://silverlight.net/getstarted/silverlight3/default.aspx" target="_blank">Silverlight
3 Beta 1 Tools</a> is creating a new Silverlight application. There is a new project
template available called <strong>Silverlight Navigation Application</strong>. Using
this project template creates a Silverlight project with a few things already set
up for you. This is a departure from what we've had so far - a blank slate that is
intimidating and doesn't really help new developers.
</p>
        <p align="left">
The new project contains the typical App.xaml but now with a bunch styles used in
the main page. The MainPage.xaml is a generic, but nice looking, layout for an example
Silverlight application. There are links to the Home and About views, which are both
located in the Views folder of the project along with a view reserved for errors.
</p>
        <p>
          <img style="border-width: 0px; margin: 0px; display: inline;" title="SilverlightNavApp_SlnExpl" alt="SilverlightNavApp_SlnExpl" src="http://programwith.net/images/SilverlightNavApp_SlnExpl.jpg" border="0" />
        </p>
        <p>
Running the application without any changes shows the full page Silverlight application.
Click on the links will change the URL in your browser and update the browsing history.
You can use these URLs to go to a specific view. For example, from the About view
copy the URL, then open an alternative browser and paste in the URL. Viola! Deep linking!
</p>
        <p>
          <img style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="SilverlightNavApp_FirstRun" alt="SilverlightNavApp_FirstRun" src="http://programwith.net/images/SilverlightNavApp_FirstRun.jpg" border="0" />
        </p>
        <h4>How It Works
</h4>
        <p>
The trick to the navigation, as implemented in the project template, is the <strong>Frame</strong> control
in MainPage.xaml.
</p>
        <div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
          <div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 1:</span>
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">UserControl</span>
              <span style="color: rgb(255, 0, 0);">x:Class</span>
              <span style="color: rgb(0, 0, 255);">="SilverlightNavigation.MainPage"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 2:</span>
              <span style="color: rgb(255, 0, 0);">xmlns</span>
              <span style="color: rgb(0, 0, 255);">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 3:</span>
              <span style="color: rgb(255, 0, 0);">xmlns:x</span>
              <span style="color: rgb(0, 0, 255);">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 4:</span>
              <span style="color: rgb(255, 0, 0);">xmlns:navigation</span>
              <span style="color: rgb(0, 0, 255);">="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 5:</span> ...</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 6:</span>
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">navigation:Frame</span>
              <span style="color: rgb(255, 0, 0);">x:Name</span>
              <span style="color: rgb(0, 0, 255);">="Frame"</span>
              <span style="color: rgb(255, 0, 0);">Source</span>
              <span style="color: rgb(0, 0, 255);">="/Views/HomePage.xaml"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 7:</span>
              <span style="color: rgb(255, 0, 0);">HorizontalContentAlignment</span>
              <span style="color: rgb(0, 0, 255);">="Stretch"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 8:</span>
              <span style="color: rgb(255, 0, 0);">VerticalContentAlignment</span>
              <span style="color: rgb(0, 0, 255);">="Stretch"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 9:</span>
              <span style="color: rgb(255, 0, 0);">Padding</span>
              <span style="color: rgb(0, 0, 255);">="15,10,15,10"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 10:</span>
              <span style="color: rgb(255, 0, 0);">Background</span>
              <span style="color: rgb(0, 0, 255);">="White"</span>
              <span style="color: rgb(0, 0, 255);">/&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 11:</span> ...</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 12:</span>
              <span style="color: rgb(0, 0, 255);">&lt;/</span>
              <span style="color: rgb(128, 0, 0);">UserControl</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
          </div>
        </div>
        <p>
In particular, notice the navigation namespace. The project has a reference to the <strong>System.Windows.Controls.Navigation</strong> assembly
which contains new controls and other things used for navigation.
</p>
        <p>
The Frame is instructed to navigate in the Click event handler of the buttons.
</p>
        <div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
          <div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 1:</span>
              <span style="color: rgb(0, 0, 255);">private</span>
              <span style="color: rgb(0, 0, 255);">void</span> NavButton_Click(<span style="color: rgb(0, 0, 255);">object</span> sender,
RoutedEventArgs e)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 2:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 3:</span> Button
navigationButton = sender <span style="color: rgb(0, 0, 255);">as</span> Button;</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 4:</span> String
goToPage = navigationButton.Tag.ToString();</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 5:</span>
              <span style="color: rgb(0, 0, 255);">this</span>.Frame.Navigate(<span style="color: rgb(0, 0, 255);">new</span> Uri(goToPage,
UriKind.Relative));</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 6:</span> }</pre>
          </div>
        </div>
        <p>
I don’t exactly like the method of storing the destination page in the buttons’ Tag
property, but that could easily be encapsulated by a custom NavigationButton control.
Perhaps we’ll get one before RTW? I’ll definitely have to expand on this in a separate
blog post.
</p>
        <p>
HomePage.xaml and AboutPage.xaml are both <strong>Page</strong> objects instead of
UserControl, which is typically the base control of new XAML files in a Silverlight
2 project. Its easy enough to add new navigable content to your application. Just
add a new item to your project, and choose the <strong>Silverlight Page</strong> template
in the <strong>Add New Item</strong> dialog.
</p>
        <h4>Custom Navigation
</h4>
        <p>
What I wanted to do with my <a href="http://silverlightoverview.codeplex.com/" target="_blank">Silverlight
Overview</a> application was have a tree view control listing all of the examples,
and each of these example pages showing up as a unique URL so I could link to a specific
example. My original Silverlight Demo application had examples split into tab controls.
Each tab was a separate XAML file. I could have modified these to be a Page instead
of UserControl, but I wanted to break them down further and didn’t relish the thought
of having 30+ Page files.
</p>
        <p>
Using <a href="http://www.red-gate.com/products/reflector/" target="_blank">Reflector</a>,
I found that the Frame control’s Navigate method is using the NavigationService. Looking
into this code wasn’t leading me anywhere so I decided to look at the <a href="http://msdn.microsoft.com/en-us/library/cc838158%28VS.96%29.aspx" target="_blank">Silverlight
3</a> documentation on MSDN. Interestingly, the only page that I found related to
navigation, <a href="http://msdn.microsoft.com/en-us/library/cc838245%28VS.96%29.aspx" target="_blank">Navigation
Overview</a>, hasn’t been updated for Silverlight 3 and contains incorrect information.
Finally I found Tim Heuer’s <a href="http://silverlight.net/learn/learnvideo.aspx?video=187319" target="_blank">Navigation
Framework screencast</a> and <a href="http://timheuer.com/blog/archive/2009/03/22/silverlight-navigation-framework-and-uri-routing.aspx" target="_blank">blog
post</a> which shows how to use the <strong>UriMapper </strong>to accomplish what
I’m looking for.
</p>
        <div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
          <div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">nav:UriMapper</span>
              <span style="color: rgb(255, 0, 0);">x:Key</span>
              <span style="color: rgb(0, 0, 255);">="uriMapper"</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">nav:UriMapping</span>
              <span style="color: rgb(255, 0, 0);">Uri</span>
              <span style="color: rgb(0, 0, 255);">="Examples/{example}"</span>
              <span style="color: rgb(255, 0, 0);">MappedUri</span>
              <span style="color: rgb(0, 0, 255);">="/ExamplePage.xaml?example={example}"</span>
              <span style="color: rgb(0, 0, 255);">/&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;/</span>
              <span style="color: rgb(128, 0, 0);">nav:UriMapper</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
          </div>
        </div>
        <p>
Currently the UriMapper can only be defined in the App.xaml. Hopefully we’ll be able
to move this to resource dictionary or even the same file as the Frame control.
</p>
        <p>
Along with my changes to the App.xaml I added one Page to my project, ExamplePage.xaml.
</p>
        <div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
          <div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">navigation:Page</span>
              <span style="color: rgb(255, 0, 0);">x:Class</span>
              <span style="color: rgb(0, 0, 255);">="SilverlightOverview.ExamplePage"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(255, 0, 0);">xmlns</span>
              <span style="color: rgb(0, 0, 255);">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(255, 0, 0);">xmlns:x</span>
              <span style="color: rgb(0, 0, 255);">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(255, 0, 0);">xmlns:navigation</span>
              <span style="color: rgb(0, 0, 255);">="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(255, 0, 0);">Title</span>
              <span style="color: rgb(0, 0, 255);">="Example
Page"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(255, 0, 0);">xmlns:slo</span>
              <span style="color: rgb(0, 0, 255);">="clr-namespace:SilverlightOverview"</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(255, 0, 0);">Loaded</span>
              <span style="color: rgb(0, 0, 255);">="Page_Loaded"</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">Grid</span>
              <span style="color: rgb(255, 0, 0);">x:Name</span>
              <span style="color: rgb(0, 0, 255);">="LayoutRoot"</span>
              <span style="color: rgb(255, 0, 0);">Background</span>
              <span style="color: rgb(0, 0, 255);">="White"</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;</span>
              <span style="color: rgb(128, 0, 0);">slo:XamlViewer</span>
              <span style="color: rgb(255, 0, 0);">x:Name</span>
              <span style="color: rgb(0, 0, 255);">="viewer"</span>
              <span style="color: rgb(0, 0, 255);">/&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;/</span>
              <span style="color: rgb(128, 0, 0);">Grid</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(0, 0, 255);">&lt;/</span>
              <span style="color: rgb(128, 0, 0);">navigation:Page</span>
              <span style="color: rgb(0, 0, 255);">&gt;</span>
            </pre>
          </div>
        </div>
        <div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
          <div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 1:</span>
              <span style="color: rgb(0, 0, 255);">public</span>
              <span style="color: rgb(0, 0, 255);">partial</span>
              <span style="color: rgb(0, 0, 255);">class</span> ExamplePage</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 2:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 3:</span>
              <span style="color: rgb(0, 0, 255);">public</span> ExamplePage()</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 4:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 5:</span> InitializeComponent();</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 6:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 7:</span>  </pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 8:</span>
              <span style="color: rgb(0, 0, 255);">private</span>
              <span style="color: rgb(0, 0, 255);">void</span> Page_Loaded(<span style="color: rgb(0, 0, 255);">object</span> sender,
RoutedEventArgs e)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 9:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 10:</span>
              <span style="color: rgb(0, 0, 255);">if</span> (<span style="color: rgb(0, 0, 255);">this</span>.NavigationContext.QueryString[<span style="color: rgb(0, 96, 128);">"example"</span>]
!= <span style="color: rgb(0, 0, 255);">null</span>)</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 11:</span> {</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 12:</span> viewer.XamlFilename
= <span style="color: rgb(0, 0, 255);">string</span>.Format(<span style="color: rgb(0, 96, 128);">"SilverlightOverview.Xaml.{0}.xaml"</span>,</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 13:</span>
              <span style="color: rgb(0, 0, 255);">this</span>.NavigationContext.QueryString[<span style="color: rgb(0, 96, 128);">"example"</span>]);</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 14:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 15:</span> }</pre>
            <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
              <span style="color: rgb(96, 96, 96);"> 16:</span> }</pre>
          </div>
        </div>
        <p>
Running the project shows that my URLs to look like this.
</p>
        <p>
          <img style="border-width: 0px; display: inline; margin-left: 0px; margin-right: 0px;" title="SilverlightNavApp_URL" alt="SilverlightNavApp_URL" src="http://programwith.net/images/SilverlightNavApp_URL.jpg" border="0" />
        </p>
        <p>
You can even <a href="http://programwith.net/SilverlightOverview/Default.html#Examples/RotateTransform" target="_blank">try
it for yourself</a> if you have the <a href="http://silverlight.net/getstarted/silverlight3/default.aspx" target="_blank">Silverlight
3 Beta 1</a> runtime installed.
</p>
        <p>
I really wanted to avoid the “Examples/” part of the URL since I only have one view,
but there is a limitation built in which throws exceptions if I don’t have at least
a something in there.
</p>
        <p>
At this point all I had to do was add a TreeView and Frame to a Grid in my MainPage.xaml,
bind the tree to a static list of example data, and my application is running. I’d
like to figure out a way to dynamically change the page’s title, but I ran out of
time. At first glace it appears that the only place to do this is from within the
Page control, but I bet there’s way to get the currently displayed page from the Frame.
</p>
        <p>
You can view the <a href="http://programwith.net/SilverlightOverview/Default.html" target="_blank">Silverlight
Overview application here</a>. At the time of writing this blog post, the deep linking
is the only Silverlight 3 feature that’s been added.
</p>
        <h4>Summary
</h4>
        <p>
          <strong>The Good</strong>:  The Navigation Framework is a really great addition
to Silverlight!
</p>
        <p>
          <strong>The Bad</strong>:  I’d rather be able to manually add items to the browser
history and display pages based on the URL, but this solution will be fine for now.
I think there might be a way to do that, but I could not find any other documentation
and I ran out of time to look through everything with Reflector.
</p>
        <p>
          <strong>The Beautiful:</strong>  I finally have something to point to when Flash
developers ask what Silverlight has to offer that Flash/Flex does’t.
</p>
        <p>
          <em>(note – I wanted to summarize with the good, the bad and the ugly, but there’s
nothing truly ugly about Silverlight 3 so I went with the opposite)</em>
        </p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=31941008-466d-4308-a7e8-25d246dcf961" />
      </body>
      <title>Silverlight 3 &amp;ndash; Deep Linking</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,31941008-466d-4308-a7e8-25d246dcf961.aspx</guid>
      <link>http://programwith.net/2009/03/23/Silverlight3NdashDeepLinking.aspx</link>
      <pubDate>Mon, 23 Mar 2009 05:11:13 GMT</pubDate>
      <description>&lt;p&gt;
This is part 1 of my &lt;a href="http://programwith.net/2009/03/23/Silverlight3FeatureByFeature.aspx" target="_blank"&gt;Silverlight
3 Feature By Feature&lt;/a&gt; series of blog posts.
&lt;/p&gt;
&lt;h4&gt;No More Blank Slate
&lt;/h4&gt;
&lt;p align="left"&gt;
The first thing you may try after installing the &lt;a href="http://silverlight.net/getstarted/silverlight3/default.aspx" target="_blank"&gt;Silverlight
3 Beta 1 Tools&lt;/a&gt; is creating a new Silverlight application. There is a new project
template available called &lt;strong&gt;Silverlight Navigation Application&lt;/strong&gt;. Using
this project template creates a Silverlight project with a few things already set
up for you. This is a departure from what we've had so far - a blank slate that is
intimidating and doesn't really help new developers.
&lt;/p&gt;
&lt;p align="left"&gt;
The new project contains the typical App.xaml but now with a bunch styles used in
the main page. The MainPage.xaml is a generic, but nice looking, layout for an example
Silverlight application. There are links to the Home and About views, which are both
located in the Views folder of the project along with a view reserved for errors.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-width: 0px; margin: 0px; display: inline;" title="SilverlightNavApp_SlnExpl" alt="SilverlightNavApp_SlnExpl" src="http://programwith.net/images/SilverlightNavApp_SlnExpl.jpg" border="0"&gt;
&lt;/p&gt;
&lt;p&gt;
Running the application without any changes shows the full page Silverlight application.
Click on the links will change the URL in your browser and update the browsing history.
You can use these URLs to go to a specific view. For example, from the About view
copy the URL, then open an alternative browser and paste in the URL. Viola! Deep linking!
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="SilverlightNavApp_FirstRun" alt="SilverlightNavApp_FirstRun" src="http://programwith.net/images/SilverlightNavApp_FirstRun.jpg" border="0"&gt; 
&lt;/p&gt;
&lt;h4&gt;How It Works
&lt;/h4&gt;
&lt;p&gt;
The trick to the navigation, as implemented in the project template, is the &lt;strong&gt;Frame&lt;/strong&gt; control
in MainPage.xaml.
&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;UserControl&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x:Class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="SilverlightNavigation.MainPage"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 2:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 3:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 4:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns:navigation&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 5:&lt;/span&gt; ...&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 6:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;navigation:Frame&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x:Name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Frame"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Source&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="/Views/HomePage.xaml"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 7:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalContentAlignment&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Stretch"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 8:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;VerticalContentAlignment&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Stretch"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 9:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Padding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="15,10,15,10"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 10:&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="White"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 11:&lt;/span&gt; ...&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 12:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;UserControl&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
In particular, notice the navigation namespace. The project has a reference to the &lt;strong&gt;System.Windows.Controls.Navigation&lt;/strong&gt; assembly
which contains new controls and other things used for navigation.
&lt;/p&gt;
&lt;p&gt;
The Frame is instructed to navigate in the Click event handler of the buttons.
&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; NavButton_Click(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender,
RoutedEventArgs e)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 3:&lt;/span&gt; Button
navigationButton = sender &lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt; Button;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 4:&lt;/span&gt; String
goToPage = navigationButton.Tag.ToString();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 5:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Frame.Navigate(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Uri(goToPage,
UriKind.Relative));&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 6:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
I don’t exactly like the method of storing the destination page in the buttons’ Tag
property, but that could easily be encapsulated by a custom NavigationButton control.
Perhaps we’ll get one before RTW? I’ll definitely have to expand on this in a separate
blog post.
&lt;/p&gt;
&lt;p&gt;
HomePage.xaml and AboutPage.xaml are both &lt;strong&gt;Page&lt;/strong&gt; objects instead of
UserControl, which is typically the base control of new XAML files in a Silverlight
2 project. Its easy enough to add new navigable content to your application. Just
add a new item to your project, and choose the &lt;strong&gt;Silverlight Page&lt;/strong&gt; template
in the &lt;strong&gt;Add New Item&lt;/strong&gt; dialog.
&lt;/p&gt;
&lt;h4&gt;Custom Navigation
&lt;/h4&gt;
&lt;p&gt;
What I wanted to do with my &lt;a href="http://silverlightoverview.codeplex.com/" target="_blank"&gt;Silverlight
Overview&lt;/a&gt; application was have a tree view control listing all of the examples,
and each of these example pages showing up as a unique URL so I could link to a specific
example. My original Silverlight Demo application had examples split into tab controls.
Each tab was a separate XAML file. I could have modified these to be a Page instead
of UserControl, but I wanted to break them down further and didn’t relish the thought
of having 30+ Page files.
&lt;/p&gt;
&lt;p&gt;
Using &lt;a href="http://www.red-gate.com/products/reflector/" target="_blank"&gt;Reflector&lt;/a&gt;,
I found that the Frame control’s Navigate method is using the NavigationService. Looking
into this code wasn’t leading me anywhere so I decided to look at the &lt;a href="http://msdn.microsoft.com/en-us/library/cc838158%28VS.96%29.aspx" target="_blank"&gt;Silverlight
3&lt;/a&gt; documentation on MSDN. Interestingly, the only page that I found related to
navigation, &lt;a href="http://msdn.microsoft.com/en-us/library/cc838245%28VS.96%29.aspx" target="_blank"&gt;Navigation
Overview&lt;/a&gt;, hasn’t been updated for Silverlight 3 and contains incorrect information.
Finally I found Tim Heuer’s &lt;a href="http://silverlight.net/learn/learnvideo.aspx?video=187319" target="_blank"&gt;Navigation
Framework screencast&lt;/a&gt; and &lt;a href="http://timheuer.com/blog/archive/2009/03/22/silverlight-navigation-framework-and-uri-routing.aspx" target="_blank"&gt;blog
post&lt;/a&gt; which shows how to use the &lt;strong&gt;UriMapper &lt;/strong&gt;to accomplish what
I’m looking for.
&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;nav:UriMapper&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x:Key&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="uriMapper"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;nav:UriMapping&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Uri&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Examples/{example}"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;MappedUri&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="/ExamplePage.xaml?example={example}"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;nav:UriMapper&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Currently the UriMapper can only be defined in the App.xaml. Hopefully we’ll be able
to move this to resource dictionary or even the same file as the Frame control.
&lt;/p&gt;
&lt;p&gt;
Along with my changes to the App.xaml I added one Page to my project, ExamplePage.xaml.
&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;navigation:Page&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x:Class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="SilverlightOverview.ExamplePage"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;           &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;           &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;           &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns:navigation&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;           &lt;span style="color: rgb(255, 0, 0);"&gt;Title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Example
Page"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;           &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns:slo&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="clr-namespace:SilverlightOverview"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;           &lt;span style="color: rgb(255, 0, 0);"&gt;Loaded&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Page_Loaded"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Grid&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x:Name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="LayoutRoot"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="White"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;slo:XamlViewer&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x:Name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="viewer"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Grid&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;navigation:Page&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;partial&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; ExamplePage&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 3:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; ExamplePage()&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 4:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 5:&lt;/span&gt; InitializeComponent();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 6:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 8:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Page_Loaded(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender,
RoutedEventArgs e)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 9:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 10:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.NavigationContext.QueryString[&lt;span style="color: rgb(0, 96, 128);"&gt;"example"&lt;/span&gt;]
!= &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 11:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 12:&lt;/span&gt; viewer.XamlFilename
= &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.Format(&lt;span style="color: rgb(0, 96, 128);"&gt;"SilverlightOverview.Xaml.{0}.xaml"&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 13:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.NavigationContext.QueryString[&lt;span style="color: rgb(0, 96, 128);"&gt;"example"&lt;/span&gt;]);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 14:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 15:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 16:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Running the project shows that my URLs to look like this.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-width: 0px; display: inline; margin-left: 0px; margin-right: 0px;" title="SilverlightNavApp_URL" alt="SilverlightNavApp_URL" src="http://programwith.net/images/SilverlightNavApp_URL.jpg" border="0"&gt; 
&lt;/p&gt;
&lt;p&gt;
You can even &lt;a href="http://programwith.net/SilverlightOverview/Default.html#Examples/RotateTransform" target="_blank"&gt;try
it for yourself&lt;/a&gt; if you have the &lt;a href="http://silverlight.net/getstarted/silverlight3/default.aspx" target="_blank"&gt;Silverlight
3 Beta 1&lt;/a&gt; runtime installed.
&lt;/p&gt;
&lt;p&gt;
I really wanted to avoid the “Examples/” part of the URL since I only have one view,
but there is a limitation built in which throws exceptions if I don’t have at least
a something in there.
&lt;/p&gt;
&lt;p&gt;
At this point all I had to do was add a TreeView and Frame to a Grid in my MainPage.xaml,
bind the tree to a static list of example data, and my application is running. I’d
like to figure out a way to dynamically change the page’s title, but I ran out of
time. At first glace it appears that the only place to do this is from within the
Page control, but I bet there’s way to get the currently displayed page from the Frame.
&lt;/p&gt;
&lt;p&gt;
You can view the &lt;a href="http://programwith.net/SilverlightOverview/Default.html" target="_blank"&gt;Silverlight
Overview application here&lt;/a&gt;. At the time of writing this blog post, the deep linking
is the only Silverlight 3 feature that’s been added.
&lt;/p&gt;
&lt;h4&gt;Summary
&lt;/h4&gt;
&lt;p&gt;
&lt;strong&gt;The Good&lt;/strong&gt;:&amp;nbsp; The Navigation Framework is a really great addition
to Silverlight!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The Bad&lt;/strong&gt;:&amp;nbsp; I’d rather be able to manually add items to the browser
history and display pages based on the URL, but this solution will be fine for now.
I think there might be a way to do that, but I could not find any other documentation
and I ran out of time to look through everything with Reflector.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The Beautiful:&lt;/strong&gt;&amp;nbsp; I finally have something to point to when Flash
developers ask what Silverlight has to offer that Flash/Flex does’t.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;(note – I wanted to summarize with the good, the bad and the ugly, but there’s
nothing truly ugly about Silverlight 3 so I went with the opposite)&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=31941008-466d-4308-a7e8-25d246dcf961" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,31941008-466d-4308-a7e8-25d246dcf961.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=dca5f26d-6b42-4966-936b-33e10cc55bbb</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,dca5f26d-6b42-4966-936b-33e10cc55bbb.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,dca5f26d-6b42-4966-936b-33e10cc55bbb.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=dca5f26d-6b42-4966-936b-33e10cc55bbb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m starting a series of blog posts where I’d go through each of Silverlight 3’s new
features. To do this, I’m taking my Silverlight Demo application and updating it to
include these new features.
</p>
        <h4>Silverlight Overview
</h4>
        <p>
To start this off, I’ve converted my demo application to work with <a href="http://silverlight.net/getstarted/silverlight3/default.aspx" target="_blank">Silverlight
3 Beta 1</a> and posted it on CodePlex as <a href="http://silverlightoverview.codeplex.com/" target="_blank">Silverlight
Overview</a>. This application is a great interactive introduction and overview of
XAML, controls and data binding in Silverlight. Currently the project only covers
features through Silverlight 2, but I will be updating it as I cover each feature
of Silverlight 3.
</p>
        <h4>Feature By Feature
</h4>
        <p>
I’ll update this post with links as I add posts for each feature of Silverlight 3
to my series.
</p>
        <ul>
          <li>
            <a href="http://programwith.net/2009/03/23/Silverlight3NdashDeepLinking.aspx" target="_blank">Deep
Linking</a>
          </li>
          <li>
Out of Browser (coming soon) 
</li>
          <li>
Data Binding (coming soon) 
</li>
          <li>
Perspective 3D (coming soon) 
</li>
          <li>
Easing Animations (coming soon) 
</li>
          <li>
Pixel Shader (coming soon) 
</li>
          <li>
Resource Dictionaries (coming soon) 
</li>
          <li>
Bitmap Enhancements (coming soon) 
</li>
          <li>
more when I get there ;-)</li>
        </ul>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=dca5f26d-6b42-4966-936b-33e10cc55bbb" />
      </body>
      <title>Silverlight 3 Feature By Feature</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,dca5f26d-6b42-4966-936b-33e10cc55bbb.aspx</guid>
      <link>http://programwith.net/2009/03/23/Silverlight3FeatureByFeature.aspx</link>
      <pubDate>Mon, 23 Mar 2009 05:06:23 GMT</pubDate>
      <description>&lt;p&gt;
I’m starting a series of blog posts where I’d go through each of Silverlight 3’s new
features. To do this, I’m taking my Silverlight Demo application and updating it to
include these new features.
&lt;/p&gt;
&lt;h4&gt;Silverlight Overview
&lt;/h4&gt;
&lt;p&gt;
To start this off, I’ve converted my demo application to work with &lt;a href="http://silverlight.net/getstarted/silverlight3/default.aspx" target="_blank"&gt;Silverlight
3 Beta 1&lt;/a&gt; and posted it on CodePlex as &lt;a href="http://silverlightoverview.codeplex.com/" target="_blank"&gt;Silverlight
Overview&lt;/a&gt;. This application is a great interactive introduction and overview of
XAML, controls and data binding in Silverlight. Currently the project only covers
features through Silverlight 2, but I will be updating it as I cover each feature
of Silverlight 3.
&lt;/p&gt;
&lt;h4&gt;Feature By Feature
&lt;/h4&gt;
&lt;p&gt;
I’ll update this post with links as I add posts for each feature of Silverlight 3
to my series.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://programwith.net/2009/03/23/Silverlight3NdashDeepLinking.aspx" target="_blank"&gt;Deep
Linking&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
Out of Browser (coming soon) 
&lt;/li&gt;
&lt;li&gt;
Data Binding (coming soon) 
&lt;/li&gt;
&lt;li&gt;
Perspective 3D (coming soon) 
&lt;/li&gt;
&lt;li&gt;
Easing Animations (coming soon) 
&lt;/li&gt;
&lt;li&gt;
Pixel Shader (coming soon) 
&lt;/li&gt;
&lt;li&gt;
Resource Dictionaries (coming soon) 
&lt;/li&gt;
&lt;li&gt;
Bitmap Enhancements (coming soon) 
&lt;/li&gt;
&lt;li&gt;
more when I get there ;-)&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=dca5f26d-6b42-4966-936b-33e10cc55bbb" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,dca5f26d-6b42-4966-936b-33e10cc55bbb.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=1ac04938-13ad-489c-9b5d-9fb5076e604c</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,1ac04938-13ad-489c-9b5d-9fb5076e604c.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,1ac04938-13ad-489c-9b5d-9fb5076e604c.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=1ac04938-13ad-489c-9b5d-9fb5076e604c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the spirit of <a href="http://mvwood.com/blog/codeshare-week-march-8-14th-2009/">Code
Share Week</a>, I’ve decided to share a base class we’ve been using for our test classes
on my current project.
</p>
        <h4>Specification
</h4>
        <p>
We’ve been using a Specification base class for our NUnit test classes, which is kind
of following the BDD style of unit testing.
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span> [TestFixture]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">class</span> Specification</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span> [SetUp]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Initialize()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span> Mocks
= <span style="color: #0000ff">new</span> MockRepository();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span> Before_each();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> ReplayAll();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span> Because();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 13:</span> [TearDown]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 14:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Cleanup()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 15:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 16:</span> After_each();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 17:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 18:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 19:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">virtual</span>
              <span style="color: #0000ff">void</span> Before_each()
{ }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 20:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">virtual</span>
              <span style="color: #0000ff">void</span> After_each()
{ }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 21:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">virtual</span>
              <span style="color: #0000ff">void</span> Because()
{ }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 22:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 23:</span>
              <span style="color: #0000ff">public</span> MockRepository
Mocks { get; <span style="color: #0000ff">private</span> set; }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 24:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 25:</span>
              <span style="color: #0000ff">protected</span> T
Mock&lt;T&gt;() <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 26:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 27:</span>
              <span style="color: #0000ff">return</span> MockRepository.GenerateMock&lt;T&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 28:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 29:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 30:</span>
              <span style="color: #0000ff">protected</span> T
Stub&lt;T&gt;() <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 31:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 32:</span>
              <span style="color: #0000ff">return</span> MockRepository.GenerateStub&lt;T&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 33:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 34:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 35:</span>
              <span style="color: #0000ff">protected</span> T
Stub&lt;T&gt;(<span style="color: #0000ff">params</span><span style="color: #0000ff">object</span>[]
args) <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 36:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 37:</span>
              <span style="color: #0000ff">return</span> MockRepository.GenerateStub&lt;T&gt;(args);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 38:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 39:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 40:</span>
              <span style="color: #0000ff">protected</span> T
Partial&lt;T&gt;() <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 41:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 42:</span>
              <span style="color: #0000ff">return</span> Mocks.PartialMock&lt;T&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 43:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 44:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 45:</span>
              <span style="color: #0000ff">protected</span> T
Partial&lt;T&gt;(<span style="color: #0000ff">params</span><span style="color: #0000ff">object</span>[]
args) <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 46:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 47:</span>
              <span style="color: #0000ff">return</span> Mocks.PartialMock&lt;T&gt;(args);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 48:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 49:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 50:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">void</span> Raise(<span style="color: #0000ff">object</span> mock, <span style="color: #0000ff">string</span> eventName, <span style="color: #0000ff">object</span> sender,
EventArgs args)</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 51:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 52:</span>
              <span style="color: #0000ff">new</span> EventRaiser((IMockedObject)mock,
eventName).Raise(sender, args);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 53:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 54:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 55:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">virtual</span>
              <span style="color: #0000ff">void</span> ReplayAll()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 56:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 57:</span> Mocks.ReplayAll();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 58:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 59:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 60:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">void</span> spec_not_implemented()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 61:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 62:</span> MethodBase
caller = <span style="color: #0000ff">new</span> StackTrace().GetFrame(1).GetMethod();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 63:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 64:</span> spec_not_implemented(caller.DeclaringType.Name
+ <span style="color: #006080">"."</span> + caller.Name);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 65:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 66:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 67:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">void</span> spec_not_implemented(<span style="color: #0000ff">string</span> specName)</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 68:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 69:</span> Console.WriteLine(<span style="color: #006080">"Specification
not implemented : "</span> + specName);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 70:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 71:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 72:</span> }</pre>
          </div>
        </div>
        <h4>A typical Specification
</h4>
        <p>
Here’s a typical specification written to test user account creation.
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">class</span> When_creating_a_new_user_account
: Specification</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #0000ff">private</span> IThirdPartyUserService
_thirdPartyUserService;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #0000ff">private</span> IUserDetailController
_userDetailController;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #0000ff">private</span> CreateUserCommand
_newUserCommand;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>
              <span style="color: #0000ff">private</span> UserService
_userService;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Before_each()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span> _thirdPartyUserService
= Stub&lt;IThirdPartyUserService&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span> _userDetailController
= Stub&lt;IUserDetailController&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span> var
lookupService = Stub&lt;ILookupService&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 13:</span> var
logService = Stub&lt;ILogService&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 14:</span> var
encryptionService = Stub&lt;IEncryptionService&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 15:</span> _newUserCommand
= <span style="color: #0000ff">new</span> CreateUserCommand();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 16:</span> _thirdPartyUserService.Stub(tpus
=&gt; tpus.CreateUser(_newUserCommand)).Return(<span style="color: #006080">"fakeAuthTicket"</span>);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 17:</span> encryptionService.Stub(es
=&gt; es.Encrypt(_newUserCommand.Password)).Return(_newUserCommand.Password);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 18:</span> _userService
= <span style="color: #0000ff">new</span> UserService(_thirdPartyUserService, _userDetailController, </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 19:</span> logService,
lookupService, encryptionService);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 20:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 21:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 22:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Because()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 23:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 24:</span> _userService.CreateUser(_newUserCommand);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 25:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 26:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 27:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 28:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Should_call_the_ThirdParty_user_service()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 29:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 30:</span> _thirdPartyUserService.AssertWasCalled(tpus
=&gt; tpus.CreateUser(_newUserCommand));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 31:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 32:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 33:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 34:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Should_call_the_UserDetailController_to_persist_data()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 35:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 36:</span> _userDetailController.AssertWasCalled(udc
=&gt; udc.Insert(_newUserCommand.Login,</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 37:</span> _newUserCommand.Password,
_newUserCommand.Email));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 38:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 39:</span> }</pre>
          </div>
        </div>
        <h4>Specification using RhinoAutoMocker
</h4>
        <p>
One problem we ran into was that the UserService class kept having dependencies added
as more functionality was added to the class. We’re using <a href="http://structuremap.sourceforge.net/Default.htm">StructureMap</a> as
an IoC container, so there’s no impact to code when you add a dependency to a constructor,
but it was requiring us to refactor our tests since we’re not using StructureMap to
create instances inside of our tests.
</p>
        <p>
StructureMap comes with a separate assembly containing the <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/10/05/using-the-rhinoautomocker-that-is-part-of-structuremap-2-5.aspx">RhinoAutoMocker</a> which
my colleague <a href="http://jonkruger.com/blog/">Jon Kruger</a> suggested would solve
our constant refactoring problem. You can use the auto mocker functionality to automatically
mock all dependencies of a class. This also cleans up your code because you don’t
have to create fields for dependencies that you plan on using in multiple test methods.
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">class</span> When_creating_a_new_user_account
: Specification</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #0000ff">private</span> RhinoAutoMocker&lt;UserService&gt;
_mocker;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #0000ff">private</span> IThirdPartyUserService
_thirdPartyUserService;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #0000ff">private</span> IUserDetailController
_userDetailController;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>
              <span style="color: #0000ff">private</span> CreateUserCommand
_newUserCommand;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Before_each()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span> _mocker
= <span style="color: #0000ff">new</span> RhinoAutoMocker&lt;UserService&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span> _newUserCommand
= <span style="color: #0000ff">new</span> CreateUserCommand();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span> _thirdPartyUserService
= _mocker.Get&lt;IThirdPartyUserService&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 13:</span> _thirdPartyUserService.Stub(tpus
=&gt; tpus.CreateUser(_newUserCommand))</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 14:</span> .Return(<span style="color: #006080">"fakeAuthTicket"</span>);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 15:</span> _userDetailController
= _mocker.Get&lt;IUserDetailController&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 16:</span> _mocker.Get&lt;IEncryptionService&gt;().Stub(es
=&gt; es.Encrypt(_newUserCommand.Password))</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 17:</span> .Return(_newUserCommand.Password);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 18:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 19:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 20:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Because()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 21:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 22:</span> _mocker.ClassUnderTest.CreateUser(_newUserCommand);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 23:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 24:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 25:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 26:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Should_call_the_ThirdParty_user_service()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 27:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 28:</span> _thirdPartyUserService.AssertWasCalled(tpus
=&gt; tpus.CreateUser(_newUserCommand));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 29:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 30:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 31:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 32:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Should_call_the_UserDetailController_to_persist_data()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 33:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 34:</span> _userDetailController.AssertWasCalled(udc
=&gt; udc.Insert(_newUserCommand.Login,</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 35:</span> _newUserCommand.Password,
_newUserCommand.Email));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 36:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 37:</span> }</pre>
          </div>
        </div>
        <h4>AutoMockingSpecification
</h4>
        <p>
I took this a step further and created a base class that is used when you’re only
testing one class. It doesn’t add all that much functionality, but it does make your
specs look much cleaner.
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">class</span> AutoMockingSpecification&lt;T&gt;
: Specification</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span>
              <span style="color: #0000ff">where</span> T
: <span style="color: #0000ff">class</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>
              <span style="color: #0000ff">private</span>
              <span style="color: #0000ff">bool</span> _replayTheClassUnderTest
= <span style="color: #0000ff">false</span>;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span>
              <span style="color: #0000ff">public</span> RhinoAutoMocker&lt;T&gt;
Mocker { get; set; }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Before_each()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span>
              <span style="color: #0000ff">base</span>.Before_each();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span> Mocker
= <span style="color: #0000ff">new</span> RhinoAutoMocker&lt;T&gt;();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 13:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 14:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> ReplayAll()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 15:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 16:</span>
              <span style="color: #0000ff">base</span>.ReplayAll();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 17:</span>
              <span style="color: #0000ff">if</span> (_replayTheClassUnderTest)</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 18:</span> Mocker.ClassUnderTest.Replay();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 19:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 20:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 21:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">virtual</span>
              <span style="color: #0000ff">void</span> PartialMockTheClassUnderTest()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 22:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 23:</span> Mocker.PartialMockTheClassUnderTest();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 24:</span> _replayTheClassUnderTest
= <span style="color: #0000ff">true</span>;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 25:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 26:</span> }</pre>
          </div>
        </div>
        <h4>Specification Using AutoMockingSpecification
</h4>
        <p>
Here’s our sample UserService specification refactored to use the AutoMockingSpecification
base class.
</p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 1:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">class</span> When_creating_a_new_user_account
: AutoMockingSpecification&lt;UserService&gt;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 2:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 3:</span>
              <span style="color: #0000ff">private</span> CreateUserCommand
_newUserCommand;</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 4:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 5:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Before_each()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 6:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 7:</span>
              <span style="color: #0000ff">base</span>.Before_each();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 8:</span> _newUserCommand
= <span style="color: #0000ff">new</span> CreateUserCommand();</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 9:</span> Mocker.Get&lt;IThirdPartyUserService&gt;().Stub(tpus
=&gt; tpus.CreateUser(_newUserCommand))</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 10:</span> .Return(<span style="color: #006080">"fakeAuthTicket"</span>);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 11:</span> Mocker.Get&lt;IEncryptionService&gt;().Stub(es
=&gt; es.Encrypt(_newUserCommand.Password))</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 12:</span> .Return(_newUserCommand.Password);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 13:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 14:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 15:</span>
              <span style="color: #0000ff">protected</span>
              <span style="color: #0000ff">override</span>
              <span style="color: #0000ff">void</span> Because()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 16:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 17:</span> Mocker.ClassUnderTest.CreateUser(_newUserCommand);</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 18:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 19:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 20:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 21:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Should_call_the_ThirdParty_user_service()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 22:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 23:</span> Mocker.Get&lt;IThirdPartyUserService&gt;().AssertWasCalled(tpus
=&gt; tpus.CreateUser(_newUserCommand));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 24:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 25:</span>  </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 26:</span> [Test]</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 27:</span>
              <span style="color: #0000ff">public</span>
              <span style="color: #0000ff">void</span> Should_call_the_UserDetailController_to_persist_data()</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 28:</span> {</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 29:</span> Mocker.Get&lt;IUserDetailController&gt;().AssertWasCalled(</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 30:</span> udc
=&gt; udc.Insert(_newUserCommand.Login, _newUserCommand.Password, _newUserCommand.Email));</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #606060"> 31:</span> }</pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #606060"> 32:</span> }</pre>
          </div>
        </div>
        <p>
        </p>
        <p>
 
</p>
        <p>
I’m pleased with the result, and it seems to be pretty popular with the other developers
on our project.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=1ac04938-13ad-489c-9b5d-9fb5076e604c" />
      </body>
      <title>Automatic Mocking Specification</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,1ac04938-13ad-489c-9b5d-9fb5076e604c.aspx</guid>
      <link>http://programwith.net/2009/03/14/AutomaticMockingSpecification.aspx</link>
      <pubDate>Sat, 14 Mar 2009 19:29:41 GMT</pubDate>
      <description>&lt;p&gt;
In the spirit of &lt;a href="http://mvwood.com/blog/codeshare-week-march-8-14th-2009/"&gt;Code
Share Week&lt;/a&gt;, I’ve decided to share a base class we’ve been using for our test classes
on my current project.
&lt;/p&gt;
&lt;h4&gt;Specification
&lt;/h4&gt;
&lt;p&gt;
We’ve been using a Specification base class for our NUnit test classes, which is kind
of following the BDD style of unit testing.
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; [TestFixture]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Specification&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; [SetUp]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Initialize()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; Mocks
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MockRepository();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; Before_each();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; ReplayAll();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; Because();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 13:&lt;/span&gt; [TearDown]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 14:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Cleanup()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 15:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 16:&lt;/span&gt; After_each();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 17:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 19:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Before_each()
{ }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 20:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; After_each()
{ }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 21:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Because()
{ }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 22:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 23:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MockRepository
Mocks { get; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; set; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 24:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 25:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; T
Mock&amp;lt;T&amp;gt;() &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 26:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 27:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; MockRepository.GenerateMock&amp;lt;T&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 28:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 29:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 30:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; T
Stub&amp;lt;T&amp;gt;() &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 31:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 32:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; MockRepository.GenerateStub&amp;lt;T&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 33:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 34:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 35:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; T
Stub&amp;lt;T&amp;gt;(&lt;span style="color: #0000ff"&gt;params&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;[]
args) &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 36:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 37:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; MockRepository.GenerateStub&amp;lt;T&amp;gt;(args);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 38:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 39:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 40:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; T
Partial&amp;lt;T&amp;gt;() &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 41:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 42:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Mocks.PartialMock&amp;lt;T&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 43:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 44:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 45:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; T
Partial&amp;lt;T&amp;gt;(&lt;span style="color: #0000ff"&gt;params&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;[]
args) &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 46:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 47:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Mocks.PartialMock&amp;lt;T&amp;gt;(args);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 48:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 49:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 50:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Raise(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; mock, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; eventName, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender,
EventArgs args)&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 51:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 52:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventRaiser((IMockedObject)mock,
eventName).Raise(sender, args);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 53:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 54:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 55:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ReplayAll()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 56:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 57:&lt;/span&gt; Mocks.ReplayAll();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 58:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 59:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 60:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; spec_not_implemented()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 61:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 62:&lt;/span&gt; MethodBase
caller = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; StackTrace().GetFrame(1).GetMethod();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 63:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 64:&lt;/span&gt; spec_not_implemented(caller.DeclaringType.Name
+ &lt;span style="color: #006080"&gt;"."&lt;/span&gt; + caller.Name);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 65:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 66:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 67:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; spec_not_implemented(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; specName)&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 68:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 69:&lt;/span&gt; Console.WriteLine(&lt;span style="color: #006080"&gt;"Specification
not implemented : "&lt;/span&gt; + specName);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 70:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 71:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 72:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;A typical Specification
&lt;/h4&gt;
&lt;p&gt;
Here’s a typical specification written to test user account creation.
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; When_creating_a_new_user_account
: Specification&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IThirdPartyUserService
_thirdPartyUserService;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IUserDetailController
_userDetailController;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; CreateUserCommand
_newUserCommand;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; UserService
_userService;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Before_each()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; _thirdPartyUserService
= Stub&amp;lt;IThirdPartyUserService&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; _userDetailController
= Stub&amp;lt;IUserDetailController&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt; var
lookupService = Stub&amp;lt;ILookupService&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 13:&lt;/span&gt; var
logService = Stub&amp;lt;ILogService&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 14:&lt;/span&gt; var
encryptionService = Stub&amp;lt;IEncryptionService&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 15:&lt;/span&gt; _newUserCommand
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CreateUserCommand();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 16:&lt;/span&gt; _thirdPartyUserService.Stub(tpus
=&amp;gt; tpus.CreateUser(_newUserCommand)).Return(&lt;span style="color: #006080"&gt;"fakeAuthTicket"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 17:&lt;/span&gt; encryptionService.Stub(es
=&amp;gt; es.Encrypt(_newUserCommand.Password)).Return(_newUserCommand.Password);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 18:&lt;/span&gt; _userService
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UserService(_thirdPartyUserService, _userDetailController, &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 19:&lt;/span&gt; logService,
lookupService, encryptionService);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 20:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 21:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 22:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Because()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 23:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 24:&lt;/span&gt; _userService.CreateUser(_newUserCommand);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 25:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 26:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 27:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 28:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Should_call_the_ThirdParty_user_service()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 29:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 30:&lt;/span&gt; _thirdPartyUserService.AssertWasCalled(tpus
=&amp;gt; tpus.CreateUser(_newUserCommand));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 31:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 32:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 33:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 34:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Should_call_the_UserDetailController_to_persist_data()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 35:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 36:&lt;/span&gt; _userDetailController.AssertWasCalled(udc
=&amp;gt; udc.Insert(_newUserCommand.Login,&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 37:&lt;/span&gt; _newUserCommand.Password,
_newUserCommand.Email));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 38:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 39:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;Specification using RhinoAutoMocker
&lt;/h4&gt;
&lt;p&gt;
One problem we ran into was that the UserService class kept having dependencies added
as more functionality was added to the class. We’re using &lt;a href="http://structuremap.sourceforge.net/Default.htm"&gt;StructureMap&lt;/a&gt; as
an IoC container, so there’s no impact to code when you add a dependency to a constructor,
but it was requiring us to refactor our tests since we’re not using StructureMap to
create instances inside of our tests.
&lt;/p&gt;
&lt;p&gt;
StructureMap comes with a separate assembly containing the &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/10/05/using-the-rhinoautomocker-that-is-part-of-structuremap-2-5.aspx"&gt;RhinoAutoMocker&lt;/a&gt; which
my colleague &lt;a href="http://jonkruger.com/blog/"&gt;Jon Kruger&lt;/a&gt; suggested would solve
our constant refactoring problem. You can use the auto mocker functionality to automatically
mock all dependencies of a class. This also cleans up your code because you don’t
have to create fields for dependencies that you plan on using in multiple test methods.
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; When_creating_a_new_user_account
: Specification&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; RhinoAutoMocker&amp;lt;UserService&amp;gt;
_mocker;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IThirdPartyUserService
_thirdPartyUserService;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IUserDetailController
_userDetailController;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; CreateUserCommand
_newUserCommand;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Before_each()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; _mocker
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RhinoAutoMocker&amp;lt;UserService&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; _newUserCommand
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CreateUserCommand();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt; _thirdPartyUserService
= _mocker.Get&amp;lt;IThirdPartyUserService&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 13:&lt;/span&gt; _thirdPartyUserService.Stub(tpus
=&amp;gt; tpus.CreateUser(_newUserCommand))&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 14:&lt;/span&gt; .Return(&lt;span style="color: #006080"&gt;"fakeAuthTicket"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 15:&lt;/span&gt; _userDetailController
= _mocker.Get&amp;lt;IUserDetailController&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 16:&lt;/span&gt; _mocker.Get&amp;lt;IEncryptionService&amp;gt;().Stub(es
=&amp;gt; es.Encrypt(_newUserCommand.Password))&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 17:&lt;/span&gt; .Return(_newUserCommand.Password);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 18:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 19:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 20:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Because()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 21:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 22:&lt;/span&gt; _mocker.ClassUnderTest.CreateUser(_newUserCommand);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 23:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 24:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 25:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 26:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Should_call_the_ThirdParty_user_service()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 27:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 28:&lt;/span&gt; _thirdPartyUserService.AssertWasCalled(tpus
=&amp;gt; tpus.CreateUser(_newUserCommand));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 29:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 30:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 31:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 32:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Should_call_the_UserDetailController_to_persist_data()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 33:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 34:&lt;/span&gt; _userDetailController.AssertWasCalled(udc
=&amp;gt; udc.Insert(_newUserCommand.Login,&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 35:&lt;/span&gt; _newUserCommand.Password,
_newUserCommand.Email));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 36:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 37:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;AutoMockingSpecification
&lt;/h4&gt;
&lt;p&gt;
I took this a step further and created a base class that is used when you’re only
testing one class. It doesn’t add all that much functionality, but it does make your
specs look much cleaner.
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; AutoMockingSpecification&amp;lt;T&amp;gt;
: Specification&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T
: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; _replayTheClassUnderTest
= &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; RhinoAutoMocker&amp;lt;T&amp;gt;
Mocker { get; set; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Before_each()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Before_each();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; Mocker
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RhinoAutoMocker&amp;lt;T&amp;gt;();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 13:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 14:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ReplayAll()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 15:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 16:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.ReplayAll();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 17:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (_replayTheClassUnderTest)&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 18:&lt;/span&gt; Mocker.ClassUnderTest.Replay();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 19:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 21:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; PartialMockTheClassUnderTest()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 22:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 23:&lt;/span&gt; Mocker.PartialMockTheClassUnderTest();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 24:&lt;/span&gt; _replayTheClassUnderTest
= &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 25:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 26:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;Specification Using AutoMockingSpecification
&lt;/h4&gt;
&lt;p&gt;
Here’s our sample UserService specification refactored to use the AutoMockingSpecification
base class.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; When_creating_a_new_user_account
: AutoMockingSpecification&amp;lt;UserService&amp;gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; CreateUserCommand
_newUserCommand;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Before_each()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 6:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Before_each();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 8:&lt;/span&gt; _newUserCommand
= &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CreateUserCommand();&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 9:&lt;/span&gt; Mocker.Get&amp;lt;IThirdPartyUserService&amp;gt;().Stub(tpus
=&amp;gt; tpus.CreateUser(_newUserCommand))&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 10:&lt;/span&gt; .Return(&lt;span style="color: #006080"&gt;"fakeAuthTicket"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 11:&lt;/span&gt; Mocker.Get&amp;lt;IEncryptionService&amp;gt;().Stub(es
=&amp;gt; es.Encrypt(_newUserCommand.Password))&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 12:&lt;/span&gt; .Return(_newUserCommand.Password);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 13:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 14:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 15:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Because()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 16:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 17:&lt;/span&gt; Mocker.ClassUnderTest.CreateUser(_newUserCommand);&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 18:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 19:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 20:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 21:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Should_call_the_ThirdParty_user_service()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 22:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 23:&lt;/span&gt; Mocker.Get&amp;lt;IThirdPartyUserService&amp;gt;().AssertWasCalled(tpus
=&amp;gt; tpus.CreateUser(_newUserCommand));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 24:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 26:&lt;/span&gt; [Test]&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 27:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Should_call_the_UserDetailController_to_persist_data()&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 28:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 29:&lt;/span&gt; Mocker.Get&amp;lt;IUserDetailController&amp;gt;().AssertWasCalled(&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 30:&lt;/span&gt; udc
=&amp;gt; udc.Insert(_newUserCommand.Login, _newUserCommand.Password, _newUserCommand.Email));&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 31:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt; 32:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
I’m pleased with the result, and it seems to be pretty popular with the other developers
on our project.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=1ac04938-13ad-489c-9b5d-9fb5076e604c" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,1ac04938-13ad-489c-9b5d-9fb5076e604c.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=92576357-1662-4a83-81fa-68d494931edc</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,92576357-1662-4a83-81fa-68d494931edc.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,92576357-1662-4a83-81fa-68d494931edc.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=92576357-1662-4a83-81fa-68d494931edc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I'll be speaking at the <a href="http://cinnug.org/blog/archive/2009/02/23/cincinnati-silverlight-firestarter.aspx">Cincinnati
Silverlight Firestarter</a> event at the Microsoft office in Mason, OH on March 28th. 
Following in the Cleveland event's footsteps, this is going to have local speakers
and is a great full day introduction to Silverlight.  I'll be giving the Controls
and Databinding post-lunch talk again. (Hopefully this time my laptop will work with
the projector.)<br /><p style="margin: 0in 0in 0pt;">
 
</p><p style="margin: 0in 0in 0pt;">
Agenda:
</p><p style="margin: 0in 0in 0pt;">
 8:30 AM: Registration
</p><p style="margin: 0in 0in 0pt;">
 9:00 AM: An Introduction to Silverlight (<a href="http://www.jeffblankenburg.com/default.aspx">Jeff
Blankenburg</a>)
</p><p style="margin: 0in 0in 0pt;">
 10:30 AM: An Introduction to XAML (<a href="http://joewirtley.blogspot.com/">Joe
Wirtley</a>)
</p><p style="margin: 0in 0in 0pt;">
 11:45 AM: Lunch break
</p><p style="margin: 0in 0in 0pt;">
 12:30 PM: An Introduction to the Tools (<a href="http://joshholmes.com">Josh
Holmes</a>)
</p><p style="margin: 0in 0in 0pt;">
 2:00 PM: An Introduction to Controls &amp; Data Binding (Matt Casto)
</p><p style="margin: 0in 0in 0pt;">
 3:30 PM: Server Communication (<a href="http://clevelanddotnet.blogspot.com/">Sam
Nasr</a><a href="http://riathoughts.com/" />)
</p><p style="margin: 0in 0in 0pt;">
 4:45 PM: Giveaways and closing<br /></p><br /><p style="margin: 0in 0in 0pt;">
To register for this event, please go to <a href="https://www.clicktoattend.com/invitation.aspx?code=136101">https://www.clicktoattend.com/invitation.aspx?code=136101</a><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;Culture=en-US" /></p><p style="margin: 0in 0in 0pt;"><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;Culture=en-US"><br /></a></p><p style="margin: 0in 0in 0pt;">
Hope to see you there!
</p><p /><img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=92576357-1662-4a83-81fa-68d494931edc" /></body>
      <title>Cincinnati Silverlight Firestarter</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,92576357-1662-4a83-81fa-68d494931edc.aspx</guid>
      <link>http://programwith.net/2009/03/13/CincinnatiSilverlightFirestarter.aspx</link>
      <pubDate>Fri, 13 Mar 2009 14:17:55 GMT</pubDate>
      <description>I'll be speaking at the &lt;a href="http://cinnug.org/blog/archive/2009/02/23/cincinnati-silverlight-firestarter.aspx"&gt;Cincinnati
Silverlight Firestarter&lt;/a&gt; event at the Microsoft office in Mason, OH on March 28th.&amp;nbsp;
Following in the Cleveland event's footsteps, this is going to have local speakers
and is a great full day introduction to Silverlight.&amp;nbsp; I'll be giving the Controls
and Databinding post-lunch talk again. (Hopefully this time my laptop will work with
the projector.)&lt;br&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
Agenda:
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;8:30 AM: Registration
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;9:00 AM: An Introduction to Silverlight (&lt;a href="http://www.jeffblankenburg.com/default.aspx"&gt;Jeff
Blankenburg&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;10:30 AM: An Introduction to XAML (&lt;a href="http://joewirtley.blogspot.com/"&gt;Joe
Wirtley&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;11:45 AM: Lunch break
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;12:30 PM: An Introduction to the Tools (&lt;a href="http://joshholmes.com"&gt;Josh
Holmes&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;2:00 PM: An Introduction to Controls &amp;amp; Data Binding (Matt Casto)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;3:30 PM: Server Communication (&lt;a href="http://clevelanddotnet.blogspot.com/"&gt;Sam
Nasr&lt;/a&gt;&lt;a href="http://riathoughts.com/"&gt;&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;4:45 PM: Giveaways and closing&lt;br&gt;
&lt;/p&gt;
&lt;br&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
To register for this event, please go to &lt;a href="https://www.clicktoattend.com/invitation.aspx?code=136101"&gt;https://www.clicktoattend.com/invitation.aspx?code=136101&lt;/a&gt;&lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;amp;Culture=en-US"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;amp;Culture=en-US"&gt;
&lt;br&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
Hope to see you there!
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=92576357-1662-4a83-81fa-68d494931edc" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,92576357-1662-4a83-81fa-68d494931edc.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb</wfw:commentRss>
      <slash:comments>10</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I was reading <a href="http://wildermuth.com/2009/03/12/What_I_Use_for_Silverlight_Development">Shawn
Wildermuth</a> and <a href="http://johnpapa.net/silverlight/my-silverlight-war-room/">John
Papa</a>'s blog posts about all of the tools that they use for Silverlight development,
and it finally pushed me to put a thought that's been rattling around in my brain
into words.<br /><br />
Last weekend I was at the <a href="http://artandcode.ning.com/">Art &amp; Code</a> conference
at CMU in Pittsburg presenting, along with <a href="http://twitter.com/timhibner">Tim
Hibner</a>, an introduction to Silverlight. Being in that environment reminded me
of what it was like when I was a student and was looking at various programming languages.
One of the things I was interested in doing back then was developing video games.
I remember looking into Flash programming and was turned off by the cost of the development
environment. To be honest, that was a while ago and I don't remember what the costs
were, but I do remember the feeling that I couldn't bother with the hassle of learning
the platform.<br /><br />
Developing video games like today's casual Flash games is a huge opportunity for an
entry point to learning Silverlight. Just look at all of the Flash <a href="http://www.kongregate.com/">game</a><a href="http://www.newgrounds.com/">sites</a><a href="http://www.flashportal.com/">out</a><a href="http://mochiland.com/articles/45-sites-to-submit-your-flash-games">there</a>.
There are actually some Silverlight specific game sites getting started now like <a href="http://silverarcade.com/">Silver
Arcade</a> and <a href="http://www.silverlightclub.com/">Silverlight Club</a>. In
fact, there is currently a <a href="http://www.serverquestcontest.com/">Silverlight
game development contest</a> with a grand prize of $5000, which should definitely
get people interested.<br /><br />
The first place people interested to start with Silverlight are pointed to is the <a href="http://silverlight.net/getstarted">Get
Started</a> page on the official Silverlight web site. This page starts out by linking
to the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&amp;displaylang=en">Silverlight
Tools for Visual Studio 2008 SP1</a>, which in turn requires you to already have <a href="http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx">Visual
Studio 2008</a> or <a href="http://www.microsoft.com/express/vwd/">Visual Web Developer
Express</a> installed with Service Pack 1. Assuming the user downloads the Visual
Web Developer Express, they have a joy filled hour+ of baby sitting installs. Then,
the second step is to download and install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5FF08106-B9F4-43CD-ABAD-4CC9D9C208D7&amp;displaylang=en">Expression
Blend 2 trial</a>, and download and install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EB9B5C48-BA2B-4C39-A1C3-135C60BBBE66&amp;displaylang=en">Expression
Blend 2 Service Pack 1</a> on top of that. Gah! It goes on from there.<br /><br />
I'm seriously wondering how many people make it that far, or have given up at this
point. I think the final straw for me would have been the fact that Blend is only
a 30 day trial. What do I do after that? Pay <a href="http://www.microsoft.com/expression/products/Purchase.aspx?key=blend">$499
for Expression Blend</a> or <a href="http://www.microsoft.com/expression/products/Purchase.aspx?key=professional">$999
for Expression Studio</a>? No way! Even as a professional developer today I wouldn't
pay that. And, sure, there's <a href="https://www.dreamspark.com/default.aspx">DreamSpark</a>,
but that's an extra hassle, and the get started page doesn't even mention it.<br /><br />
I love Silverlight, but its been easy for me since I've been developing on the Microsoft
platform for over 10 years and I have access to MSDN downloads. Thank goodness for
the fact that Blend is available through that, or else no one would bother with it.<br /><br />
Microsoft has done a great job with making free versions of its tools available lately,
but for all the weight they're putting behind Silverlight I don't understand why they
don't, at the very least, have an Express version of Blend. I would even suggest that
there should be a free version of the entire Expression Suite, although a name like
Expression Suite Express is kinda silly. :-)<br /><p /><img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb" /></body>
      <title>Is Blend's Cost Prohibitive to Silverlight Adoption?</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb.aspx</guid>
      <link>http://programwith.net/2009/03/13/IsBlendsCostProhibitiveToSilverlightAdoption.aspx</link>
      <pubDate>Fri, 13 Mar 2009 12:09:13 GMT</pubDate>
      <description>I was reading &lt;a href="http://wildermuth.com/2009/03/12/What_I_Use_for_Silverlight_Development"&gt;Shawn
Wildermuth&lt;/a&gt; and &lt;a href="http://johnpapa.net/silverlight/my-silverlight-war-room/"&gt;John
Papa&lt;/a&gt;'s blog posts about all of the tools that they use for Silverlight development,
and it finally pushed me to put a thought that's been rattling around in my brain
into words.&lt;br&gt;
&lt;br&gt;
Last weekend I was at the &lt;a href="http://artandcode.ning.com/"&gt;Art &amp;amp; Code&lt;/a&gt; conference
at CMU in Pittsburg presenting, along with &lt;a href="http://twitter.com/timhibner"&gt;Tim
Hibner&lt;/a&gt;, an introduction to Silverlight. Being in that environment reminded me
of what it was like when I was a student and was looking at various programming languages.
One of the things I was interested in doing back then was developing video games.
I remember looking into Flash programming and was turned off by the cost of the development
environment. To be honest, that was a while ago and I don't remember what the costs
were, but I do remember the feeling that I couldn't bother with the hassle of learning
the platform.&lt;br&gt;
&lt;br&gt;
Developing video games like today's casual Flash games is a huge opportunity for an
entry point to learning Silverlight. Just look at all of the Flash &lt;a href="http://www.kongregate.com/"&gt;game&lt;/a&gt; &lt;a href="http://www.newgrounds.com/"&gt;sites&lt;/a&gt; &lt;a href="http://www.flashportal.com/"&gt;out&lt;/a&gt; &lt;a href="http://mochiland.com/articles/45-sites-to-submit-your-flash-games"&gt;there&lt;/a&gt;.
There are actually some Silverlight specific game sites getting started now like &lt;a href="http://silverarcade.com/"&gt;Silver
Arcade&lt;/a&gt; and &lt;a href="http://www.silverlightclub.com/"&gt;Silverlight Club&lt;/a&gt;. In
fact, there is currently a &lt;a href="http://www.serverquestcontest.com/"&gt;Silverlight
game development contest&lt;/a&gt; with a grand prize of $5000, which should definitely
get people interested.&lt;br&gt;
&lt;br&gt;
The first place people interested to start with Silverlight are pointed to is the &lt;a href="http://silverlight.net/getstarted"&gt;Get
Started&lt;/a&gt; page on the official Silverlight web site. This page starts out by linking
to the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&amp;amp;displaylang=en"&gt;Silverlight
Tools for Visual Studio 2008 SP1&lt;/a&gt;, which in turn requires you to already have &lt;a href="http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx"&gt;Visual
Studio 2008&lt;/a&gt; or &lt;a href="http://www.microsoft.com/express/vwd/"&gt;Visual Web Developer
Express&lt;/a&gt; installed with Service Pack 1. Assuming the user downloads the Visual
Web Developer Express, they have a joy filled hour+ of baby sitting installs. Then,
the second step is to download and install the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5FF08106-B9F4-43CD-ABAD-4CC9D9C208D7&amp;amp;displaylang=en"&gt;Expression
Blend 2 trial&lt;/a&gt;, and download and install the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EB9B5C48-BA2B-4C39-A1C3-135C60BBBE66&amp;amp;displaylang=en"&gt;Expression
Blend 2 Service Pack 1&lt;/a&gt; on top of that. Gah! It goes on from there.&lt;br&gt;
&lt;br&gt;
I'm seriously wondering how many people make it that far, or have given up at this
point. I think the final straw for me would have been the fact that Blend is only
a 30 day trial. What do I do after that? Pay &lt;a href="http://www.microsoft.com/expression/products/Purchase.aspx?key=blend"&gt;$499
for Expression Blend&lt;/a&gt; or &lt;a href="http://www.microsoft.com/expression/products/Purchase.aspx?key=professional"&gt;$999
for Expression Studio&lt;/a&gt;? No way! Even as a professional developer today I wouldn't
pay that. And, sure, there's &lt;a href="https://www.dreamspark.com/default.aspx"&gt;DreamSpark&lt;/a&gt;,
but that's an extra hassle, and the get started page doesn't even mention it.&lt;br&gt;
&lt;br&gt;
I love Silverlight, but its been easy for me since I've been developing on the Microsoft
platform for over 10 years and I have access to MSDN downloads. Thank goodness for
the fact that Blend is available through that, or else no one would bother with it.&lt;br&gt;
&lt;br&gt;
Microsoft has done a great job with making free versions of its tools available lately,
but for all the weight they're putting behind Silverlight I don't understand why they
don't, at the very least, have an Express version of Blend. I would even suggest that
there should be a free version of the entire Expression Suite, although a name like
Expression Suite Express is kinda silly. :-)&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,4b85cefc-e72c-4db1-ab8c-23ebfc85f1fb.aspx</comments>
      <category>silverlight</category>
      <category>tools</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=c875d34f-7fc0-428c-bac2-f269a34baeed</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,c875d34f-7fc0-428c-bac2-f269a34baeed.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,c875d34f-7fc0-428c-bac2-f269a34baeed.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=c875d34f-7fc0-428c-bac2-f269a34baeed</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Last Saturday's <a href="http://programwith.net/2008/10/21/ClevelandSilverlightFirestarter.aspx">Silverlight
Firestarter</a> event in Cleveland was a blast.  Being able to express my excitement
for Silverlight to so many people (around 70 people showed) that had little to no
experience with it was unbelievable.<br /><br />
I had problems connecting my Dell Inspiron 1720 laptop to the external display so
the projector wouldn't work.  I had the same problem last Tuesday night at the <a href="http://cinnug.org">CINNUG</a> presentation,
but this time <a href="http://riathoughts.com/">John Stockton</a> was there to save
the day.  I was able to present all of my material on his machine without much
of a hitch.<br /><br /><a href="http://www.jeffblankenburg.com">Jeff Blankenburg</a> did a top notch job
presenting the keynote and improvising in his Tools talk when his Blend install wouldn't
work with Silverlight 2 projects.  <a href="http://www.codinggeekette.com/">Sarah
Dutkiewicz</a> was inspirational in her XAML basics session - she gave a clear introduction
to XAML while being sick and barely able to talk!  Finally, John Stockton's presentation
on Server Communicatiion in Silverlight showed why he's the man.  :-D<br /><br />
The project and slide files that I used for the presentations are available from my
Sky Drive:<br /><br /><iframe marginheight="0" marginwidth="0" style="border: 1px solid rgb(221, 229, 233); margin: 3px; padding: 0pt; width: 240px; height: 26px; background-color: rgb(255, 255, 255);" src="http://cid-63a50a5c41970075.skydrive.live.com/embedrow.aspx/ClevelandSilverlightFirestarter" scrolling="no" frameborder="0" /><img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=c875d34f-7fc0-428c-bac2-f269a34baeed" /></body>
      <title>Cleveland Silverlight Firestarter Recap</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,c875d34f-7fc0-428c-bac2-f269a34baeed.aspx</guid>
      <link>http://programwith.net/2008/11/04/ClevelandSilverlightFirestarterRecap.aspx</link>
      <pubDate>Tue, 04 Nov 2008 03:10:04 GMT</pubDate>
      <description>Last Saturday's &lt;a href="http://programwith.net/2008/10/21/ClevelandSilverlightFirestarter.aspx"&gt;Silverlight
Firestarter&lt;/a&gt; event in Cleveland was a blast.&amp;nbsp; Being able to express my excitement
for Silverlight to so many people (around 70 people showed) that had little to no
experience with it was unbelievable.&lt;br&gt;
&lt;br&gt;
I had problems connecting my Dell Inspiron 1720 laptop to the external display so
the projector wouldn't work.&amp;nbsp; I had the same problem last Tuesday night at the &lt;a href="http://cinnug.org"&gt;CINNUG&lt;/a&gt; presentation,
but this time &lt;a href="http://riathoughts.com/"&gt;John Stockton&lt;/a&gt; was there to save
the day.&amp;nbsp; I was able to present all of my material on his machine without much
of a hitch.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://www.jeffblankenburg.com"&gt;Jeff Blankenburg&lt;/a&gt; did a top notch job
presenting the keynote and improvising in his Tools talk when his Blend install wouldn't
work with Silverlight 2 projects.&amp;nbsp; &lt;a href="http://www.codinggeekette.com/"&gt;Sarah
Dutkiewicz&lt;/a&gt; was inspirational in her XAML basics session - she gave a clear introduction
to XAML while being sick and barely able to talk!&amp;nbsp; Finally, John Stockton's presentation
on Server Communicatiion in Silverlight showed why he's the man.&amp;nbsp; :-D&lt;br&gt;
&lt;br&gt;
The project and slide files that I used for the presentations are available from my
Sky Drive:&lt;br&gt;
&lt;br&gt;
&lt;iframe marginheight="0" marginwidth="0" style="border: 1px solid rgb(221, 229, 233); margin: 3px; padding: 0pt; width: 240px; height: 26px; background-color: rgb(255, 255, 255);" src="http://cid-63a50a5c41970075.skydrive.live.com/embedrow.aspx/ClevelandSilverlightFirestarter" scrolling="no" frameborder="0"&gt;
&lt;/iframe&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=c875d34f-7fc0-428c-bac2-f269a34baeed" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,c875d34f-7fc0-428c-bac2-f269a34baeed.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=7a783681-837c-41b3-9b32-1b0a9afd41b7</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,7a783681-837c-41b3-9b32-1b0a9afd41b7.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,7a783681-837c-41b3-9b32-1b0a9afd41b7.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=7a783681-837c-41b3-9b32-1b0a9afd41b7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I'll be speaking at the <a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;Culture=en-US">Cleveland
Silverlight Firestarter</a> event on November 1st.  This event is going to have
mostly the same structure as the <a href="http://blogs.msdn.com/peterlau/archive/2008/10/06/nyc-silverlight-2-fire-starter-content-and-links.aspx">NYC
Silverlight Firestarter</a>, but with (mostly) local speakers.  For instance,
I'll be filling <a href="http://wildermuth.com/2008/09/13/Just_Back_From_the_Silverlight_2_Firestarter_in_NYC">Shawn
Wildermuth</a>'s shoes by giving the Controls and Databinding afternoon talk.<p style="margin: 0in 0in 0pt;">
 
</p><p style="margin: 0in 0in 0pt;">
Agenda:
</p><p style="margin: 0in 0in 0pt;">
 8:00 AM: Registration
</p><p style="margin: 0in 0in 0pt;">
 9:00 AM: Keynote/Intro to Silverlight 2 (<a href="http://www.jeffblankenburg.com/default.aspx">Jeff
Blankenburg</a>)
</p><p style="margin: 0in 0in 0pt;">
 10:30 AM: XAML Basics (<a href="http://www.codinggeekette.com/">Sarah Dutkiewicz</a>)
</p><p style="margin: 0in 0in 0pt;">
 Noon: Lunch break
</p><p style="margin: 0in 0in 0pt;">
 1:00 PM: The Tools (Jeff Blankenburg)
</p><p style="margin: 0in 0in 0pt;">
 2:30 PM: Controls &amp; Data Binding (Matt Casto)
</p><p style="margin: 0in 0in 0pt;">
 4:00 PM: Server Communication (<a href="http://riathoughts.com/">John Stockton</a>)
</p><p style="margin: 0in 0in 0pt;"><br /></p><p style="margin: 0in 0in 0pt;" /><p style="margin: 0in 0in 0pt;">
To register for this event, please go to <a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;Culture=en-US">http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;Culture=en-US</a></p><p style="margin: 0in 0in 0pt;"><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;Culture=en-US"><br /></a></p><p style="margin: 0in 0in 0pt;" /><p style="margin: 0in 0in 0pt;">
Hope to see you there!
</p><img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=7a783681-837c-41b3-9b32-1b0a9afd41b7" /></body>
      <title>Cleveland Silverlight Firestarter</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,7a783681-837c-41b3-9b32-1b0a9afd41b7.aspx</guid>
      <link>http://programwith.net/2008/10/21/ClevelandSilverlightFirestarter.aspx</link>
      <pubDate>Tue, 21 Oct 2008 18:09:19 GMT</pubDate>
      <description>I'll be speaking at the &lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;amp;Culture=en-US"&gt;Cleveland
Silverlight Firestarter&lt;/a&gt; event on November 1st.&amp;nbsp; This event is going to have
mostly the same structure as the &lt;a href="http://blogs.msdn.com/peterlau/archive/2008/10/06/nyc-silverlight-2-fire-starter-content-and-links.aspx"&gt;NYC
Silverlight Firestarter&lt;/a&gt;, but with (mostly) local speakers.&amp;nbsp; For instance,
I'll be filling &lt;a href="http://wildermuth.com/2008/09/13/Just_Back_From_the_Silverlight_2_Firestarter_in_NYC"&gt;Shawn
Wildermuth&lt;/a&gt;'s shoes by giving the Controls and Databinding afternoon talk.&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
Agenda:
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;8:00 AM: Registration
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;9:00 AM: Keynote/Intro to Silverlight 2 (&lt;a href="http://www.jeffblankenburg.com/default.aspx"&gt;Jeff
Blankenburg&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;10:30 AM: XAML Basics (&lt;a href="http://www.codinggeekette.com/"&gt;Sarah Dutkiewicz&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;Noon: Lunch break
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;1:00 PM: The Tools (Jeff Blankenburg)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;2:30 PM: Controls &amp;amp; Data Binding (Matt Casto)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&amp;nbsp;4:00 PM: Server Communication (&lt;a href="http://riathoughts.com/"&gt;John Stockton&lt;/a&gt;)
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
To register for this event, please go to &lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;amp;Culture=en-US"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;amp;Culture=en-US&lt;/a&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&lt;a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032392883&amp;amp;Culture=en-US"&gt;
&lt;br&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;
Hope to see you there!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=7a783681-837c-41b3-9b32-1b0a9afd41b7" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,7a783681-837c-41b3-9b32-1b0a9afd41b7.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=eb154aab-3dea-41b8-a447-30f8eef99be3</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,eb154aab-3dea-41b8-a447-30f8eef99be3.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,eb154aab-3dea-41b8-a447-30f8eef99be3.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=eb154aab-3dea-41b8-a447-30f8eef99be3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">My submission to the <a href="http://www.teamzonesports.com/SilverlightGameContest">Create
a Sports Game in Silverlight Contest</a> hosted by <a href="http://www.teamzonesports.com/">Team
Zone Sports</a> ended up in second place!<br /><br />
The game is called Ball Blocks because I couldn't come up with a better name at the
time.  You play by drawing a square over the balls where the four corners of
the square are on top of the same type of ball.  The bigger the square (more
balls inside of it) the more points you get and the more time gets added back to the
timer.<br /><br />
The game currently has a bug in it where it can freeze the browser during the game
over animation when time expires.  This seems to happen more often on slower
machines.  It may be because of the spinning textblock ... I'm just not sure.<br /><br />
Because of time spent trying to fix this bug, I didn't get sounds fully implemented
and didn't get a far into the game development as I'd hoped.  I'm hoping to spend
some more time on it some time soon and get some of the features I'd originally envisioned
implemented.<br /><br />
I've created a <a href="http://www.codeplex.com/BallBlocks">Ball Blocks project</a> on
CodePlex and uploaded the code.  The project has been updated to work in Silverlight
2.0 RC0 so it should be ready once Silverlight 2 is released.<br /><p /><img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=eb154aab-3dea-41b8-a447-30f8eef99be3" /></body>
      <title>Ball Blocks</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,eb154aab-3dea-41b8-a447-30f8eef99be3.aspx</guid>
      <link>http://programwith.net/2008/10/07/BallBlocks.aspx</link>
      <pubDate>Tue, 07 Oct 2008 15:35:12 GMT</pubDate>
      <description>My submission to the &lt;a href="http://www.teamzonesports.com/SilverlightGameContest"&gt;Create
a Sports Game in Silverlight Contest&lt;/a&gt; hosted by &lt;a href="http://www.teamzonesports.com/"&gt;Team
Zone Sports&lt;/a&gt; ended up in second place!&lt;br&gt;
&lt;br&gt;
The game is called Ball Blocks because I couldn't come up with a better name at the
time.&amp;nbsp; You play by drawing a square over the balls where the four corners of
the square are on top of the same type of ball.&amp;nbsp; The bigger the square (more
balls inside of it) the more points you get and the more time gets added back to the
timer.&lt;br&gt;
&lt;br&gt;
The game currently has a bug in it where it can freeze the browser during the game
over animation when time expires.&amp;nbsp; This seems to happen more often on slower
machines.&amp;nbsp; It may be because of the spinning textblock ... I'm just not sure.&lt;br&gt;
&lt;br&gt;
Because of time spent trying to fix this bug, I didn't get sounds fully implemented
and didn't get a far into the game development as I'd hoped.&amp;nbsp; I'm hoping to spend
some more time on it some time soon and get some of the features I'd originally envisioned
implemented.&lt;br&gt;
&lt;br&gt;
I've created a &lt;a href="http://www.codeplex.com/BallBlocks"&gt;Ball Blocks project&lt;/a&gt; on
CodePlex and uploaded the code.&amp;nbsp; The project has been updated to work in Silverlight
2.0 RC0 so it should be ready once Silverlight 2 is released.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=eb154aab-3dea-41b8-a447-30f8eef99be3" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,eb154aab-3dea-41b8-a447-30f8eef99be3.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=c41366fc-ccb3-4d12-8431-b355e6c4b39f</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=c41366fc-ccb3-4d12-8431-b355e6c4b39f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a very simple animation that can be used just about anywhere.
</p>
        <p>
          <iframe style="width: 300px; height: 150px" src="http://silverlight.services.live.com/invoke/63993/Crawling%20Border/iframe.html" frameborder="0" scrolling="no">
          </iframe>
        </p>
        <p>
[[ If you're viewing this post through an RSS reader, you won't be able to see the
Silverlight example ]]
</p>
        <p>
Following is my Page.xaml for this example.  There was no code needed.
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">UserControl</span>
              <span style="color: #ff0000">x:Class</span>
              <span style="color: #0000ff">="AnimationSample.Page"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">xmlns</span>
              <span style="color: #0000ff">="http://schemas.microsoft.com/client/2007"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #ff0000">xmlns:x</span>
              <span style="color: #0000ff">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">Width</span>
              <span style="color: #0000ff">="300"</span>
              <span style="color: #ff0000">Height</span>
              <span style="color: #0000ff">="150"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Grid</span>
              <span style="color: #ff0000">x:Name</span>
              <span style="color: #0000ff">="LayoutRoot"</span>
              <span style="color: #ff0000">Background</span>
              <span style="color: #0000ff">="White"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Grid.Triggers</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">EventTrigger</span>
              <span style="color: #ff0000">RoutedEvent</span>
              <span style="color: #0000ff">="Grid.Loaded"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">EventTrigger.Actions</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">BeginStoryboard</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Storyboard</span>
              <span style="color: #ff0000">x:Name</span>
              <span style="color: #0000ff">="CrawlingBorder"</span>
              <span style="color: #ff0000">RepeatBehavior</span>
              <span style="color: #0000ff">="Forever"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">DoubleAnimationUsingKeyFrames</span>
              <span style="color: #ff0000">Storyboard</span>.<span style="color: #ff0000">TargetName</span><span style="color: #0000ff">="rectangle"</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">Storyboard</span>.<span style="color: #ff0000">TargetProperty</span><span style="color: #0000ff">="(Shape.StrokeDashOffset)"</span><span style="color: #ff0000">BeginTime</span><span style="color: #0000ff">="00:00:00"</span><span style="color: #0000ff">&gt;</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">SplineDoubleKeyFrame</span>
              <span style="color: #ff0000">KeyTime</span>
              <span style="color: #0000ff">="00:00:00"</span>
              <span style="color: #ff0000">Value</span>
              <span style="color: #0000ff">="0"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">SplineDoubleKeyFrame</span>
              <span style="color: #ff0000">KeyTime</span>
              <span style="color: #0000ff">="00:00:00.5000000"</span>
              <span style="color: #ff0000">Value</span>
              <span style="color: #0000ff">="5"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">DoubleAnimationUsingKeyFrames</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Storyboard</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">BeginStoryboard</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">EventTrigger.Actions</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">EventTrigger</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Grid.Triggers</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Rectangle</span>
              <span style="color: #ff0000">Stroke</span>
              <span style="color: #0000ff">="Green"</span>
              <span style="color: #ff0000">StrokeThickness</span>
              <span style="color: #0000ff">="6"</span>
              <span style="color: #ff0000">StrokeDashArray</span>
              <span style="color: #0000ff">="3,2"</span>
              <span style="color: #ff0000">StrokeDashCap</span>
              <span style="color: #0000ff">="Round"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">Margin</span>
              <span style="color: #0000ff">="20"</span>
              <span style="color: #ff0000">StrokeDashOffset</span>
              <span style="color: #0000ff">="0"</span>
              <span style="color: #ff0000">StrokeLineJoin</span>
              <span style="color: #0000ff">="Round"</span>
              <span style="color: #ff0000">x:Name</span>
              <span style="color: #0000ff">="rectangle"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Rectangle</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">TextBlock</span>
              <span style="color: #ff0000">FontFamily</span>
              <span style="color: #0000ff">="Lucida
Sans Unicode"</span>
              <span style="color: #ff0000">FontSize</span>
              <span style="color: #0000ff">="24"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #ff0000">Text</span>
              <span style="color: #0000ff">="Crawling
Border"</span>
              <span style="color: #ff0000">FontWeight</span>
              <span style="color: #0000ff">="Bold"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">HorizontalAlignment</span>
              <span style="color: #0000ff">="Center"</span>
              <span style="color: #ff0000">VerticalAlignment</span>
              <span style="color: #0000ff">="Center"</span>
              <span style="color: #ff0000">Foreground</span>
              <span style="color: #0000ff">="#FFDE680A"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Grid</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">UserControl</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
          </div>
        </div>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=c41366fc-ccb3-4d12-8431-b355e6c4b39f" />
      </body>
      <title>Crawling Border Animation</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</guid>
      <link>http://programwith.net/2008/04/22/CrawlingBorderAnimation.aspx</link>
      <pubDate>Tue, 22 Apr 2008 02:55:36 GMT</pubDate>
      <description>&lt;p&gt;
This is a very simple animation that can be used just about anywhere.
&lt;/p&gt;
&lt;p&gt;
&lt;iframe style="width: 300px; height: 150px" src="http://silverlight.services.live.com/invoke/63993/Crawling%20Border/iframe.html" frameborder="0" scrolling="no"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;
[[ If you're viewing this post through an RSS reader, you won't be able to see the
Silverlight example ]]
&lt;/p&gt;
&lt;p&gt;
Following is my Page.xaml for this example.&amp;nbsp; There was no code needed.
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="AnimationSample.Page"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="300"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Height&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="150"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="LayoutRoot"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="White"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid.Triggers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger&lt;/span&gt; &lt;span style="color: #ff0000"&gt;RoutedEvent&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Grid.Loaded"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger.Actions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Storyboard&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="CrawlingBorder"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;RepeatBehavior&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Forever"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;              &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Storyboard&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;TargetName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="rectangle"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                &lt;span style="color: #ff0000"&gt;Storyboard&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;TargetProperty&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="(Shape.StrokeDashOffset)"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;BeginTime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="00:00:00"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SplineDoubleKeyFrame&lt;/span&gt; &lt;span style="color: #ff0000"&gt;KeyTime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="00:00:00"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="0"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SplineDoubleKeyFrame&lt;/span&gt; &lt;span style="color: #ff0000"&gt;KeyTime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="00:00:00.5000000"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="5"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;              &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger.Actions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid.Triggers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Rectangle&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Stroke&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Green"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeThickness&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="6"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeDashArray&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="3,2"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeDashCap&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Round"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;               &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="20"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeDashOffset&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="0"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeLineJoin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Round"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="rectangle"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Rectangle&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FontFamily&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Lucida
Sans Unicode"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FontSize&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="24"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;               &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Crawling
Border"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FontWeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Bold"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;               &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Center"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Center"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Foreground&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="#FFDE680A"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=c41366fc-ccb3-4d12-8431-b355e6c4b39f" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=92aeb18f-3f9e-452a-9331-d0ee6e99e33c</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=92aeb18f-3f9e-452a-9331-d0ee6e99e33c</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I gave a talk at the <a href="http://cinnug.org/cododn/">Central Ohio Day of .NET</a> last
Saturday about Silverlight 2.  The presentation was written in Silverlight 2
Beta 1 and included examples of functionality built into Silverlight versions 1 and
2, and the beginning steps in creating the presentation itself.
</p>
        <p>
I have much more planned to be added to the presentation, so I created a CodePlex
project called <a href="http://www.codeplex.com/PresentLight">PresentLight</a>. 
I'm hoping that other people will like the idea of giving a presentation in the technology
that they're speaking about, and maybe they'll use the framework or even add their
own content!
</p>
        <p>
I uploaded a slightly older version than the one I gave at CODoDN to silverlight.live.com,
check it out by clicking on the following preview image.  The XAP is 14 MB so
expect a decent wait for everything to load ... I need to reduce the size.  I'll
update this post with a better example as soon as I have it available.
</p>
        <p>
          <a href="http://silverlight.services.live.com/invoke/63993/PresentLight/iframe.html">
            <img height="325" src="http://programwith.net/images/PresentLightSS.png" width="443" />
          </a>
        </p>
        <p>
Much thanks goes out to <a href="http://www.jeffblankenburg.com/index.html">Jeff Blankenburg</a> for
building the original slide deck that I based this presentation on.  Also, I
got the idea from <a href="http://david.sleeckx.be/?p=12">David Sleeckx</a>'s WPF
presentation, which is an excellent way to get an overview of WPF.
</p>
        <h3>Using the Presentation
</h3>
        <p>
You can navigate the slides through the menu on the left, or move forward one slide
by clicking on the header area.  A few of the slides don't have much at first,
but clicking in the slide area will show text which was talking points for that part
of the presentation.  The interactive slides in the middle should be pretty self
explanatory - you can modify the XAML in most of the examples to see changes in real
time.
</p>
        <p>
The screen shots at the end can be clicked on to view the full size.  I wanted
to keep the entire presentation in Silverlight, so I was trying to use screen shots
instead of jumping into Visual Studio.  These slides were taking over an hour
each to prepare, because I was trying to give each one a different type of animation. 
I think they ended up being a little disjointed though - its much more natural to
see someone working with the environment than seeing screen shots of some code, then
the solution explorer, then XAML.  I'm definitely going to have to give more
thought to that area.
</p>
        <h3>Plans for the Future
</h3>
        <p>
I plan to have the slides stored in data rather than hard coded in the page code behind. 
I'm going to integrate more examples, such as Isolated Storage, Communications with
web services and through sockets, and dynamic languages integrated directly into the
slides, like I did with the XAML examples.
</p>
        <p>
Also, I'm going to expand more on some of the user controls that I created as part
of the application.  I already went into the scrolling textbox control in my
last post, so there will be more of that on the way.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=92aeb18f-3f9e-452a-9331-d0ee6e99e33c" />
      </body>
      <title>PresentLight - A Silverlight Presentation Written in Silverlight</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</guid>
      <link>http://programwith.net/2008/04/22/PresentLightASilverlightPresentationWrittenInSilverlight.aspx</link>
      <pubDate>Tue, 22 Apr 2008 02:15:26 GMT</pubDate>
      <description>&lt;p&gt;
I gave a talk at the &lt;a href="http://cinnug.org/cododn/"&gt;Central Ohio Day of .NET&lt;/a&gt; last
Saturday about Silverlight 2.&amp;nbsp; The presentation was written in Silverlight 2
Beta 1 and included examples of functionality built into Silverlight versions 1 and
2, and the beginning steps in creating the presentation itself.
&lt;/p&gt;
&lt;p&gt;
I have much more planned to be added to the presentation, so I created a CodePlex
project called &lt;a href="http://www.codeplex.com/PresentLight"&gt;PresentLight&lt;/a&gt;.&amp;nbsp;
I'm hoping that other people will like the idea of giving a presentation in the technology
that they're speaking about, and maybe they'll use the framework or even add their
own content!
&lt;/p&gt;
&lt;p&gt;
I uploaded a slightly older version than the one I gave at CODoDN to silverlight.live.com,
check it out by clicking on the following preview image.&amp;nbsp; The XAP is 14 MB so
expect a decent wait for everything to load ... I need to reduce the size.&amp;nbsp; I'll
update this post with a better example as soon as I have it available.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://silverlight.services.live.com/invoke/63993/PresentLight/iframe.html"&gt;&lt;img height="325" src="http://programwith.net/images/PresentLightSS.png" width="443"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Much thanks goes out to &lt;a href="http://www.jeffblankenburg.com/index.html"&gt;Jeff Blankenburg&lt;/a&gt; for
building the original slide deck that I based this presentation on.&amp;nbsp; Also, I
got the idea from &lt;a href="http://david.sleeckx.be/?p=12"&gt;David Sleeckx&lt;/a&gt;'s WPF
presentation, which is an excellent way to get an overview of WPF.
&lt;/p&gt;
&lt;h3&gt;Using the Presentation
&lt;/h3&gt;
&lt;p&gt;
You can navigate the slides through the menu on the left, or move forward one slide
by clicking on the header area.&amp;nbsp; A few of the slides don't have much at first,
but clicking in the slide area will show text which was talking points for that part
of the presentation.&amp;nbsp; The interactive slides in the middle should be pretty self
explanatory - you can modify the XAML in most of the examples to see changes in real
time.
&lt;/p&gt;
&lt;p&gt;
The screen shots at the end can be clicked on to view the full size.&amp;nbsp; I wanted
to keep the entire presentation in Silverlight, so I was trying to use screen shots
instead of jumping into Visual Studio.&amp;nbsp; These slides were taking over an hour
each to prepare, because I was trying to give each one a different type of animation.&amp;nbsp;
I think they ended up being a little disjointed though - its much more natural to
see someone working with the environment than seeing screen shots of some code, then
the solution explorer, then XAML.&amp;nbsp; I'm definitely going to have to give more
thought to that area.
&lt;/p&gt;
&lt;h3&gt;Plans for the Future
&lt;/h3&gt;
&lt;p&gt;
I plan to have the slides stored in data rather than hard coded in the page code behind.&amp;nbsp;
I'm going to integrate more examples, such as Isolated Storage, Communications with
web services and through sockets, and dynamic languages integrated directly into the
slides, like I did with the XAML examples.
&lt;/p&gt;
&lt;p&gt;
Also, I'm going to expand more on some of the user controls that I created as part
of the application.&amp;nbsp; I already went into the scrolling textbox control in my
last post, so there will be more of that on the way.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=92aeb18f-3f9e-452a-9331-d0ee6e99e33c" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=470085fe-abab-4091-a93f-d5d77fb8ecfc</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=470085fe-abab-4091-a93f-d5d77fb8ecfc</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox(VS.95).aspx">TextBox</a> control
included with Silverlight 2 Beta 1 is a welcome addition.  There was no such
control in previous versions of Silverlight, including the alpha.
</p>
        <p>
Unfortunately, the TextBox control is very limited at this point.  It does not
support scrollbars when it's content is larger than it's size.  You can "scroll"
the next by moving the cursor, but that's just enough to make it functional. 
Selecting text past what's visible doesn't automatically scroll to the cursor. 
Also, there's no text wrapping, although setting the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.acceptsreturn(VS.95).aspx">AcceptsReturn</a> property
to True will allow line breaks in the text.
</p>
        <p>
I wanted to have a text box with a little more functionality for my projects, so I
decided to see what I could do.  What follows is the simple ScrollingTextBox
control that I created.  I didn't spend a ton of time on this because I fully
expect this "missing" functionality to be included by Beta 2, or at least by the time
Silverlight 2 is released.
</p>
        <iframe src="http://silverlight.services.live.com/invoke/63993/Scrolling%20TextBox%20Control/iframe.html" scrolling="no" frameborder="0" style="width:400px; height:300px">
        </iframe>
        <p>
 
</p>
        <p>
To build this, I first created a Silverlight application project and added a Silverlight
control called ScrollingTextBox.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">UserControl</span>
          <span class="attr">x:Class</span>
          <span class="kwrd">="PresentLight.ScrollingTextBox"</span>
          <span class="attr">xmlns</span>
          <span class="kwrd">="http://schemas.microsoft.com/client/2007"</span>
          <span class="attr">xmlns:x</span>
          <span class="kwrd">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Grid</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="LayoutRoot"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ScrollViewer</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="sv"</span>
          <span class="attr">HorizontalScrollBarVisibility</span>
          <span class="kwrd">="Auto"</span>
          <span class="attr">VerticalScrollBarVisibility</span>
          <span class="kwrd">="Auto"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="hiddenTextBlock"</span>
          <span class="attr">Opacity</span>
          <span class="kwrd">="0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBox</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="tb"</span>
          <span class="attr">AcceptsReturn</span>
          <span class="kwrd">="True"</span>
          <span class="attr">TextChanged</span>
          <span class="kwrd">="tb_TextChanged"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ScrollViewer</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Grid</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">UserControl</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
The internal <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textblock(VS.95).aspx">TextBlock</a> control
is only there to serve as a way to get the actual size of the text.  TextBlock
controls will automatically resize to fit their contents, so if I keep it's text the
same as the internal textbox control, it will resize accordingly.  The default
value for <a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.width(VS.95).aspx">Width</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.height(VS.95).aspx">Height</a> dependency
properties in Silverlight is Auto, which causes this resize behavior.
</p>
        <p>
Since the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.scrollviewer(VS.95).aspx">ScrollViewer</a> control
automatically set's it's scrollable region to fit it's contents, it will be resized
to fit the internal textblock.  The internal textbox control will automatically
resize to fit it's container, since I haven't set any width or height on it.
</p>
        <p>
Then I added a dependency property for setting the control's Text, which takes care
of setting the textbox's text value.  Finally, I handled the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.textchanged(VS.95).aspx">TextChanged</a> event
on the internal TextBox control to resize based on my internal TextBlock's size.
</p>
        <pre class="csharpcode">
          <span class="kwrd">using</span> System.Windows; <span class="kwrd">using</span> System.Windows.Controls; <span class="kwrd">namespace</span> PresentLight
{ <span class="kwrd">public</span><span class="kwrd">partial</span><span class="kwrd">class</span> ScrollingTextBox
: UserControl { <span class="kwrd">public</span><span class="kwrd">string</span> Text
{ get { <span class="kwrd">return</span> (<span class="kwrd">string</span>)GetValue(TextProperty);
} set { SetValue(TextProperty, <span class="kwrd">value</span>); tb.Text = <span class="kwrd">value</span>;
} } <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">readonly</span> DependencyProperty
TextProperty = DependencyProperty.Register(<span class="str">"Text"</span>, <span class="kwrd">typeof</span>(<span class="kwrd">string</span>), <span class="kwrd">typeof</span>(ScrollingTextBox), <span class="kwrd">null</span>); <span class="kwrd">public</span> ScrollingTextBox()
{ InitializeComponent(); } <span class="kwrd">private</span><span class="kwrd">void</span> tb_TextChanged(<span class="kwrd">object</span> sender,
TextChangedEventArgs e) { <span class="kwrd">if</span> (hiddenTextBlock != <span class="kwrd">null</span>)
{ hiddenTextBlock.Text = tb.Text; tb.Width = hiddenTextBlock.ActualWidth; tb.Height
= hiddenTextBlock.ActualHeight; } } } }</pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
The result is a marginally better control.  There are a lot of possible improvements
for me to make, such as possibly handing the selection changed event on the textbox
to scroll the ScrollViewer to the cursor's position.  That will have to wait
for a future post.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=470085fe-abab-4091-a93f-d5d77fb8ecfc" />
      </body>
      <title>Scrolling TextBox in Silverlight 2 Beta 1</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</guid>
      <link>http://programwith.net/2008/04/13/ScrollingTextBoxInSilverlight2Beta1.aspx</link>
      <pubDate>Sun, 13 Apr 2008 14:41:18 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox(VS.95).aspx"&gt;TextBox&lt;/a&gt; control
included with Silverlight 2 Beta 1 is a welcome addition.&amp;nbsp; There was no such
control in previous versions of Silverlight, including the alpha.
&lt;/p&gt;
&lt;p&gt;
Unfortunately, the TextBox control is very limited at this point.&amp;nbsp; It does not
support scrollbars when it's content is larger than it's size.&amp;nbsp; You can "scroll"
the next by moving the cursor, but that's just enough to make it functional.&amp;nbsp;
Selecting text past what's visible doesn't automatically scroll to the cursor.&amp;nbsp;
Also, there's no text wrapping, although setting the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.acceptsreturn(VS.95).aspx"&gt;AcceptsReturn&lt;/a&gt; property
to True will allow line breaks in the text.
&lt;/p&gt;
&lt;p&gt;
I wanted to have a text box with a little more functionality for my projects, so I
decided to see what I could do.&amp;nbsp; What follows is the simple ScrollingTextBox
control that I created.&amp;nbsp; I didn't spend a ton of time on this because I fully
expect this "missing" functionality to be included by Beta 2, or at least by the time
Silverlight 2 is released.
&lt;/p&gt;
&lt;iframe src="http://silverlight.services.live.com/invoke/63993/Scrolling%20TextBox%20Control/iframe.html" scrolling="no" frameborder="0" style="width:400px; height:300px"&gt;
&lt;/iframe&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
To build this, I first created a Silverlight application project and added a Silverlight
control called ScrollingTextBox.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="PresentLight.ScrollingTextBox"&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="sv"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="attr"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="hiddenTextBlock"&lt;/span&gt; &lt;span class="attr"&gt;Opacity&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBox&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="tb"&lt;/span&gt; &lt;span class="attr"&gt;AcceptsReturn&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt; &lt;span class="attr"&gt;TextChanged&lt;/span&gt;&lt;span class="kwrd"&gt;="tb_TextChanged"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;p&gt;
The internal &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textblock(VS.95).aspx"&gt;TextBlock&lt;/a&gt; control
is only there to serve as a way to get the actual size of the text.&amp;nbsp; TextBlock
controls will automatically resize to fit their contents, so if I keep it's text the
same as the internal textbox control, it will resize accordingly.&amp;nbsp; The default
value for &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.width(VS.95).aspx"&gt;Width&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.height(VS.95).aspx"&gt;Height&lt;/a&gt; dependency
properties in Silverlight is Auto, which causes this resize behavior.
&lt;/p&gt;
&lt;p&gt;
Since the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.scrollviewer(VS.95).aspx"&gt;ScrollViewer&lt;/a&gt; control
automatically set's it's scrollable region to fit it's contents, it will be resized
to fit the internal textblock.&amp;nbsp; The internal textbox control will automatically
resize to fit it's container, since I haven't set any width or height on it.
&lt;/p&gt;
&lt;p&gt;
Then I added a dependency property for setting the control's Text, which takes care
of setting the textbox's text value.&amp;nbsp; Finally, I handled the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.textchanged(VS.95).aspx"&gt;TextChanged&lt;/a&gt; event
on the internal TextBox control to resize based on my internal TextBlock's size.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows; &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls; &lt;span class="kwrd"&gt;namespace&lt;/span&gt; PresentLight
{ &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ScrollingTextBox
: UserControl { &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Text
{ get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;)GetValue(TextProperty);
} set { SetValue(TextProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); tb.Text = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
} } &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty
TextProperty = DependencyProperty.Register(&lt;span class="str"&gt;"Text"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ScrollingTextBox), &lt;span class="kwrd"&gt;null&lt;/span&gt;); &lt;span class="kwrd"&gt;public&lt;/span&gt; ScrollingTextBox()
{ InitializeComponent(); } &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; tb_TextChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
TextChangedEventArgs e) { &lt;span class="kwrd"&gt;if&lt;/span&gt; (hiddenTextBlock != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
{ hiddenTextBlock.Text = tb.Text; tb.Width = hiddenTextBlock.ActualWidth; tb.Height
= hiddenTextBlock.ActualHeight; } } } }&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;p&gt;
The result is a marginally better control.&amp;nbsp; There are a lot of possible improvements
for me to make, such as possibly handing the selection changed event on the textbox
to scroll the ScrollViewer to the cursor's position.&amp;nbsp; That will have to wait
for a future post.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=470085fe-abab-4091-a93f-d5d77fb8ecfc" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=685207f7-56f7-4aa3-a10a-9d8eac1e7042</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=685207f7-56f7-4aa3-a10a-9d8eac1e7042</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I haven't been posting much lately because I've been very busy preparing for my <a href="http://cinnug.org/cododn/sessions.aspx#Creating%20Silverlight%202.0%20Presentation%20in%20Silverlight%202.0">session</a> at
the <a href="http://cinnug.org/cododn/">Central Ohio Day of .NET</a>.  I'm creating
a presentation about Silverlight 2.0 Beta 1, but with a <a href="http://www.youtube.com/watch?v=cWWtb2uDDfE">twist</a> -
the presentation is actually a Silverlight application!
</p>
        <h4>Templates
</h4>
        <p>
For the last day or so I've been working on getting my application's main control
to use templates to define the interface.  This gives me the option to create
multiple "skins" for the application.
</p>
        <p>
To accomplish this, I've been referencing two very excellent tutorials by <a href="http://silverlight.net/learn/tutorials/stylestemplates.aspx">Jesse
Liberty</a> and <a href="http://blogs.msdn.com/sburke/archive/2008/03/22/tutorial-writing-a-templated-silverlight-2-control.aspx">Shawn
Burke</a>.  But, as usual for me, I ran into a problem that sucked up a ton of
time.
</p>
        <h4>The Problem
</h4>
        <p>
I was trying to set up my template to include buttons for navigation between slides. 
I started by building a simple XAML interface for the buttons, like so.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">StackPanel</span>
          <span class="attr">Orientation</span>
          <span class="kwrd">="Horizontal"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="First"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Prev"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Next"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Last"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">StackPanel</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
 
</p>
        <p>
And that looks good enough for this example.
</p>
        <p>
          <img src="http://programwith.net/images/TemplateExample1.png" />  
</p>
        <p>
Then I took that same XAML and put it into a template stored in the application resources
(in App.xaml).
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Style</span>
          <span class="attr">x:Key</span>
          <span class="kwrd">="TestTemplate"</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter</span>
          <span class="attr">Property</span>
          <span class="kwrd">="Template"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ControlTemplate</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">StackPanel</span>
          <span class="attr">Orientation</span>
          <span class="kwrd">="Horizontal"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="First"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Prev"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Next"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Last"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">StackPanel</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ControlTemplate</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Style</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
And modified my Page.xaml to have my Presentation UserControl class (modeled after
Shawn Burke's tutorial) with the template applied as a style.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">local:Presentation</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="PresentationControl"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestTemplate}"</span>
          <span class="kwrd">/&gt;</span>
          <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        </pre>
        <p>
But running this treated me to a browser window that's stuck loading.  My break
point in OnApplyTemplate in my Presentation class never got hit.  Pausing Visual
Studio didn't tell me anything, so I knew it wasn't stuck in a loop.  This had
me stuck for several hours.
</p>
        <h4>The Solution
</h4>
        <p>
What I eventually found was that certain things that are perfectly acceptable XAML
in a user control won't work in a template.  Furthermore, if Silverlight encounters
these elements in the template it just hangs.
</p>
        <p>
The problem XAML was the buttons.  Instead of including your actual buttons in
your template, you should instead create a separate template for the buttons, and
reference that as your button style.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">Style</span>
          <span class="attr">x:Key</span>
          <span class="kwrd">="TestButton"</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="Button"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter</span>
          <span class="attr">Property</span>
          <span class="kwrd">="Template"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ControlTemplate</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="Button"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button.Content</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ContentPresenter</span>
          <span class="attr">Content</span>
          <span class="kwrd">="{TemplateBinding
Content}"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button.Content</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ControlTemplate</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Style</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <p>
Then modify the previous template to use the new button template.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Style</span>
          <span class="attr">x:Key</span>
          <span class="kwrd">="TestTemplate"</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter</span>
          <span class="attr">Property</span>
          <span class="kwrd">="Template"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ControlTemplate</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">StackPanel</span>
          <span class="attr">Orientation</span>
          <span class="kwrd">="Horizontal"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="FirstButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="First"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="PreviousButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="Prev"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="NextButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="Next"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="LastButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="Last"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">StackPanel</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ControlTemplate</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Style</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
Finally, this works.  It looks the same, but now I can take the template and
make it look much nicer if I want.
</p>
        <p>
Hopefully this tip will help others working on templating in Silverlight avoid the
pitfalls I ran into.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=685207f7-56f7-4aa3-a10a-9d8eac1e7042" />
      </body>
      <title>Silverlight Templates Tip</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</guid>
      <link>http://programwith.net/2008/04/12/SilverlightTemplatesTip.aspx</link>
      <pubDate>Sat, 12 Apr 2008 22:45:08 GMT</pubDate>
      <description>&lt;p&gt;
I haven't been posting much lately because I've been very busy preparing for my &lt;a href="http://cinnug.org/cododn/sessions.aspx#Creating%20Silverlight%202.0%20Presentation%20in%20Silverlight%202.0"&gt;session&lt;/a&gt; at
the &lt;a href="http://cinnug.org/cododn/"&gt;Central Ohio Day of .NET&lt;/a&gt;.&amp;nbsp; I'm creating
a presentation about Silverlight 2.0 Beta 1, but with a &lt;a href="http://www.youtube.com/watch?v=cWWtb2uDDfE"&gt;twist&lt;/a&gt; -
the presentation is actually a Silverlight application!
&lt;/p&gt;
&lt;h4&gt;Templates
&lt;/h4&gt;
&lt;p&gt;
For the last day or so I've been working on getting my application's main control
to use templates to define the interface.&amp;nbsp; This gives me the option to create
multiple "skins" for the application.
&lt;/p&gt;
&lt;p&gt;
To accomplish this, I've been referencing two very excellent tutorials by &lt;a href="http://silverlight.net/learn/tutorials/stylestemplates.aspx"&gt;Jesse
Liberty&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/sburke/archive/2008/03/22/tutorial-writing-a-templated-silverlight-2-control.aspx"&gt;Shawn
Burke&lt;/a&gt;.&amp;nbsp; But, as usual for me, I ran into a problem that sucked up a ton of
time.
&lt;/p&gt;
&lt;h4&gt;The Problem
&lt;/h4&gt;
&lt;p&gt;
I was trying to set up my template to include buttons for navigation between slides.&amp;nbsp;
I started by building a simple XAML interface for the buttons, like so.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="First"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Prev"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Next"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Last"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
And that looks good enough for this example.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://programwith.net/images/TemplateExample1.png"&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Then I took that same XAML and put it into a template stored in the application resources
(in App.xaml).
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TestTemplate"&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Template"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="First"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Prev"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Next"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Last"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;p&gt;
And modified my Page.xaml to have my Presentation UserControl class (modeled after
Shawn Burke's tutorial) with the template applied as a style.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;local:Presentation&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="PresentationControl"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestTemplate}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/pre&gt;
&lt;p&gt;
But running this treated me to a browser window that's stuck loading.&amp;nbsp; My break
point in OnApplyTemplate in my Presentation class never got hit.&amp;nbsp; Pausing Visual
Studio didn't tell me anything, so I knew it wasn't stuck in a loop.&amp;nbsp; This had
me stuck for several hours.
&lt;/p&gt;
&lt;h4&gt;The Solution
&lt;/h4&gt;
&lt;p&gt;
What I eventually found was that certain things that are perfectly acceptable XAML
in a user control won't work in a template.&amp;nbsp; Furthermore, if Silverlight encounters
these elements in the template it just hangs.
&lt;/p&gt;
&lt;p&gt;
The problem XAML was the buttons.&amp;nbsp; Instead of including your actual buttons in
your template, you should instead create a separate template for the buttons, and
reference that as your button style.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TestButton"&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="Button"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Template"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="Button"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ContentPresenter&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{TemplateBinding
Content}"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Then modify the previous template to use the new button template.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TestTemplate"&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Template"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="FirstButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="First"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="PreviousButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Prev"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="NextButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Next"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LastButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Last"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;p&gt;
Finally, this works.&amp;nbsp; It looks the same, but now I can take the template and
make it look much nicer if I want.
&lt;/p&gt;
&lt;p&gt;
Hopefully this tip will help others working on templating in Silverlight avoid the
pitfalls I ran into.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=685207f7-56f7-4aa3-a10a-9d8eac1e7042" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</comments>
      <category>silverlight</category>
    </item>
  </channel>
</rss>
