﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Andy's Blog</title>
    <description>Adventures in .NET </description>
    <link>http://www.spritehand.com/Home/tabid/67/BlogId/2/Default.aspx</link>
    <language>en-US</language>
    <managingEditor>andy@beaulieu.com</managingEditor>
    <webMaster>andy@beaulieu.com</webMaster>
    <pubDate>Sat, 19 Jul 2008 03:44:05 GMT</pubDate>
    <lastBuildDate>Sat, 19 Jul 2008 03:44:05 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>Blog RSS Generator Version 3.1.20.17153</generator>
    <item>
      <title>More Polygon Physics with Silverlight</title>
      <description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;I’ve souped up my previous &lt;/FONT&gt;&lt;A href="http://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.com/silverlight/2.0/polygondemo/testpage.html"&gt;&lt;FONT face=Arial size=2&gt;demo on Polygon Physics&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt; using Silverlight and &lt;/FONT&gt;&lt;A href="http://www.codeplex.com/FarseerPhysics"&gt;&lt;FONT face=Arial size=2&gt;Farseer&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt; to include two improvements. First, I’ve added a utility function to create an approximate Farseer Polygon Geometry from any Silverlight Path object. Also, I’ve added the ability to manipulate the polygons using the mouse (turns out this is pretty easy thanks to Farseer). In this blog post, I’ll explain how I made these enhancements.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;[&lt;/STRONG&gt;&lt;/FONT&gt;&lt;A href="http://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.com/silverlight/2.0/polygondemo/testpage.html"&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;TRY THE DEMO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;]&lt;SPAN style="mso-spacerun: yes"&gt;       &lt;/SPAN&gt;[&lt;/STRONG&gt;&lt;/FONT&gt;&lt;A href="http://www.spritehand.com/silverlight/2.0/polygondemo/PolygonDemo.v2.zip"&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;DOWNLOAD THE SOURCE&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;]&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;A href="http://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.com/silverlight/2.0/polygondemo/testpage.html"&gt;&lt;FONT size=2&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/spriteJitter2.gif" border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=2&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=2&gt;To begin, if you are new to &lt;/FONT&gt;&lt;A href="http://www.codeplex.com/FarseerPhysics"&gt;&lt;FONT size=2&gt;Farseer Physics&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt; and Silverlight, you should start with my &lt;/FONT&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/91/Default.aspx"&gt;&lt;FONT size=2&gt;first post on Polygon Physics&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;U&gt;&lt;FONT face=Arial&gt;Creating a Farseer Polygon Geometry based on a Path&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=2&gt;In the &lt;/FONT&gt;&lt;A href="http://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.comhttp://www.spritehand.com/silverlight/2.0/polygondemo/testpage.html"&gt;&lt;FONT size=2&gt;demo app&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;, if you type out any letters (A-Z) on the keyboard, then you will see a demo of Path objects being translated to Polygon Physics objects. In the Silverlight Project, these Path objects are pulled from the ucAlphabet.xaml user control.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=2&gt;There is an unfortunate problem in Silverlight 2 Beta 2 (not sure if this will be resolved by release time) with getting the geometry information on a Path object. So let’s say you design a Path using Expression Blend:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Path&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="pathTest"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="65"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="Left"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Margin&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="78.5,57.5,0,0"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="Top"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Width&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="83"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Data&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="M98,89 L79,122 L117,119 L150,108 L161,58 L102,58 z"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Fill&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="#FFFFFFFF"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Stretch&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="Fill"&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; Stroke&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="#FF000000"/&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;BR&gt;&lt;FONT face=Calibri&gt;&lt;FONT face=Arial size=2&gt;…and then you later want to manipulate that Path’s geometry using code –&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;PathFigure&lt;/SPAN&gt; figure &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; (pathTest.Data &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;PathGeometry&lt;/SPAN&gt;).Figures)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// this won't work in Silverlight 2 Beta 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// the Figures collection is always empty!&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;BR&gt;&lt;FONT face=Arial size=2&gt;…you really can’t do the manipulation in code because the Path.Data property does not get filled.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;So, we need another method of getting the Path’s shape so that we can hand it off to Farseer. One way we could do this is by translating the Path “mini-language” which defines the shape. So we could translate this part of the XAML for the Path:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Data&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;="M98,89 L79,122 L117,119 L150,108 L161,58 L102,58 z"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;I actually think this would be an ideal approach, but it’s not the one I took. Instead, I used the HitTest method to “scan” the Path for its approximate shape. I did this with a series of loops which scans each side of the Path and tests each x,y point for a hit. If the HitTest succeeds on a point, then I add that point into a list which defines the overall shape. I then give this list of points depicting the shape over to Farseer to define the Polygon Geometry.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;Below is an excerpt from the method Utils.GetPointsForPath which scans the left side of the Path to get it’s outline:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;// left side&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;for&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; (&lt;SPAN style="COLOR: blue"&gt;double&lt;/SPAN&gt; y = top; y &lt; top + height; y++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;double&lt;/SPAN&gt; x = left; x &lt; left + width; x++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN lang=FR-CA style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-ansi-language: FR-CA"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN lang=FR-CA style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-ansi-language: FR-CA"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Point&lt;/SPAN&gt; ptTest = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Point&lt;/SPAN&gt;(x,y);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN lang=FR-CA style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-ansi-language: FR-CA"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;List&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElement&lt;/SPAN&gt;&gt; hits = path.HitTest(ptTest) &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&lt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElement&lt;/SPAN&gt;&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (hits.Contains(path))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Point&lt;/SPAN&gt; ptHit = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Point&lt;/SPAN&gt;(x / scaleX, y / scaleY);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;outline.Add(ptHit);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;I simply repeat this for the bottom, right, and top sides and then I have a list of points representing the approximate outline of the Path.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;U&gt;&lt;FONT face=Arial&gt;Manipulating Polygons with the Mouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;This is almost a freebie and can be nearly copy/pasted from the original Silverlight/Farseer demos ported by &lt;/FONT&gt;&lt;A href="http://www.bluerosegames.com/brg/silverlight_game_development.aspx"&gt;&lt;FONT face=Arial size=2&gt;Bill Reiss&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;. To allow the user to grab onto a Farseer object and move it around the screen, we need to do three basic steps:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;1. In the MouseDown event for the polygon, we keep track of the polygon (“sprite”) that was clicked and create a Fixed Linear Spring at the clicked point.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; sprite_MouseLeftButtonDown(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;MouseButtonEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Vector2&lt;/SPAN&gt; point = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Vector2&lt;/SPAN&gt;((&lt;SPAN style="COLOR: blue"&gt;float&lt;/SPAN&gt;)(e.GetPosition(_parentCanvas).X), (&lt;SPAN style="COLOR: blue"&gt;float&lt;/SPAN&gt;)(e.GetPosition(_parentCanvas).Y));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;_pickedSprite = (sender &lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;SpriteBase&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;_pickedSprite.CaptureMouse();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (_pickedSprite != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;_mousePickSpring = &lt;SPAN style="COLOR: #2b91af"&gt;ControllerFactory&lt;/SPAN&gt;.Instance.CreateFixedLinearSpring(_physicsSimulator, _pickedSprite.BodyObject, _pickedSprite.BodyObject.GetLocalPosition(point), point, 10, 5);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;e.Handled = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;2. In the MouseMove event for the polygon, we adjust the attached point for the Fixed Linear Spring to the mouse move point.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; sprite_MouseMove(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;MouseEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (_mousePickSpring != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Vector2&lt;/SPAN&gt; point = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Vector2&lt;/SPAN&gt;((&lt;SPAN style="COLOR: blue"&gt;float&lt;/SPAN&gt;)(e.GetPosition(_parentCanvas).X), (&lt;SPAN style="COLOR: blue"&gt;float&lt;/SPAN&gt;)(e.GetPosition(_parentCanvas).Y));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;_mousePickSpring.WorldAttachPoint = point;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;e.Handled = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;3. In the MouseUp event for the polygon, we dispose of the Fixed Linear Spring.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; sprite_MouseLeftButtonUp(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;MouseButtonEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (_mousePickSpring != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; &amp;&amp; _mousePickSpring.IsDisposed == &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;_mousePickSpring.Dispose();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;      &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;  &lt;/SPAN&gt;_mousePickSpring = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;_pickedSprite.ReleaseMouseCapture();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;e.Handled = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;I also embellished with a Line showing the drag direction of the Spring from the Polygon.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;U&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Arial size=2&gt;Note that the “HitTest for Path Outline” method is only giving an approximate Polygon outlining the shape of the Path, but it is pretty close! I think with some further tweaks to the Utils.GetPointsForPath method, it could get even closer. &lt;/FONT&gt;&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/111/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/111/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=111</guid>
      <pubDate>Thu, 17 Jul 2008 19:28:00 GMT</pubDate>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=111</trackback:ping>
    </item>
    <item>
      <title>Finding a XAML Element by Name at Runtime</title>
      <description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;In ASP.NET, it's possible to get a reference to a control by Id at runtime using the FindControl method - something like this:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=4&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#2b91af&gt;Label &lt;/FONT&gt;lblCustomerName = (&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#2b91af&gt;&lt;FONT color=#2b91af&gt;Label&lt;/FONT&gt;&lt;/FONT&gt;) item.FindControl(&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"&lt;FONT color=#000000&gt;lblCustomerName&lt;/FONT&gt;"&lt;/FONT&gt;&lt;/FONT&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;This can be helpful in dynamic code which might need to iterate through a large collection of elements in XAML.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;In Silverlight, there is no FindControl method, but we can still get a reference to an object by name using the FindName method of a container:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#2b91af&gt;TextBlock &lt;/FONT&gt;lblCustomerName = cnvContainer.FindName("lblCustomerName") &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;as&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#2b91af&gt;&lt;FONT color=#2b91af&gt;TextBlock&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;We can also access the Children collection of a container and query using a lambda expression:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;&lt;FONT size=3&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#2b91af&gt;TextBlock &lt;/FONT&gt;lblCustomerName = (cnvContainer.Children.First&lt;&lt;FONT color=#2b91af&gt;&lt;FONT color=#2b91af&gt;UIElement&lt;/FONT&gt;&lt;/FONT&gt;&gt;(label =&gt; label.GetValue(&lt;FONT color=#2b91af&gt;&lt;FONT color=#2b91af&gt;Canvas&lt;/FONT&gt;&lt;/FONT&gt;.NameProperty).ToString() == "lblCustomerName")) &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;as&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#2b91af&gt;&lt;FONT color=#2b91af&gt;TextBlock&lt;/FONT&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;In the above example, we are getting a reference to an object named lblCustomerName inside a canvas named cnvContainer. We do so by using a lambda expression on the Children property, along with the Canvas.NameProperty which gives the variable (x:Name) property of a UIElement.&lt;/FONT&gt;&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/110/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/110/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=110</guid>
      <pubDate>Mon, 14 Jul 2008 21:52:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=110</trackback:ping>
    </item>
    <item>
      <title>Why is my Default.aspx page Always Executed?</title>
      <description>&lt;P&gt;This is a new Silverlight spin on an old problem. Let's say you have a Default.aspx page with some code behind logic in it. One day you notice using the debugger that the code-behind logic in Default.aspx.cs is &lt;STRONG&gt;&lt;EM&gt;always&lt;/EM&gt;&lt;/STRONG&gt; executed - even when accessing a different aspx page.&lt;/P&gt;
&lt;P&gt;This problem can arise for a couple of common reasons. One reason is that someone copied the Default.aspx page to a new page and forgot to change the Codebehind and Inherits page directives to a new code-behind class. You can usually solve this by searching other pages for references to _Default in their page header:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;%@ Page language="c#" &lt;FONT style="BACKGROUND-COLOR: #ffff00"&gt;Codebehind="Default.aspx.cs"&lt;/FONT&gt; AutoEventWireup="false" &lt;BR&gt;&lt;FONT style="BACKGROUND-COLOR: #ffff00"&gt;Inherits="VersaTrans.GPS.Web.UI._Default"&lt;/FONT&gt; %&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Another more common reason though, is that you have dynamically assigned a Url for a resource, such as an img src, and the src attribute evaluates to an empty string:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;IMG src='http://www.spritehand.com&lt;%# Eval("ImageUrl") %&gt;'&gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;... if bound to an empty field, would evaluate to:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;IMG src="http://www.spritehand.com"&gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;When this happens, the Request will go to the root of your website, which in turn will execute the default page of your site - normally Default.aspx. You can use a tool such as &lt;A href="http://www.fiddlertool.com/fiddler/"&gt;Fiddler&lt;/A&gt; or &lt;A href="http://projects.nikhilk.net/WebDevHelper/"&gt;Web Development Helper&lt;/A&gt; to help troubleshoot this issue. By capturing the http traffic, you will see a request for the root of your site.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;A Silverlight Twist&lt;/STRONG&gt;&lt;BR&gt;The problem described above is hard enough to track down in an ASP.NET environment. But to make it even more confusing, a Silverlight application within the ASP.NET website can also cause the problem.&lt;/P&gt;
&lt;P&gt;A common way to dynamically assign an image source in Silverlight is shown below. We create an ImageSource based on Uri and the set the SourceProperty of the Image to the Uri:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;Uri imageUri = new Uri(imageUrl, UriKind.Absolute);&lt;BR&gt;ImageSource imgSource = new System.Windows.Media.Imaging.BitmapImage(imageUri);&lt;BR&gt;img.SetValue(Image.SourceProperty, imgSource);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;... but if the variable imageUrl above is an empty string, we are back to the same issue described above for the ASP.NET environment. The browser will request the root of the web site, and the default page will be executed.&lt;/P&gt;
&lt;P&gt;To avoid this problem, check for empty Image Source's when assigning Url's to image objects.&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/109/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/109/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=109</guid>
      <pubDate>Mon, 07 Jul 2008 20:53:00 GMT</pubDate>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=109</trackback:ping>
    </item>
    <item>
      <title>I'm All Ported Out</title>
      <description>&lt;P&gt;I have most of my Silverlight games and demos ported to Silverlight 2 Beta 2. Here are links to the more popular games and demos...&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;
&lt;TABLE cellSpacing=0 cellPadding=0 width="100%" summary="Module Design Table" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width=23 background=/Portals/_default/Containers/SpriteHand/left-tile.gif&gt;&lt;/TD&gt;
&lt;TD id=dnn_ctr506_ContentPane align=left bgColor=#f7f7f7&gt;&lt;!-- Start_Module_506 --&gt;
&lt;DIV id=dnn_ctr506_ModuleContent&gt;&lt;SPAN class=Normal id=dnn_ctr506_HtmlModule_HtmlHolder&gt;
&lt;TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colSpan=2&gt;&lt;FONT face=Arial size=1&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;DESTROY ALL INVADERS&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=50&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;A href="http://www.spritehand.com/silverlight/2.0/destroyallinvaders/default.html"&gt;PLAY IT&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P align=right&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;NOBR&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/75/Default.aspx"&gt;INFO AND CODE&lt;/A&gt;&lt;/NOBR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;FONT color=#003366&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colSpan=2&gt;&lt;FONT face=Arial size=1&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;SORT THE FOOBARS&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;A game where you need to sort the good foobars from the bad ones. &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=50&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;A href="http://www.spritehand.com/silverlight/2.0/sortthefoobars/testpage.html"&gt;PLAY IT&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P align=right&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;NOBR&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/86/Default.aspx"&gt;MORE INFO&lt;/A&gt;&lt;/NOBR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;FONT color=#003366&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colSpan=2&gt;&lt;FONT face=Arial size=1&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;POLYGON PHYSICS DEMO&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;A demo showing polygon physics where the user draws physics objects with the mouse. &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=50&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;A href="http://www.spritehand.com/silverlight/2.0/polygondemo/testpage.html"&gt;PLAY IT&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P align=right&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;NOBR&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/91/Default.aspx"&gt;MORE INFO&lt;/A&gt;&lt;/NOBR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;FONT color=#003366&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colSpan=2&gt;&lt;FONT face=Arial size=1&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;SILVERLIGHT ROCKS!&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;Destroy the asteroids before they destroy your ship! &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=50&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;A href="http://www.spritehand.com/silverlight/2.0/silverlightrocks/silverlightrocks.htm"&gt;PLAY IT&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P align=right&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;NOBR&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/73/Default.aspx"&gt;INFO AND CODE&lt;/A&gt;&lt;/NOBR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;HR&gt;

&lt;TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colSpan=2&gt;&lt;FONT face=Arial size=1&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;DEEPZOOM FOR ECOMMERCE&lt;BR&gt;&lt;/STRONG&gt;A real world example of using DeepZoom for E-Commerce.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=50&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;A href="http://www.wssmithers.com"&gt;VIEW IT&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P align=right&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;NOBR&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/105/Default.aspx"&gt;MORE INFO&lt;/A&gt;&lt;/NOBR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;HR&gt;

&lt;TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colSpan=2&gt;&lt;FONT face=Arial size=1&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;USING HITTEST METHOD IN SILVERLIGHT 2 FOR COLLISION DETECTION&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;A small sample showing how to use HitTest for accurate collision detection in Silverlight 2. This method is also used in the Silverlight Rocks! sample above. &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width=50&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;A href="http://www.spritehand.com/silverlight/2.0/hittest/clientbin/testpage.html"&gt;VIEW IT&lt;/A&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P align=right&gt;&lt;FONT face=Arial color=#003366 size=2&gt;&lt;NOBR&gt;&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/95/Default.aspx"&gt;INFO AND CODE&lt;/A&gt;&lt;/NOBR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/108/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/108/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=108</guid>
      <pubDate>Mon, 16 Jun 2008 23:51:00 GMT</pubDate>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=108</trackback:ping>
    </item>
    <item>
      <title>Tech Ed Work and Play</title>
      <description>&lt;P&gt;I had a great time at Tech Ed Orlando where I helped out as a Technical Learning Guide, delivered a couple of Silverlight Instructor-Led Labs, and helped out in the Hands-On Labs area. I have to say though, that my feet have never hurt so bad because of those concrete convention floors! It was great meeting all of the other training folks there and building camaraderie. It kind of felt like summer camp when I was kid! And although I was most excited about delivering the Silverlight training, I was excited to help out with the ASP.NET MVC labs as well.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/teched1.jpg"&gt;&lt;BR&gt;&lt;FONT size=2&gt;What happens when you mix free beer with free amusement park rides? Chris Sutton, Me, Laurent Duveau, and Rodrigo Díaz Concha at the new Simpsons ride at Universal.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/teched2.jpg"&gt;&lt;BR&gt;&lt;FONT size=2&gt;Trying really hard not to look nervous :)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;And the &lt;A href="http://www.devfish.net/articles/inbetween/"&gt;Tweener Event&lt;/A&gt; on Saturday, even though I could only stick around for a bit, was a great event. I tried to hold my own, speaking between two renowned Silverlight presenters, &lt;A href="http://www.waltritscher.com/"&gt;Walt Ritscher&lt;/A&gt; and &lt;A href="http://silverlightrocks.com/community/blogs/silverlight_games_101/default.aspx"&gt;Bill Reiss&lt;/A&gt;. The real fun with the Tweener event though, was the night-before get-together hosted by &lt;A href="http://www.devfish.net/DFBlog.aspx"&gt;Joe Healy&lt;/A&gt; at Friday’s. &lt;BR&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/107/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/107/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=107</guid>
      <pubDate>Fri, 13 Jun 2008 00:36:00 GMT</pubDate>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=107</trackback:ping>
    </item>
    <item>
      <title>I'm Out and About</title>
      <description>&lt;P&gt;I'll be doing a few Silverlight talks in the coming weeks - if you are in the area, stop by and say hi! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Tuesday, June 3rd - Friday, June 6th&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;I'll be at &lt;A href="http://www.microsoft.com/events/teched2008/developer/default.mspx"&gt;Tech-Ed Developers&lt;/A&gt; in Orlando leading the Instructor-Led Lab "Microsoft Silverlight 2 Foundations" on 6/3 and 6/5, and also milling about as a Technical Learning Guide throughout the week.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Saturday, June 7th 10:20am - 11:30am&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;I'll be presenting "Silverlight 2 for Data Applications" at the &lt;A href="http://www.devfish.net/articles/inbetween/"&gt;]inbetween[&lt;/A&gt; event in Orlando. This is a FREE event and well worth the time.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Wednesday, June 18th&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;I'll be presenting "Silverlight 2 for Data Applications" at the &lt;A href="http://wnydnug.org/Meetings/tabid/54/Default.aspx"&gt;Western New York .Net Users Group&lt;/A&gt; in Buffalo, NY&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/106/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/106/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=106</guid>
      <pubDate>Wed, 28 May 2008 23:23:00 GMT</pubDate>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=106</trackback:ping>
    </item>
    <item>
      <title>DeepZoom for eCommerce</title>
      <description>&lt;P&gt;It just so happens my father-in-law is a woodworker who creates some really fantastic pieces and has contemplated selling them online for some time. But limiting the shopper to a few small thumbnail images wouldn't do his work justice.&lt;/P&gt;
&lt;P&gt;Enter Silverlight's &lt;A href="http://msdn.microsoft.com/en-us/library/cc190891(VS.95).aspx"&gt;MutliScaleImage&lt;/A&gt; class (aka "DeepZoom"). Chances are you've seen DeepZoom in action on sites like the &lt;A href="http://memorabilia.hardrock.com/"&gt;Hardrock Memorabilia&lt;/A&gt; site. DeepZoom provides progressive image downloads with an intuitive navigation system that looks like something out of &lt;A href="http://www.imdb.com/title/tt0181689/"&gt;Minority Report&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;So here is &lt;A href="http://www.wssmithers.com/InteractiveGallery/tabid/128/Default.aspx"&gt;the site&lt;/A&gt; we pulled together using DeepZoom, Silverlight, and some really impressive &lt;A href="http://en.wikipedia.org/wiki/Wood_turning"&gt;wood turnings&lt;/A&gt;:&lt;/P&gt;&lt;A href="http://www.wssmithers.com/InteractiveGallery/tabid/128/Default.aspx"&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/DeepZoom1.png"&gt;&lt;/A&gt; 
&lt;P&gt;One of the irritations with buying stuff on the web is that you can't hold the item in your hand and really check it out before forking over your credit card info. This can be especially irritating if the item you're looking at is hand-made, such as a painting, piece of pottery, or... a bowl turning! I think technologies like DeepZoom can greatly improve this experience over traditional thumbnail images.&lt;/P&gt;
&lt;P&gt;Notice how the site also uses a picture-in-picture type view for some of the pieces, to show different views - such as the item with the top removed:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.wssmithers.com/InteractiveGallery/tabid/128/Default.aspx"&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/DeepZoom2.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;... the neat thing here is that the smaller picture-in-picture image has all of the detail of the main image.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Shameless Plug:&lt;/STRONG&gt; If you are looking for a one of a kind, hand-made gift  please &lt;A href="http://www.wssmithers.com/InteractiveGallery/tabid/128/Default.aspx"&gt;browse the site&lt;/A&gt;! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Lessons Learned:&lt;BR&gt;&lt;/STRONG&gt;It turns out there is a surprising amount of code you need to write yourself to get a DeepZoom implementation such as the one at &lt;A href="http://www.wssmithers.com/"&gt;wssmithers.com&lt;/A&gt;. You might expect most functionality would be built into the MultiScaleImage class, but it isn't! &lt;/P&gt;
&lt;P&gt;One of the key requirements of the site was to be able to tie the product information (item #, price, etc) from a SQL Server db to the Images in the DeepZoom Composer project. In order to create this relationship, you can use the index # of the subimage as a unique key in the composition.&lt;/P&gt;
&lt;P&gt;So first, we handle the ImageOpenSucceeded event of the MultiScaleImage Control:&lt;/P&gt;&lt;FONT size=5&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;deepZoomObject.ImageOpenSucceeded += &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#2b91af&gt;&lt;FONT color=#2b91af&gt;RoutedEventHandler&lt;/FONT&gt;&lt;/FONT&gt;(deepZoomObject_ImageOpenSucceeded);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;... and in that handler we can store the image index along with relevant data (perhaps a ProductId) to tie the image to its data:&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Dictionary&lt;/SPAN&gt;&lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&gt; _imageData = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Dictionary&lt;/SPAN&gt;&lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&gt;();&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt; &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;       &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; deepZoomObject_ImageOpenSucceeded(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;_imageData.Clear();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; i = 0; i &lt; deepZoomObject.SubImages.Count; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MultiScaleSubImage&lt;/SPAN&gt; subImage = deepZoomObject.SubImages[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;                &lt;/SPAN&gt;_imageData.Add(i.ToString(), "You can tie data here");&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;                &lt;/SPAN&gt;subImage.SetValue(&lt;SPAN style="COLOR: #2b91af"&gt;FrameworkElement&lt;/SPAN&gt;.NameProperty, i.ToString());&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            }&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&lt;/o:p&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;There are many other aspects to creating a DeepZoom site such as this which I hope to explain in a future blog post and maybe prepare a talk on the subject!</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/105/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/105/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=105</guid>
      <pubDate>Wed, 21 May 2008 01:33:00 GMT</pubDate>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=105</trackback:ping>
    </item>
    <item>
      <title>Where is my Astoria Client for Silverlight 2?</title>
      <description>&lt;P&gt;According to &lt;A href="http://blogs.msdn.com/astoriateam/archive/2008/04/24/using-rest-services-in-silverlight.aspx"&gt;this post&lt;/A&gt; from the Astoria Team Blog, it looks like we won't have a new &lt;A href="http://astoria.mslivelabs.com/"&gt;Astoria (ADO.NET Data Services)&lt;/A&gt; client for Silverlight 2 until SL2 Beta 2 is released (perhaps May 2008?)&lt;/P&gt;
&lt;P&gt;Many of the &lt;A HREF="http://www.spritehand.com/Home/tabid/67/EntryID/103/Default.aspx"&gt;data demos for Silverlight 2&lt;/A&gt; have so far used LINQ to SQL for the data access layer. These demos involve creating a LINQ to SQL data model (using a nice drag/drop editor), and then exposing that model through a web service by manually coding a WCF Web Service or .asmx Service.&lt;/P&gt;
&lt;P&gt;Don't get me wrong, this is a pretty rapid development method... but what if you didn't need to code the web service for basic CRUD operations and queries on your data? What if it were all exposed for you and you could use LINQ to access the data from the Silverlight client?&lt;/P&gt;
&lt;P&gt;This automatic service layer is just one of the advantages that ADO.NET Data Services (Astoria) provides, and since Silverlight 2 has much better support for Data Entry controls, the combination of SL and Astoria should provide a powerful rapid development environment!&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/104/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/104/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=104</guid>
      <pubDate>Fri, 25 Apr 2008 14:04:00 GMT</pubDate>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=104</trackback:ping>
    </item>
    <item>
      <title>Silverlight 2 for Data Apps</title>
      <description>&lt;P&gt;Thanks to everyone who attended my "Silverlight 2 for Data Applications" talk at &lt;A href="http://blogs.msdn.com/cbowen/archive/2008/03/28/code-camp-9-the-schedule.aspx"&gt;Code Camp 9&lt;/A&gt; in Waltham, MA on 4/5/2008! And a big thanks to &lt;A href="http://blogs.msdn.com/cbowen/"&gt;Chris Bowen&lt;/A&gt; and &lt;A href="http://geekswithblogs.net/cpels/Default.aspx"&gt;Chris Pels&lt;/A&gt; for their hard work organizing this great event time after time. I had a great crowd for my talk, standing room only, and as promised I have some goodies for all:&lt;/P&gt;
&lt;P&gt;First, even if you couldn't make it to Code Camp for my talk, I have created a screen cast that walks through the demos. Just click the image below to &lt;A href="http://www.spritehand.comhttp://www.spritehand.com/silverlight/silverlightfordata/silverlightfordata.htm"&gt;launch the video&lt;/A&gt;:&lt;/P&gt;&lt;A href="http://www.spritehand.comhttp://www.spritehand.com/silverlight/silverlightfordata/silverlightfordata.htm"&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/SilverlightForData.png" border=0&gt;&lt;/A&gt; 
&lt;P&gt;I also have the Beers Demo Application and Slide Deck available:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.spritehand.com/silverlight/silverlightfordata/BeersDemoForSilverlight.zip"&gt;DOWNLOAD THE DEMO CODE&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.spritehand.com/silverlight/silverlightfordata/SilverlightForData.ppt.zip"&gt;DOWNLOAD THE SLIDE DECK (PPT)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT size=4&gt;Summary of the Presentation&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In this talk, I walked through a mult-tier Silverlight Application with the following architecture:&lt;/P&gt;
&lt;P&gt;1. A Silverlight 2 Client containing a Master/Detail scenario&lt;/P&gt;
&lt;P&gt;2. A WCF Web Service providing communication to the Silverlight Client&lt;/P&gt;
&lt;P&gt;3. A Data Accesss Layer using LINQ to SQL&lt;/P&gt;
&lt;P&gt;4. A Simple SQL Server Database with (Mmmmm) Beer Data.&lt;/P&gt;
&lt;P&gt;We explored how to use LINQ to SQL to expose our database entities through a WCF Web Service, and how Silverlight 2 can communicate with the web service. We also explored formatting a DataGrid and creating User Controls with DataBound UI Elements, and how to do basic CRUD operations from the Silverlight client back to the Web Service.&lt;/P&gt;
&lt;P&gt;Here is a shot of the completed demo (download the source code above):&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.spritehand.com/Silverlight/SilverlightForData/SilverlightForDataScreen.png" border=0&gt;&lt;/P&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/103/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/103/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=103</guid>
      <pubDate>Sun, 06 Apr 2008 22:59:00 GMT</pubDate>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=103</trackback:ping>
    </item>
    <item>
      <title>LINQ to SQL CRUD</title>
      <description>&lt;P&gt;I'm seeing a lot of buzz around LINQ to SQL lately and how it can help to quickly create a Silverlight 2 data app. &lt;/P&gt;
&lt;P&gt;I'll be giving a talk around this at the upcoming &lt;A href="http://blogs.msdn.com/cbowen/archive/2008/03/28/code-camp-9-the-schedule.aspx"&gt;Code Camp 9&lt;/A&gt; in Waltham, MA, and I wanted to share how I am doing basic CRUD operations in LINQ to SQL, as I've seen this question come up a few times.&lt;/P&gt;
&lt;P&gt;You may remember my Silverlight 1.1 Alpha demo app, "&lt;A href="http://www.spritehand.com/Home/tabid/67/EntryID/79/Default.aspx"&gt;Andy's Fridge&lt;/A&gt;." I'll be using a similar Beer Database which has a very simple schema containing Beers and Brewers like so:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.spritehand.com/Portals/1/BeerDB.png"&gt;&lt;/P&gt;
&lt;P&gt;It's important to note that the RowVersionId columns in the diagram are Timestamp columns. This will allow LINQ to SQL to generate more efficient Update statements, based on the unique Row Id (timestamp) instead of Where clauses with lots of logical "AND's" for each original value. &lt;/P&gt;
&lt;P&gt;So, given that schema is like that above, our CRUD operations for the Beer entity would exist in our web service like so:&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;BeerService&lt;/SPAN&gt; : &lt;SPAN style="COLOR: #2b91af"&gt;IBeerService&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&lt;&lt;SPAN style="COLOR: #2b91af"&gt;Beer&lt;/SPAN&gt;&gt; GetAllBeers()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt; db = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; beers = &lt;SPAN style="COLOR: blue"&gt;from&lt;/SPAN&gt; b &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.Beers&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;orderby&lt;/SPAN&gt; b.BeerName&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;select&lt;/SPAN&gt; b;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; beers.ToList&lt;&lt;SPAN style="COLOR: #2b91af"&gt;Beer&lt;/SPAN&gt;&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; SaveBeer(&lt;SPAN style="COLOR: #2b91af"&gt;Beer&lt;/SPAN&gt; beer)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt; db = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (beer.BeerId &gt; 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// this is an update&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;db.Beers.Attach(beer, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// this is an insert&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;            &lt;/SPAN&gt;db.Beers.InsertOnSubmit(beer);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;db.SubmitChanges();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; DeleteBeer(&lt;SPAN style="COLOR: #2b91af"&gt;Beer&lt;/SPAN&gt; beer)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt; db = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;db.Beers.Attach(beer, &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;db.Beers.DeleteOnSubmit(beer);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;        &lt;/SPAN&gt;db.SubmitChanges();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;    &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt; &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Note that I piggybacked the SaveBeer method to do either an Insert operation or Update operation, based on whether or not a primary key is available in the passed entity.&lt;/P&gt;
&lt;P&gt;I guess until ADO.NET Data Services (Astoria) and the Entity Framework are officially available, we will have to settle with LINQ to SQL for Data Access! But I don't think we will be waiting long :)&lt;/P&gt;
&lt;P&gt;What can we look forward to with Astoria and the EF?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;no need to write tedious web service methods for CRUD operations like shown above 
&lt;LI&gt;serialization of Parent and Child records (LINQ to SQL cannot pass related child records across the wire with parent rows) 
&lt;LI&gt;Access to other Database Providers other than SQL Server. 
&lt;LI&gt;The ability to flexibly map Conceptual model elements such as class properties to Physical columns in the database (LINQ to SQL provides only a 1-to-1 mapping)&lt;/LI&gt;&lt;/UL&gt;</description>
      <link>http://www.spritehand.com/Home/tabid/67/EntryID/102/Default.aspx</link>
      <author>andy@beaulieu.com</author>
      <comments>http://www.spritehand.com/Home/tabid/67/EntryID/102/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.spritehand.com/Default.aspx?tabid=67&amp;EntryID=102</guid>
      <pubDate>Fri, 28 Mar 2008 17:42:00 GMT</pubDate>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.spritehand.com/DesktopModules/Blog/Trackback.aspx?id=102</trackback:ping>
    </item>
  </channel>
</rss>