<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Gabo's blog</title><subtitle type="html">wax on, wax off for .net developers</subtitle><id>http://weblogs.asp.net/gabriellopez/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/gabriellopez/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2008-06-01T18:55:00Z</updated><entry><title>Workflow  + WCF + ASP.NET sample updated</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/11/11/workflow-wcf-asp-net-sample-updated.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/11/11/workflow-wcf-asp-net-sample-updated.aspx</id><published>2008-11-11T12:01:00Z</published><updated>2008-11-11T12:01:00Z</updated><content type="html">&lt;p&gt;Back in 2006 when Workflow foundation was still WWF (and some of us believed it was going to change the world), and all the foundations were "add ons" on top of the .NET 2.0 version of the framework I set out to build a reference asp.net help desk solution to learn the basics of the once new workflow &amp;amp; communication foundations, plus asp.net membership to see if I could make sense of all these technologies in one integrated sample.&lt;/p&gt;&lt;p&gt;The project was named &lt;a href="http://sinergia.sourceforge.net/" mce_href="http://sinergia.sourceforge.net/"&gt;Sinergia and lives in sourceforge&lt;/a&gt; (why sourceforge and not codeplex is the topic for another post). It turned out to be a pretty good experience, I played hosting workflow in a couple different hosts, and I finally settled for a Windows Service. It was a good excercise to learn what could be the best practices for developing, testing and deploying a workflow solution. I think it provides good guidance for anyone looking to build a workflow based, web .net solution.&lt;br&gt;&lt;/p&gt;&lt;p&gt;I updated the project some weeks ago, to the .net 3.5 version of the framework. It's available for &lt;a href="https://sourceforge.net/project/showfiles.php?group_id=168325" mce_href="https://sourceforge.net/project/showfiles.php?group_id=168325"&gt;download here&lt;/a&gt;.Post PDC word is Workflow Foundation is going through some major changes, which I still have to evaluate, understand and some day maybe impact on this bits.&lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6729332" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="WCF" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/WCF/default.aspx" /><category term="WWF" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/WWF/default.aspx" /></entry><entry><title>Silverlight free controls</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/10/09/silverlight-free-controls.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/10/09/silverlight-free-controls.aspx</id><published>2008-10-09T17:01:00Z</published><updated>2008-10-09T17:01:00Z</updated><content type="html">&lt;p&gt;We are doing some Silverlight development so I started to
look for third party controls to make my webapp look sexy, and came across &lt;a href="http://blogs.msdn.com/mgrayson/" mce_href="http://blogs.msdn.com/mgrayson/"&gt;Martin Grayson’s&lt;/a&gt;Blacklight project. Seems Microsoft is investing in developing and releasing quality controls, source code and everything, not tied to the official Silverlight release. &lt;/p&gt;

&lt;p&gt;In a nutshell Blacklight’s control are among the best free
up to date silverlight controls out there. &lt;a href="http://mightymeaty.members.winisp.net/blacklight.silverlight/"&gt;You can check them out online here&lt;/a&gt;. The source code is available for download in the &lt;a href="http://www.codeplex.com/blacklight/"&gt;codeplex project site&lt;/a&gt;.
They make for good examples to learn control development in Silverlight.&lt;/p&gt;

&lt;p&gt;I’ve modified the &lt;b&gt;silverlight docking panel&lt;/b&gt; to support different docking layouts, you can download the twisted &lt;a href="http://weblogs.asp.net/blogs/gabriellopez/Blacklight.SilverlightRC0-DockPosition.zip"&gt;source code here&lt;/a&gt;. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;By the way if you know of any other good Silverlight control
suite let me know.&lt;/p&gt;

&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6667317" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="silverlight" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/silverlight/default.aspx" /></entry><entry><title>The young history of our industry</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/07/28/the-young-history-of-our-industry.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/07/28/the-young-history-of-our-industry.aspx</id><published>2008-07-28T04:51:32Z</published><updated>2008-07-28T04:51:32Z</updated><content type="html">&lt;p&gt;My engineering career didn't provide any formal insight into the history and timeline of events that led to were software, and software companies are today. I never had a history of software subject, but I remember enjoying when some teacher would go out topic into historical anecdotes about when a technology appeared. 
&lt;/p&gt;&lt;p&gt;That's why I bought &lt;a href="http://www.amazon.com/Airline-Reservations-Sonic-Hedgehog-Computing/dp/026253262X"&gt;From Airline Reservations to Sonic the Hedgedog: A history of the software industry&lt;/a&gt;. Yeah a history book with a long title about the IT Industry, but it turned out to be really good reading.
&lt;/p&gt;&lt;p&gt;It follows a business perspective, that might be a bit dense at times, but it's worth it. It starts with military software projects in the fifties, sage, sabre, fortran, cobol, and goes on until middle of the nineties. It covers software contractors, corporate business software, as well as retail mass market products, including a chapter dedicated to the video game industry.
&lt;/p&gt;&lt;p&gt;It's good to learn how software companies and products were born and died, what were the strategies, revenues and historical contexts for the companies that shaped today's software industry landscape.   &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6452602" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author></entry><entry><title>MOSS Search Tunning algorithm</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/07/16/moss-search-tunning-algorithm.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/07/16/moss-search-tunning-algorithm.aspx</id><published>2008-07-16T16:17:10Z</published><updated>2008-07-16T16:17:10Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (!Customer.IsHappyWithSearchResultsRelevance)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;{
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://technet.microsoft.com/en-us/library/cc262541(TechNet.10).aspx"&gt;Enable search query logging&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://technet.microsoft.com/en-us/library/cc262796(TechNet.10).aspx"&gt;Configure Authoritative Pages&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://blogs.msdn.com/hodgblog/archive/2007/01/29/moss-search-result-removal.aspx"&gt;Remove undesired result pages&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://blah.winsmarts.com/2007-5-MOSS_2007_Trick_-_Search_Scopes_+_Managed_Properties__Tasty_Dish.aspx"&gt;Configure Search Scopes&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://blogs.msdn.com/miketag/archive/2007/07/16/reasons-for-a-full-crawl.aspx"&gt;Schedule full &amp;amp; incremental crawls&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;    
 &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;span style="color:green"&gt;//[http://&amp;lt;MOSSURL&amp;gt;/ssp/admin/_layouts/SpUsageSspSearchResults.aspx]&lt;/span&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;span style="color:blue"&gt;foreach&lt;/span&gt;(Keyword k &lt;span style="color:blue"&gt;in&lt;/span&gt; Top Queries With Low ClickThrough&lt;span style="color:green"&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;    {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://office.microsoft.com/en-us/sharepointserver/HA011605771033.aspx"&gt;Add keywords, synonyms and best bets&lt;/a&gt;(k)&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;    }            
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://msdn.microsoft.com/en-us/library/bb219479.aspx"&gt;Develop Custom Search Webpart with Custom SQL Syntax&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;span style="color:green"&gt;//handle with care, black magic involved, time space search continum in jeopardy
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;a href="http://www.codeplex.com/searchrelevancy"&gt;Change property weights with relevancy tool&lt;/a&gt;&lt;span style="color:green"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;span style="color:blue"&gt;if&lt;/span&gt;(Customer.StillUnhappy) {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;
			&lt;span style="color:blue"&gt;return&lt;/span&gt;
			&lt;a href="http://www.fastsearch.com/"&gt;Call the cavalry&lt;/a&gt; || WaitUntil_MOSS_2009() &lt;span style="color:green"&gt;//busy wating?
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;    }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New; font-size:10pt"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6407241" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="SharePoint" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/SharePoint/default.aspx" /><category term="search" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/search/default.aspx" /></entry><entry><title>eBanking meets RIA</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/06/27/ebanking-meets-ria.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/06/27/ebanking-meets-ria.aspx</id><published>2008-06-27T04:11:00Z</published><updated>2008-06-27T04:11:00Z</updated><content type="html">So we said to ourselves, all internet banking applications look pretty much the same, despite there are some new toys in town like &lt;b&gt;Silveright&lt;/b&gt;, and AJAX. What would be the result of applying &lt;b&gt;Rich Internet Application&lt;/b&gt; technologies to our &lt;b&gt;internet banking&lt;/b&gt; platform?&lt;br&gt;&lt;br&gt;

This was the result back in January,
&lt;br&gt;&lt;br&gt;
&lt;object width="425" height="344"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/Q5Gixj31xF4&amp;amp;hl=en"&gt;
&lt;embed src="http://www.youtube.com/v/Q5Gixj31xF4&amp;amp;hl=en" mce_src="http://www.youtube.com/v/Q5Gixj31xF4&amp;amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"&gt;&lt;/object&gt;
&lt;br&gt;&lt;br&gt;
Now where are back again working on a new, improved version.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6325720" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="silverlight" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/silverlight/default.aspx" /><category term="internet banking" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/internet+banking/default.aspx" /><category term="financial services" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/financial+services/default.aspx" /></entry><entry><title>Office Seat Map webpart</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/06/27/office-seat-map-webpart.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/06/27/office-seat-map-webpart.aspx</id><published>2008-06-27T02:57:00Z</published><updated>2008-06-27T02:57:00Z</updated><content type="html">
&lt;p&gt;In our efforts to make the most of our intranet, and the SharePoint intranets projects we deliver, I'm developing a &lt;b&gt;Silverlight&lt;/b&gt; based, &lt;b&gt;Office Map webpart&lt;/b&gt;. I like to think of it as a Google Maps, or Virtual Earth, for the enterprise cubicles.  
&lt;/p&gt;

&lt;p&gt;It's fairly simple stuff right now, I'm querying contact information from the MOSS User Profiles store and I'm displaying it associated to a x,y pair of coordinates on top of an office map image, Silverlight is just perfect for this kind of stuff. Profiles positioning is a drag and drop task carried out by and admin.
&lt;/p&gt;

&lt;p&gt;This is what it looks like now,
&lt;/p&gt;

&lt;p align="center"&gt;&amp;nbsp;&lt;img src="http://weblogs.asp.net/blogs/gabriellopez/seatmap.png" title="office seat map webpart" alt="office seat map webpart" mce_src="http://weblogs.asp.net/blogs/gabriellopez/seatmap.png" width="400" height="272"&gt;&lt;/p&gt;

&lt;p&gt;Some scenarios I think a tool like this could come in handy are:
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mapping names to faces, and viceversa (what was the name again of the new guy seated over there?)
&lt;/li&gt;

&lt;li&gt;Geo querying workmates basic contact information (phone, email, mobile)
&lt;/li&gt;

&lt;li&gt;Locating resources, printers, shredders in the office (ok, I've just sent ten copies to HP LaserJet 3320, now where the heck is that printer?)
&lt;/li&gt;

&lt;li&gt;Management Office space, and seat assignment planning. Designing and sharing possible seat layouts.
&lt;/li&gt;

&lt;li&gt;Communicating seat assignments highlighting only those who've been moved 
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It'd be cool to integrate it to a map provider like Virtual Earth, zooming in from the world map to the office building, into the seat map.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6325469" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="SharePoint" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/SharePoint/default.aspx" /><category term="silverlight" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/silverlight/default.aspx" /><category term="enterprise 2.0" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/enterprise+2.0/default.aspx" /><category term="intranet" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/intranet/default.aspx" /></entry><entry><title>Silverlight 2 Beta 2 is out there, but hold on...</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/06/08/silverlight-2-beta-2-is-out-there-but-hold-on.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/06/08/silverlight-2-beta-2-is-out-there-but-hold-on.aspx</id><published>2008-06-08T17:10:00Z</published><updated>2008-06-08T17:10:00Z</updated><content type="html">&lt;p&gt;As &lt;a href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx"&gt;Scott Guthrie posted&lt;/a&gt;, there's a new release available of Silverlight 2, it's &lt;b&gt;beta version 2&lt;/b&gt; now this time, and we are getting closer to the release.I've upgraded to the new version, and here's a quick review of the pros and cons,&lt;br&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;The Pros&lt;/b&gt;,&lt;/p&gt;&lt;ul&gt;&lt;li&gt;It has &lt;b&gt;go live&lt;/b&gt; license, meaning you can take it to production and you'll get support&lt;/li&gt;&lt;li&gt;There's a new Expression Blend preview, compatible with the VS2008 SP1 beta&lt;/li&gt;&lt;li&gt;It has several enhancements in the control template editing support, for out of the box controls&lt;br&gt;&lt;/li&gt;&lt;li&gt;A new feature called Visual State Manager which enables customization of controls look&amp;amp;feel in specific states, like checked, unchecked, pressed, visited and the transitions animations between states&lt;/li&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx"&gt;Check scott's entry for the full list and explanation&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;The Cons&lt;/b&gt;,&lt;br&gt;&lt;ul&gt;&lt;li&gt; Clients upgraded to beta 2 won't be able to run beta 1 apps,&amp;nbsp; so if you have a bunch of silverlight applications it's an all or none upgrade decision.&lt;/li&gt;&lt;li&gt;&lt;b&gt;It's buggy in the WCF service reference wizard&lt;/b&gt;, you may want to check &lt;a href="http://silverlight.net/forums/t/17500.aspx" mce_href="http://silverlight.net/forums/t/17500.aspx"&gt;this forum thread&lt;/a&gt;. You get some very annoying &lt;b&gt;Unable to find service 'DynamicTypeService'&lt;/b&gt; messages, plus some object reference not set to an instance of an object when trying to add a new reference. This for me has been a low blow, since I may have to rewrite all the communication logic, or wait for a fix :(&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I'll keep you in the loop,&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6257642" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="silverlight" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/silverlight/default.aspx" /><category term="WCF" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/WCF/default.aspx" /></entry><entry><title>The state of the art in code quality metrics</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/06/07/the-state-of-the-art-in-code-quality-metrics.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/06/07/the-state-of-the-art-in-code-quality-metrics.aspx</id><published>2008-06-07T17:23:00Z</published><updated>2008-06-07T17:23:00Z</updated><content type="html">&lt;p&gt;&lt;img src="http://blog.pengoworks.com/enclosures/wtfm_cf7237e5-a580-4e22-a42a-f8597dd6c60b.jpg" mce_src="http://blog.pengoworks.com/enclosures/wtfm_cf7237e5-a580-4e22-a42a-f8597dd6c60b.jpg" height="471" width="500"&gt;&lt;/p&gt;&lt;p&gt;Any coincidence with reality is on your account&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6255937" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author></entry><entry><title>SOA Governance</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/06/02/soa-governance.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/06/02/soa-governance.aspx</id><published>2008-06-02T17:08:08Z</published><updated>2008-06-02T17:08:08Z</updated><content type="html">&lt;p&gt;&lt;strong&gt;SOA Governance&lt;/strong&gt;, a term that's taking off but's not always easy to pick up. &lt;a href="http://www.ibm.com/developerworks/webservices/library/ar-servgov/?S_TACT=105AGX04&amp;amp;S_CMP=ART"&gt;Here's a good article from IBM that introduces it&lt;/a&gt;, explaining what would happen if there is no SOA Governance in the enterprise.
&lt;/p&gt;&lt;p&gt;&lt;em&gt;"Service-Oriented Architecture (SOA) is a compelling technique for developing software applications that best align with business models. However, SOA increases the level of cooperation and coordination required between business and information technology (IT), as well as among IT departments and teams. This cooperation and coordination is provided by SOA governance, which covers the tasks and processes for specifying and managing how services and SOA applications are supported."&lt;/em&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6242454" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author></entry><entry><title>How to develop a casual game with Silverlight 2</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gabriellopez/archive/2008/06/01/how-to-develop-a-casual-game-with-silverlight-2.aspx" /><id>http://weblogs.asp.net/gabriellopez/archive/2008/06/01/how-to-develop-a-casual-game-with-silverlight-2.aspx</id><published>2008-06-01T20:55:00Z</published><updated>2008-06-01T20:55:00Z</updated><content type="html">&lt;p&gt;Game programming was my first love in computer science, and a couple of weeks ago I decided to give it a try with the new Silverlight 2 version available. To my surprise I could accomplish something fun with little effort, and maybe there's someone out there trying to do stuff like this, so let's go through the basics of building a casual game with silverlight 2. Our target will be to develop a mutant version of the old &lt;a href="http://en.wikipedia.org/wiki/Breakout" mce_href="http://en.wikipedia.org/wiki/Breakout"&gt;breakout&lt;/a&gt; classic. We are going to animate a paddle to prevent a ball from touching the ground while breaking bricks on top of each screen.
&lt;/p&gt;&lt;p&gt;Assuming you have a Visual Studio 2008 installation, with the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e0bae58e-9c0b-4090-a1db-f134d9f095fd&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e0bae58e-9c0b-4090-a1db-f134d9f095fd&amp;amp;displaylang=en"&gt;Silverlight Tools for VS2008&lt;/a&gt; loaded, let's start by creating a Silverlight Application Project. 
&lt;/p&gt;&lt;div style="text-align: center;"&gt;&lt;table style="border-collapse: collapse;" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 319px;"&gt;&lt;col style="width: 319px;"&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;&lt;tr&gt;&lt;td style="padding-left: 7px; padding-right: 7px;"&gt;&lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/gabriellopez/silverlightapp.png" title="silverlight visual studio" alt="silverlight visual studio" mce_src="http://weblogs.asp.net/blogs/gabriellopez/silverlightapp.png" height="200" width="300"&gt;&lt;br&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style="padding-left: 7px; padding-right: 7px;"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/blogs/gabriellopez/silverlightapp2.png" title="silverlight visual studio web app" alt="silverlight visual studio web app" mce_src="http://weblogs.asp.net/blogs/gabriellopez/silverlightapp2.png" height="155" width="210"&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;First we are going to modify the Page.xaml created page, to include all the elements our simple game will have, being those: 
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;a paddle, 
&lt;/li&gt;&lt;li&gt;a ball, 
&lt;/li&gt;&lt;li&gt;some bricks to destroy
&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Let's start by changing the default Grid layout, to use instead a Canvas layout, with some rectangles in it. Use the following xaml code:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&lt;span style="font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;
				&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Canvas&lt;/span&gt;&lt;span style="color: red;"&gt; x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="GameCanvas"&lt;/span&gt;&lt;span style="color: red;"&gt; Background&lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-size: 8pt;"&gt;="LightGray" &lt;/span&gt;&lt;span style="font-size: 3pt;"&gt;
				&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;span style="color: red;"&gt;Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="400" &lt;/span&gt;&lt;span style="color: red;"&gt;Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="300"&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;
			&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Rectangle&lt;/span&gt;&lt;span style="color: red;"&gt; x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="paddle"&lt;/span&gt;&lt;span style="color: red;"&gt; Fill&lt;/span&gt;&lt;span style="color: blue;"&gt;="Black"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="60"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="10"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Top&lt;/span&gt;&lt;span style="color: blue;"&gt;="280"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Left&lt;/span&gt;&lt;span style="color: blue;"&gt;="180"/&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;
			&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Rectangle&lt;/span&gt;&lt;span style="color: red;"&gt; x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="ball"&lt;/span&gt;&lt;span style="color: red;"&gt; Fill&lt;/span&gt;&lt;span style="color: blue;"&gt;="Black"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="10"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="10"&lt;/span&gt;&lt;span style="color: red;"&gt; RadiusX&lt;/span&gt;&lt;span style="color: blue;"&gt;="5"&lt;/span&gt;&lt;span style="color: red;"&gt; RadiusY&lt;/span&gt;&lt;span style="color: blue;"&gt;="5"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Left&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Top&lt;/span&gt;&lt;span style="color: blue;"&gt;="250"/&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;
			&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Rectangle&lt;/span&gt;&lt;span style="color: red;"&gt; x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Brick1"&lt;/span&gt;&lt;span style="color: red;"&gt; Fill&lt;/span&gt;&lt;span style="color: blue;"&gt;="Red"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="40"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="15"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Left&lt;/span&gt;&lt;span style="color: blue;"&gt;="120"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Top&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"/&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;
			&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Rectangle&lt;/span&gt;&lt;span style="color: red;"&gt; x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Brick2"&lt;/span&gt;&lt;span style="color: red;"&gt; Fill&lt;/span&gt;&lt;span style="color: blue;"&gt;="Blue"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="40"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="15"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Left&lt;/span&gt;&lt;span style="color: blue;"&gt;="180"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Top&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"/&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;
			&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Rectangle&lt;/span&gt;&lt;span style="color: red;"&gt; x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Brick3"&lt;/span&gt;&lt;span style="color: red;"&gt; Fill&lt;/span&gt;&lt;span style="color: blue;"&gt;="Green"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="40"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="15"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Left&lt;/span&gt;&lt;span style="color: blue;"&gt;="240"&lt;/span&gt;&lt;span style="color: red;"&gt; Canvas.Top&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"/&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 8pt;"&gt;&lt;span style="color: rgb(163, 21, 21); font-family: Courier New;"&gt;
			&lt;/span&gt;&lt;span style="color: blue; font-family: Courier New;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21); font-family: Courier New;"&gt;Canvas&lt;/span&gt;&lt;span style="color: blue; font-family: Courier New;"&gt;&amp;gt;&lt;/span&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;You should be able to see something like this in the updated design preview,&lt;/p&gt;&lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/gabriellopez/preview.png" title="silverlight casual game breakout" alt="silverlight casual game breakout" mce_src="http://weblogs.asp.net/blogs/gabriellopez/preview.png" align="middle" height="300" width="399"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="text-align: center;"&gt;
	&lt;/p&gt;&lt;h2&gt;Animating the paddle
&lt;/h2&gt;&lt;p&gt;To animate the paddle we are going to add an event handler for the KeyDown event, in the Canvas element of the Page user control. When doing this we'll come across a beta bug, adding the Canvas KeyDown event handler in the xaml doesn't work (at least, not for me), but if I register the event handler in the code behind it works.
&lt;/p&gt;&lt;p style="text-align: center;"&gt;
	&lt;/p&gt;&lt;p&gt;So far, my code looks something like the following code block, and after build you should be able to happily move your paddle left and right ways.
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;public&lt;/span&gt; Page()
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;            &amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;.KeyDown += &lt;span style="color: blue;"&gt;new&lt;/span&gt;
			&lt;span style="color: rgb(43, 145, 175);"&gt;KeyEventHandler&lt;/span&gt;(GameCanvas_KeyDown);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;        }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;private&lt;/span&gt;
			&lt;span style="color: blue;"&gt;void&lt;/span&gt; GameCanvas_KeyDown(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;KeyEventArgs&lt;/span&gt; e)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; currentX = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)paddle.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.LeftProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; newX = 0;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt; (e.Key.Equals(&lt;span style="color: rgb(43, 145, 175);"&gt;Key&lt;/span&gt;.Left)) 
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; newX = currentX - 5;                                
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt; (newX &amp;lt; 0)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; newX = 0;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }                
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;
			&lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.Key.Equals(&lt;span style="color: rgb(43, 145, 175);"&gt;Key&lt;/span&gt;.Right))
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;            &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; newX = currentX + 5;                
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt; ((newX + paddle.Width) &amp;gt; GameCanvas.Width)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; newX = GameCanvas.Width - paddle.Width;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }                
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; paddle.SetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.LeftProperty, newX);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;        }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;But there's still not much fun involved, everything still is pretty static, so let's animate the ball now.
&lt;/p&gt;&lt;h2&gt;Animating the ball
&lt;/h2&gt;&lt;p&gt;In Silverlight there might be a better way to do this with storyboards, but I'm going to go old school on this one and use a timer, and increment the ball coordinates with a vector. 
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;        System.Threading.&lt;span style="color: rgb(43, 145, 175);"&gt;Timer&lt;/span&gt; tick;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;
			&lt;span style="color: blue;"&gt;double&lt;/span&gt; vectorY = 10;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;
			&lt;span style="color: blue;"&gt;double&lt;/span&gt; vectorX = 10;&lt;/span&gt;
	&lt;/p&gt;&lt;p&gt;In the code of a new GotFocus handler for the Canvas element, we are going to set the timer. The timer invokes the OnTick handler on wake  up, which in turn uses the beautiful Dispatcher.BeginInvoke(()=&amp;gt;UpdateBallPosition()) lambda expression to execute code in the UI thread, and be able to access safely all the UI elements in the canvas, and calculate the new coordinates of the ball and update them.
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;private&lt;/span&gt;
			&lt;span style="color: blue;"&gt;void&lt;/span&gt; OnGotFocus(&lt;span style="color: blue;"&gt;object&lt;/span&gt; source, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; args)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tick = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Threading.&lt;span style="color: rgb(43, 145, 175);"&gt;Timer&lt;/span&gt;(OnTick, &lt;span style="color: blue;"&gt;null&lt;/span&gt;, 1000, 100);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;        }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;void&lt;/span&gt; OnTick(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;.Dispatcher.BeginInvoke(() =&amp;gt; UpdateBallPosition());
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;        }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;void&lt;/span&gt; UpdateBallPosition()
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; x = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)ball.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.LeftProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; y = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)ball.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.TopProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; paddleX = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)paddle.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.LeftProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; paddleY = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)paddle.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.TopProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; maxX = GameCanvas.Width;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double&lt;/span&gt; maxY = GameCanvas.Height;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += vectorX;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y += vectorY;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; collision detection
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; outer boundaries
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt; (x &amp;lt;= 0 || x &amp;gt;= (maxX - ball.Width))
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vectorX = -(vectorX);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; x = (x &amp;lt;= 0) ? 0 : x;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; x = x &amp;gt;= (maxX - ball.Width) ? (maxX - ball.Width) : x;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt; paddleHit = ((y + ball.Height) &amp;gt;= paddleY &amp;amp;&amp;amp; x &amp;gt;= paddleX &amp;amp;&amp;amp; x &amp;lt;= (paddleX + paddle.Width));
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt; (y &amp;lt;= 0 || y &amp;gt;= (maxY - ball.Height) || paddleHit)
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vectorY = -(vectorY);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; y = (y &amp;lt;= 0) ? 0 : y;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; y = y &amp;gt;= (maxY - ball.Height) ? (maxY - ball.Height) : y;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue; font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue; font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ball.SetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.TopProperty, y);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ball.SetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.LeftProperty, x);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 8pt;"&gt;&lt;span style="font-family: Courier New;"&gt;        }&lt;/span&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Then we add code like the following to enable collision detection with the bricks, 
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&lt;span style="color: blue;"&gt;            #region&lt;/span&gt; collision detection blocks
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;double&lt;/span&gt; blockY = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)Brick1.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.TopProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;double&lt;/span&gt; blockX = (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)Brick1.GetValue(&lt;span style="color: rgb(43, 145, 175);"&gt;Canvas&lt;/span&gt;.LeftProperty);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: blue;"&gt;if&lt;/span&gt; (y &amp;gt;= blockY &amp;amp;&amp;amp; y &amp;lt;= (blockY + Brick1.Height) &amp;amp;&amp;amp; x &amp;gt;= blockX &amp;amp;&amp;amp; x &amp;lt;= (blockX + Brick1.Width))
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;            {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;
			&lt;span style="color: green;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //block collision
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Brick1.Fill = &lt;span style="color: blue;"&gt;new&lt;/span&gt;
			&lt;span style="color: rgb(43, 145, 175);"&gt;SolidColorBrush&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;Colors&lt;/span&gt;.Yellow);                                
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vectorY = -(vectorY);                
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 8pt;"&gt;            }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 8pt;"&gt;&lt;span style="color: blue; font-family: Courier New;"&gt;            #endregion&lt;/span&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This is just for one brick, you do your thing to generalize this code for all three bricks. 
&lt;/p&gt;&lt;p&gt;And of course, it wouldn't be a game if there's no way to loose or win, so we add logic to control win or lose conditions.
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;            #region&lt;/span&gt; gameover and win conditions
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
			&lt;span style="color: green;"&gt;//GAME OVER?
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
			&lt;span style="color: blue;"&gt;if&lt;/span&gt; (y &amp;gt;= (maxY - ball.Height))
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;            {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
			&lt;span style="color: green;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //game over 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tick.Dispose();                             
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;
			&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;            }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size: 10pt;"&gt;&lt;span style="color: blue; font-family: Courier New;"&gt;            #endregion&lt;/span&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This is just the lose condition, but I hope you get the idea. Next week we'll pimp up this solution to add score handling and sounds to this breakout mutant. The &lt;a href="http://weblogs.asp.net/blogs/gabriellopez/BreakoutMutant.zip" title="silverlight casual game sample" mce_href="http://weblogs.asp.net/blogs/gabriellopez/BreakoutMutant.zip"&gt;source code from the developed casual game sample can be downloaded from here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6240194" width="1" height="1"&gt;</content><author><name>gabouy</name><uri>http://weblogs.asp.net/members/gabouy.aspx</uri></author><category term="silverlight" scheme="http://weblogs.asp.net/gabriellopez/archive/tags/silverlight/default.aspx" /></entry></feed>