<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-234416327021972627</id><updated>2012-01-24T13:13:03.118-06:00</updated><category term='c#'/><category term='VSTT'/><category term='SRP'/><category term='Web Test'/><category term='OCP'/><category term='Design Review'/><category term='Load test'/><category term='Open Closed Principle'/><category term='Software Development'/><category term='.Net'/><category term='VB.Net'/><category term='Circular Reference'/><category term='Management'/><category term='Single Responsibilty Principle'/><category term='VSTS Test Edition'/><title type='text'>Tim's Brown Bag Lunch</title><subtitle type='html'>I borrowed the term “Brown Bag Lunch” from a former colleague of mine (Dirk Vangeison).  The idea of the brown bag lunch is every month or so have a team member volunteer to host a 1 hour presentation over lunch (of course the attendees would bring their own lunch). Topics for a brown bag lunch might be design patterns, new technologies, SDLC, trouble shooting techniques, or new tools.  It is a great way to transfer knowledge and really good way to develop presentation skills.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-8312535456936103628</id><published>2010-05-29T08:31:00.001-05:00</published><updated>2010-05-29T08:31:42.709-05:00</updated><title type='text'>Azure In Action Book Review</title><content type='html'>&lt;p&gt;This week I just finished co hosting the Minneapolis Windows Azure boot camp.&amp;#160; We had about 100 folks show up which near as I can tell makes it one of the largest if not the largest boot camp in the country. By way of preparation for the event Manning Publishing, Chris Hay, and Brian Prince were kind enough to provide me with a copy of Azure in Action.&amp;#160; Being a consultant at &lt;a href="http://www.intertech.com/"&gt;Intertech&lt;/a&gt; here in Minneapolis, I pretty much always have a full time customer that pays me to do work (for them of course).&amp;#160; When I am trying to learn a new subject I tend to do it off hours and I tend to only have small half hour time slices to really focus on it.&amp;#160; I need a book that I can pick up for a short period of time 4 or 5 times a week and if I skip a couple days I don’t want to have to struggle with trying to remember where I left off.&amp;#160;&amp;#160; &lt;a href="http://www.manning.com/hay/"&gt;&lt;strong&gt;Azure In Action&lt;/strong&gt;&lt;/a&gt; fit the bill perfectly.&amp;#160; &lt;/p&gt;  &lt;p&gt;Chris Hay and Brian Prince (Manning Publications) do an excellent job of sprinkling in a refreshing dose of IT humor as they show us how to use this exciting new platform and teach us how we need to think differently about how we architect an application for the clouds.&amp;#160; Chapter 11 section 1 has a perfect example of this combination of humor and new way of thinking about architecture:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;“&lt;strong&gt;&lt;u&gt;Surely I always need a relational database, you pillock?&lt;/u&gt;&lt;/strong&gt;     &lt;br /&gt;Over the past decade or so, there has been a government conspiracy to make us always use relational databases to track our data ;). Every database vendor has some secret code in their product that means the government can query our data whenever they want.     &lt;br /&gt;Okay, so the above statement is a bunch of baloney but there is a serious point there (no really there is). We are a little conditioned to store our data in a relational form, even when it's not strictly necessary.     &lt;br /&gt;If you can expand your mind and except that there are other ways of storing data then you can use the Table Service to store your data in a highly scalable (and cheaper fashion).”&lt;/p&gt;  &lt;p&gt;If you are thinking about using the Windows Azure platform or just getting started on an Azure project, do yourself a favor and go out and get a copy of Azure in Action – you won’t regret it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.intertech.com/PostingImages/AzureinActionBookReview_84E8/image.png"&gt;&lt;img title="image" border="0" alt="image" src="http://www.intertech.com/PostingImages/AzureinActionBookReview_84E8/image_thumb.png" width="198" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.manning.com/hay/" href="http://www.manning.com/hay/"&gt;http://www.manning.com/hay/&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e9bfe492-6c95-43ab-99f8-127fbc3accbf" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows+Azure" rel="tag"&gt;Windows Azure&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Azure+In+Action" rel="tag"&gt;Azure In Action&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Prince" rel="tag"&gt;Prince&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Hay" rel="tag"&gt;Hay&lt;/a&gt;,&lt;a href="http://technorati.com/tags/cloud+computing" rel="tag"&gt;cloud computing&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-8312535456936103628?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/8312535456936103628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/05/azure-in-action-book-review.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/8312535456936103628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/8312535456936103628'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/05/azure-in-action-book-review.html' title='Azure In Action Book Review'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-4011761312211556004</id><published>2010-03-05T17:58:00.001-06:00</published><updated>2010-03-05T17:58:33.677-06:00</updated><title type='text'>Moved to the Intertech site</title><content type='html'>&lt;p&gt;I have moved my blog to the Intertech site.&lt;/p&gt;  &lt;p&gt;Here is my first post&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.intertech.com/Blog/post/Software-as-a-Service-(SaaS).aspx" href="http://www.intertech.com/Blog/post/Software-as-a-Service-(SaaS).aspx"&gt;http://www.intertech.com/Blog/post/Software-as-a-Service-(SaaS).aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is the general blog site:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.intertech.com/Blog/" href="http://www.intertech.com/Blog/"&gt;http://www.intertech.com/Blog/&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-4011761312211556004?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/4011761312211556004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/03/moved-to-intertech-site.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4011761312211556004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4011761312211556004'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/03/moved-to-intertech-site.html' title='Moved to the Intertech site'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-7077689867827419364</id><published>2010-02-05T17:22:00.001-06:00</published><updated>2010-02-05T17:22:44.491-06:00</updated><title type='text'>Not moving just yet</title><content type='html'>&lt;p&gt;I am having some technical difficulties getting images posted to my new blog site so I’ll revise my statement.&amp;#160; Very soon I will be blogging on an internally managed blog site at Intertech (&lt;a href="http://www.intertech.com/blog/"&gt;http://www.intertech.com/blog/&lt;/a&gt;).&amp;#160; I will not be moving existing content but I will continue to update the links on my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html"&gt;design and code review check list&lt;/a&gt; until it is complete.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-7077689867827419364?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/7077689867827419364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/02/not-moving-just-yet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7077689867827419364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7077689867827419364'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/02/not-moving-just-yet.html' title='Not moving just yet'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-9207991782161733449</id><published>2010-02-05T17:19:00.001-06:00</published><updated>2010-02-05T17:19:26.356-06:00</updated><title type='text'>Consider composition over inheritance</title><content type='html'>&lt;p&gt;This week I want to discuss another bullet from my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html"&gt;code review checklist&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Composition is a method we use to combine simple objects into more complex objects.&amp;#160; With composition we have an owner class that changes behavior by delegating the implementation of certain behaviors to smaller and simpler objects.&amp;#160; When we destroy the owner object, all of these smaller objects the owner uses are also destroyed.&amp;#160; If we were to use inheritance to achieve this same goal (changing behavior) we would use a subclass to change the behavior of the base class.&amp;#160; As I mentioned in &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-delegation-vs.html" target="_blank"&gt;my last post&lt;/a&gt;,&amp;#160; the base class and subclass are tightly coupled and this can tend to be a bit brittle.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;Consider the very real case where we are writing an application that needs to work with both Oracle and SQL Server.&amp;#160; We could use inheritance to define a base class and have one subclass for SQL Server and another for Oracle.&amp;#160; Our application can figure out which object to instantiate at runtime and that will work pretty well. Here is what our class diagram might look like:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/S2ynett7_oI/AAAAAAAAAJ4/ktppdoOfnvQ/s1600-h/image3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/S2yne1wtKyI/AAAAAAAAAJ8/GQCe2lj-BUc/image_thumb1.png?imgmax=800" width="399" height="374" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;If we take a little different approach and use composition instead we might have a class diagram similar to the following.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/S2ynfMOB1aI/AAAAAAAAAKA/sAM5yexY-80/s1600-h/image7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/S2ynfaw07rI/AAAAAAAAAKE/GOmHfTIHgRA/image_thumb3.png?imgmax=800" width="403" height="397" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The CompositionDatabaseWriter does not need to implement IDatabaseWriter but I did that because I think it makes the example easier to understand.&amp;#160; The application will use the CompositionDatabaseWriter to do database work and CompositionDatabaseWriter will determine whether to use SqlServerDatabaseWriter or OracleDatabaseWriter at runtime perhaps by using a configuration file entry.&amp;#160; When one of the CompositionDatabaseWriter methods is called, CompositionDatabaseWriter simply calls the corresponding method on the Sql Server or Oracle object.&amp;#160; &lt;/p&gt;  &lt;p&gt;Both designs allow us to interact with an oracle or Sql Server database which was our goal.&amp;#160; Now here is where the flexibility of composition comes in;&amp;#160; Suppose we now need to support a MySql database.&amp;#160; If we use inheritance to solve this problem, at a minimum we must create a MySqlDatabaseWriter subclass, recompile, test, and deploy our data layer.&amp;#160; If we use composition instead we can create a MySqlDatabaseWriter in a new assembly and all we have to do to use it is deploy this single assembly and change a config file.&amp;#160; Very powerful, because we used composition we can change the behavior at runtime via configuration. &lt;/p&gt;  &lt;p&gt;The fact of the mater is that our sample is so simple we didn’t even use composition at all so imagine the considerably more complex scenario where what we are doing is creating a persistence object that must transactionally work with the file system and a database.&amp;#160; We define the persistence object and within the persistence object we delegate the responsibility of dealing with the file system to one class, and dealing with the database to another.&amp;#160; The persistence object is &lt;em&gt;composed&lt;/em&gt; of a FileSytemWriter and a DatabaseWriter.&amp;#160; Our Persistence object has only one concern – coordinating database and file persistence.&amp;#160; Our FileSystemWriter has only one concern – managing File System interactions, and finally our DatabaseWriter is only concerned about interacting with a database of one type.&amp;#160; We have decomposed a fairly complex problem into a few smaller more managable problems, we came up with a nice robust design thanks to composition and we have managed to do it in such a way that there are no &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-single-responsibility.html" target="_blank"&gt;SRP&lt;/a&gt; violations either!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-9207991782161733449?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/9207991782161733449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/02/consider-composition-over-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/9207991782161733449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/9207991782161733449'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/02/consider-composition-over-inheritance.html' title='Consider composition over inheritance'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_04HDQqptby8/S2yne1wtKyI/AAAAAAAAAJ8/GQCe2lj-BUc/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-4501838849243196885</id><published>2010-01-24T10:33:00.001-06:00</published><updated>2010-01-24T10:33:23.475-06:00</updated><title type='text'>Moving my blog.</title><content type='html'>&lt;p&gt;As of today I will be blogging on an internally managed blog site at Intertech (&lt;a href="http://www.intertech.com/blog/"&gt;http://www.intertech.com/blog/&lt;/a&gt;).&amp;#160; I will not be moving existing content but I will continue to update the links on my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html" target="_blank"&gt;design and code review check list&lt;/a&gt; until it is complete.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-4501838849243196885?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/4501838849243196885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/01/moving-my-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4501838849243196885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4501838849243196885'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2010/01/moving-my-blog.html' title='Moving my blog.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-7402122800375442634</id><published>2009-12-26T11:02:00.001-06:00</published><updated>2009-12-26T11:02:40.222-06:00</updated><title type='text'>Design Review and Delegation Vs. Inheritance</title><content type='html'>&lt;p&gt;This week I want to discuss another bullet from my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html" target="_blank"&gt;code review checklist&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;Consider delegation over inheritance.&amp;#160; I have had some pretty heated debates on this topic in the past and I will even take it a step further and say the rule should state that we should &lt;strong&gt;&lt;em&gt;&lt;u&gt;favor&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; delegation over inheritance.&amp;#160; Let’s consider the following classic (and intuitive) person/student/teacher example.&amp;#160; A class diagram might look something like this&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/SzZBqtfVgaI/AAAAAAAAAJo/WCtOdyceix0/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SzZBqz_W0qI/AAAAAAAAAJs/zFXGVgk0jkI/image_thumb%5B1%5D.png?imgmax=800" width="414" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Person is our base class; Teacher and student derive from person.&amp;#160; We can say that a student &lt;strong&gt;&lt;em&gt;Is A&lt;/em&gt;&lt;/strong&gt; person and that a Teacher&lt;strong&gt;&lt;em&gt; Is A&lt;/em&gt;&lt;/strong&gt; person.&lt;/p&gt;  &lt;p&gt;The up-side of this design is it is simple, intuitive, and it will perform well.&amp;#160; The down side of this approach is that there is a tight coupling between the derived classes and the base class, we are breaking encapsulation by making the functionality of the derived class dependent on the functionality in the base class, and we may even break encapsulation on our Person class by using protected or public access modifiers where we normally wouldn’t do so.&amp;#160; &lt;/p&gt;  &lt;p&gt;The problem with breaking encapsulation is that making a change to one class (our base class) can cause unintended changes in other consuming classes (our derived classes).&amp;#160; I can’t begin to tell you how many times I have seen a seemingly small change to a base class break huge pieces of an application.&lt;/p&gt;  &lt;p&gt;Now let’s consider using delegation rather than inheritance.&amp;#160; We will change our class diagram to look like the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SzZBrffRmbI/AAAAAAAAAJw/S3VG5ZSW3G0/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SzZBryU69rI/AAAAAAAAAJ0/HEzlcN14Zvs/image_thumb%5B5%5D.png?imgmax=800" width="419" height="395" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We can say a teacher &lt;strong&gt;&lt;em&gt;Has A&lt;/em&gt;&lt;/strong&gt; person and similarly student &lt;strong&gt;&lt;em&gt;Has A&lt;/em&gt;&lt;/strong&gt; person.&lt;/p&gt;  &lt;p&gt;The down-side of this design is that we have to write more code to create and manage the person class and thus the code will not perform as well (though in most cases I suspect the performance hit is negligible).&amp;#160; We also cannot use polymorphism - we cannot treat a student as a person and we cannot treat a teacher as a person.&amp;#160; The up-side of this design is that we can decrease coupling by defining a person interface and using the interface as the return type for our Person property rather than the concrete Person class, and our design is more robust.&amp;#160; When we use delegation we can have a single instance of a person act as both a student and a teacher.&amp;#160; Try that in C# using the inheritance design!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ab446493-baef-4d37-98a8-4ff400cc0cb6" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Design+Review" rel="tag"&gt;Design Review&lt;/a&gt;,&lt;a href="http://technorati.com/tags/inheritance" rel="tag"&gt;inheritance&lt;/a&gt;,&lt;a href="http://technorati.com/tags/delegation+c%23+code+review" rel="tag"&gt;delegation c# code review&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-7402122800375442634?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/7402122800375442634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-delegation-vs.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7402122800375442634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7402122800375442634'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-delegation-vs.html' title='Design Review and Delegation Vs. Inheritance'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_04HDQqptby8/SzZBqz_W0qI/AAAAAAAAAJs/zFXGVgk0jkI/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-1294059022017729025</id><published>2009-12-12T10:53:00.001-06:00</published><updated>2009-12-12T10:53:10.382-06:00</updated><title type='text'>Design Review and the DRY Principle</title><content type='html'>&lt;p&gt;DRY in the DRY principle is an acronym for Don’t Repeat Yourself.&amp;#160; While we are going to focus on applying the principle to code, it can and should be applied to more than just code.&amp;#160; The can be applied to database schemas, tests, documentation, test plans, design documents, build scripts and more.&amp;#160; Any time we start duplicating our work we are signing up for parallel maintenance and chances are we will eventually have the items fall out of synch.&lt;/p&gt;  &lt;p&gt;We can use several techniques to avoid duplicate code.&amp;#160; Some obvious things we can do include using classes and methods to organize common code.&amp;#160; We can write an abstract or base class to implement common behaviors for multiple derived classes.&amp;#160; &lt;/p&gt;  &lt;p&gt;We can use properties to perform a validation in one place rather than performing the validation anywhere we want to use a member variable:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:01b3e2da-514c-490e-90b2-0b208d68f2ce" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;         [System.Diagnostics.&lt;span style="color:#2b91af"&gt;DebuggerBrowsable&lt;/span&gt;(System.Diagnostics.&lt;span style="color:#2b91af"&gt;DebuggerBrowsableState&lt;/span&gt;.Never)]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; aComplexInteger;&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; AComplexInteger&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; aComplexInteger; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;set&lt;/span&gt; &lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;value&lt;/span&gt; == 0)&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ArgumentOutOfRangeException&lt;/span&gt;(&lt;span style="color:#a31515"&gt;"AComplexInteger"&lt;/span&gt;);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;value&lt;/span&gt; != aComplexInteger)&lt;/li&gt;&lt;li&gt;                 {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     aComplexInteger = &lt;span style="color:#0000ff"&gt;value&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#008000"&gt;//Maybe raise a value changed event&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 }&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;One of my favorite techniques is constructor chaining.&amp;#160; If we have multiple constructors that perform similar logic , we should use constructor chaining to avoid duplicating code:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:abde1529-d930-4541-a9b4-b51d1a7c3836" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CicMaster&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BetterConstructorLogic&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; WhyItIsBetter&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#008000"&gt;//No duplicate code, this is called constructor chaining&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#008000"&gt;//step through this&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; someString = &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Empty;&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; someInteger = 0;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;&amp;gt; myIntegers = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;&amp;gt;();&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; BetterConstructorLogic():&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;(&lt;span style="color:#a31515"&gt;"A Default Value"&lt;/span&gt;)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//someString = "A Default Value";&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             System.Diagnostics.&lt;span style="color:#2b91af"&gt;Debug&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;"In Default Constructor"&lt;/span&gt;);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; BetterConstructorLogic(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; aString):&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;(aString,123)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//someInteger = 123;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             System.Diagnostics.&lt;span style="color:#2b91af"&gt;Debug&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;"In one param constructor"&lt;/span&gt;);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; BetterConstructorLogic(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; aString, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; anInteger)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             System.Diagnostics.&lt;span style="color:#2b91af"&gt;Debug&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515"&gt;"In two param constructor"&lt;/span&gt;);&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             someString = aString;&lt;/li&gt;&lt;li&gt;             someInteger = anInteger;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             myIntegers.Add(someInteger);&lt;/li&gt;&lt;li&gt;             myIntegers.Add(someInteger ^ 3);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             myIntegers.Add((&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)(2 * 3.14 * someInteger));&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The final technique I would like to mention is use a factory to create all but the simplest objects.&amp;#160; The following (admittedly nonsensical) code needs to execute maybe a half dozen lines of code to construct an Order object.&amp;#160; &lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a82db611-b7ad-47db-8d88-fdc6ffce509d" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Threading;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; BusinessLayer&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; {&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObjectContext&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; ObjectContext(&lt;span style="color:#2b91af"&gt;String&lt;/span&gt; username)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//Look up the user permissions&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; IsInTranaction { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; BeginTransaction()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//do some transaction logic&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Order&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Order(&lt;span style="color:#2b91af"&gt;ObjectContext&lt;/span&gt; theContext)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Consumer&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Consumer()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#2b91af"&gt;ObjectContext&lt;/span&gt; ctx = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObjectContext&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;Thread&lt;/span&gt;.CurrentPrincipal.Identity.Name);&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!ctx.IsInTranaction)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (ctx.BeginTransaction())&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 {&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#008000"&gt;//...&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 }&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#2b91af"&gt;Order&lt;/span&gt; order = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Order&lt;/span&gt;(ctx);&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Duplicating these few lines of code in a couple places is not that difficult.&amp;#160; Now say the application is enhanced and grows for a few years and suddenly we see this code duplicated dozens or hundreds of times.&amp;#160; At some point it is likely that we want to change the construction logic, finding and changing all the code we use to create the order is difficult, time consuming, and a QA burden.&amp;#160; &lt;/p&gt;  &lt;p&gt;A better approach would be to encapsulate the logic required to build a new order.&amp;#160; Here is an implementation using a simple factory.&amp;#160; It is much easier to find, change, and test this code:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:721384be-eb0a-496a-b64e-68e383e25197" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;OrderFactory&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Order&lt;/span&gt; GetOrder()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#2b91af"&gt;ObjectContext&lt;/span&gt; ctx = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObjectContext&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;Thread&lt;/span&gt;.CurrentPrincipal.Identity.Name);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!ctx.IsInTranaction)&lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (ctx.BeginTransaction())&lt;/li&gt;&lt;li&gt;                 {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#008000"&gt;//...&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Order&lt;/span&gt;(ctx);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DryConsumer&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; DryConsumer()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#2b91af"&gt;Order&lt;/span&gt; order = &lt;span style="color:#2b91af"&gt;OrderFactory&lt;/span&gt;.GetOrder();&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;If we recognize that we are duplicating even a few lines of code over and over we need to take a serious look at the code and figure out a way to encapsulate the logic.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html"&gt;My design review checklist&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f5b93235-06dd-4ff1-8f79-1480e2781c07" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/DRY" rel="tag"&gt;DRY&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Design+Review" rel="tag"&gt;Design Review&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Agile+principles" rel="tag"&gt;Agile principles&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Don't+Repeat+Yourself" rel="tag"&gt;Don't Repeat Yourself&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-1294059022017729025?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/1294059022017729025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-dry-principle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/1294059022017729025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/1294059022017729025'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-dry-principle.html' title='Design Review and the DRY Principle'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-3581754519329434323</id><published>2009-11-27T17:34:00.001-06:00</published><updated>2010-07-05T21:04:23.224-05:00</updated><title type='text'>Silverlight 3, the CollectionViewSource and sorting</title><content type='html'>&lt;p&gt;In my &lt;a href="https://blogadmin.intertech.com/Blog/post/Silverlight-3-and-the-CollectionViewSource.aspxhtml" target="_blank"&gt;previous post&lt;/a&gt; we were introduced to the CollectionViewSource. We have multiple ItemSources binding to the same collection using a CollectionViewSource – very powerful.&amp;#160; Now what if we want to sort the items displayed in one of our grid cells?&amp;#160; We will focus on row one and column one for the rest of this post.&lt;/p&gt;  &lt;p&gt;I’ve added some more default data to the Control’s constructor to make things a little more interesting and also notice I have added a few buttons to the bottom of our control:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/SxBiC2SyUHI/AAAAAAAAAJA/Q60bYop9yoY/s1600-h/image%5B7%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SxBiDSz6T3I/AAAAAAAAAJE/utngqtsR1mo/image_thumb%5B3%5D.png?imgmax=800" width="244" height="139" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Sort by Name button adds a sort description to the CollectionViewSource&lt;/p&gt;  &lt;p&gt;theDataContext[0].Column1.View.SortDescriptions.Add(new SortDescription(&amp;quot;SomeName&amp;quot;,ListSortDirection.Ascending)); &lt;/p&gt;  &lt;p&gt;This code tells the CollectionViewSource to sort the items in it’s view by the SomeName property in ascending order.&amp;#160; Click the button and we see the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SxBiDnL2dbI/AAAAAAAAAJI/-L68McnJWxs/s1600-h/image%5B12%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/SxBiD9PnmoI/AAAAAAAAAJM/lXZqMhBYuzE/image_thumb%5B6%5D.png?imgmax=800" width="183" height="314" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click the Clear Sort Descriptions button.&lt;/p&gt;  &lt;p&gt;The Sort By Value button tells the CollectionViewSource to sort the items in the view by the SomeValue Property in ascending order.&lt;/p&gt;  &lt;p&gt;theDataContext[0].Column1.View.SortDescriptions.Add(new SortDescription(&amp;quot;SomeValue&amp;quot;, ListSortDirection.Ascending)); &lt;/p&gt;  &lt;p&gt;Click the button to see the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SxBiEBP4ZGI/AAAAAAAAAJQ/W7PGMEAsNk4/s1600-h/image%5B17%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SxBiEeTv60I/AAAAAAAAAJU/aLtwEvm8LU0/image_thumb%5B9%5D.png?imgmax=800" width="170" height="320" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This time our list is sorted by the SomeValue property.&lt;/p&gt;  &lt;p&gt;Where things get interesting is that you can add multiple sort descriptions.&amp;#160; Try clearing the filter, then adding the name and value filter (in that order) and we see the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/SxBiEjoXzKI/AAAAAAAAAJY/ZCyXvH4sBIQ/s1600-h/image%5B22%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/SxBiFLgqI9I/AAAAAAAAAJc/YGZ_MCC1NF8/image_thumb%5B12%5D.png?imgmax=800" width="149" height="319" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The collection is first sorted by name, then by value.&lt;/p&gt;  &lt;p&gt;Clear the filter and click the Value, then name button and we see this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SxBiFWEDd-I/AAAAAAAAAJg/JYWvwGtbbVc/s1600-h/image%5B28%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SxBiFm9lHxI/AAAAAAAAAJk/7GatL1cfL68/image_thumb%5B16%5D.png?imgmax=800" width="186" height="321" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The collection is first sorted by SomeValue, then by SomeName. &lt;/p&gt;  &lt;p&gt;The order is important!&amp;#160; If you want to add a sort description to the top of the sort order, simply use the Insert method as follows:&lt;/p&gt;  &lt;p&gt;theDataContext[0].Column1.View.SortDescriptions.Insert(0,new SortDescription(&amp;quot;SomeValue&amp;quot;, ListSortDirection.Ascending));&lt;/p&gt;  &lt;p&gt;Here is the modified XAML:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4aa4656f-a75a-43be-aece-2be512e084ef" class="wlWriterSmartContent"&gt;   &lt;br /&gt;    &lt;div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid"&gt;     &lt;br /&gt;      &lt;div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px"&gt;Code Snippet&lt;/div&gt;      &lt;br /&gt;      &lt;div style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; background: #ddd; max-height: 300px; overflow: scroll; padding-top: 0px"&gt;       &lt;br /&gt;        &lt;ol style="margin: 0px 0px 0px 35px; white-space: nowrap; background: #ffffff"&gt;         &lt;br /&gt;          &lt;li&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl&lt;/span&gt;&lt;span style="color: #ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;SilverlightApplication1.MainPage&amp;quot;&lt;/span&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt; &lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;d&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/expression/blend/2008&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;mc&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt; &lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160; &lt;span style="color: #ff0000"&gt;mc&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Ignorable&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;d&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; d&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;DesignWidth&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;640&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; d&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;DesignHeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;480&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: #ff0000"&gt; TargetType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Button&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;FontSize&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;9&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LayoutRoot&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ScrollViewer&lt;/span&gt;&lt;span style="color: #ff0000"&gt; VerticalScrollBarVisibility&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Auto&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Vertical&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGrid&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;TheMainDataGrid&amp;quot;&lt;/span&gt;&amp;#160; &lt;span style="color: #ff0000"&gt; AutoGenerateColumns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;False&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;}&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; HeadersVisibility&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Column&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGrid.Columns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Header&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Column 1&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color: #ff0000"&gt; MinHeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;15&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Path&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=Column1.View}&amp;quot; &amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Orientation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Horizontal&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Path&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=SomeName}&amp;quot; /&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000"&gt; SomeValue&lt;/span&gt;&lt;span style="color: #0000ff"&gt;}&amp;quot; /&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Header&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Column 2&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color: #ff0000"&gt; MinHeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;15&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Path&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=Column2.View}&amp;quot; &amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Horizontal&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000"&gt; SomeName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;}&amp;quot; /&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000"&gt; SomeValue&lt;/span&gt;&lt;span style="color: #0000ff"&gt;}&amp;quot; /&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGrid.Columns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;data&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataGrid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Horizontal&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Left&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Name:&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;tbNAme&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;100&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;100&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Value:&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;tbValue&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;100&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AddButton&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Add&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AddButton_Click&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Left&amp;quot;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ChangeNameButton&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Change Name&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ChangeNameButton_Click&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ChangeValueButton&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Change Value&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ChangeValueButton_Click&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;refresh&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Refresh CVS&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;refresh_Click&amp;quot; /&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AddNameSort&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Sort by Name&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AddNameSort_Click&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AddValueSort&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Sort by Value&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AddValueSort_Click&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ClearSort&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Clear Sort Descriptions&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Click&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ClearSort_Click&amp;quot;/&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ScrollViewer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;           &lt;span style="color: #a31515"&gt;&amp;#160; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li style="background: #f3f3f3"&gt;&amp;lt;/&lt;/li&gt;           &lt;span style="color: #a31515"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;li&gt;&lt;/li&gt;            &lt;br /&gt;&lt;/li&gt;       &lt;/ol&gt;        &lt;br /&gt;&lt;/div&gt;      &lt;br /&gt;&lt;/div&gt;    &lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Here is the modified code behind:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:74f499cc-8323-41b7-bcba-91e34e4b2d3c" class="wlWriterSmartContent"&gt;   &lt;br /&gt;    &lt;div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid"&gt;     &lt;br /&gt;      &lt;div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px"&gt;Code Snippet&lt;/div&gt;      &lt;br /&gt;      &lt;div style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; background: #ddd; max-height: 300px; overflow: scroll; padding-top: 0px"&gt;       &lt;br /&gt;        &lt;ol style="margin: 0px 0px 0px 45px; white-space: nowrap; background: #ffffff"&gt;         &lt;br /&gt;          &lt;li&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Collections.ObjectModel;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/li&gt;          &lt;li&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows.Data;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; SilverlightApplication1&lt;/li&gt;          &lt;li&gt;{&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;MainPage&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;UserControl&lt;/span&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;&amp;gt; theMainCollection ;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;TheRowClass&lt;/span&gt;&amp;gt; theDataContext;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent();&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theMainCollection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;&amp;gt;()&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;A&amp;quot;&lt;/span&gt;,SomeValue=11},&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;A&amp;quot;&lt;/span&gt;,SomeValue=12},&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;A&amp;quot;&lt;/span&gt;,SomeValue=10},&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;AB&amp;quot;&lt;/span&gt;,SomeValue=21},&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;A&amp;quot;&lt;/span&gt;,SomeValue=13},&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;B&amp;quot;&lt;/span&gt;,SomeValue=13},&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;B&amp;quot;&lt;/span&gt;,SomeValue=14},&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;AB&amp;quot;&lt;/span&gt;,SomeValue=11},&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;BC&amp;quot;&lt;/span&gt;,SomeValue=22},&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;AB&amp;quot;&lt;/span&gt;,SomeValue=23},&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color: #a31515"&gt;&amp;quot;BC&amp;quot;&lt;/span&gt;,SomeValue=24}&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;TheRowClass&lt;/span&gt;&amp;gt;();&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TheRowClass&lt;/span&gt;(theMainCollection));&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TheRowClass&lt;/span&gt;(theMainCollection));&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TheMainDataGrid.DataContext = theDataContext;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AddFilter(theDataContext[0].Column1, 1, 1);&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AddFilter(theDataContext[0].Column2, 1, 2);&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AddFilter(theDataContext[1].Column1, 2, 1);&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AddFilter(theDataContext[1].Column2, 2, 2);&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddFilter(&lt;span style="color: #2b91af"&gt;CollectionViewSource&lt;/span&gt; cvs, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; row, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; column)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cvs.Filter += &lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; o, &lt;span style="color: #2b91af"&gt;FilterEventArgs&lt;/span&gt; eArgs)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;//Simple filter saying if column = 1 look for an A in the SomeName property&lt;/span&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;//Else look for a B.&amp;#160; If we are in Row 1 look for a 1 in the SomeValue property&lt;/span&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;//Else look for a 2&lt;/span&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; columnFilter;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (row == 1)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; columnFilter = &lt;span style="color: #a31515"&gt;&amp;quot;A&amp;quot;&lt;/span&gt;;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; columnFilter = &lt;span style="color: #a31515"&gt;&amp;quot;B&amp;quot;&lt;/span&gt;;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((eArgs.Item &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;).SomeValue.ToString().Contains(column.ToString()) &amp;amp;&amp;amp; (eArgs.Item &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;).SomeName.Contains(columnFilter))&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; eArgs.Accepted = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; eArgs.Accepted = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddButton_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt; tc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TestClass&lt;/span&gt;();&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; tc.SomeName = tbNAme.Text;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; tc.SomeValue = &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;.Parse(tbValue.Text);&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theMainCollection.Add(tc);&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ChangeNameButton_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theMainCollection[theMainCollection.Count-1].SomeName = &lt;span style="color: #a31515"&gt;&amp;quot;B&amp;quot;&lt;/span&gt;;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ChangeValueButton_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theMainCollection[theMainCollection.Count - 1].SomeValue = 25;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; refresh_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[0].Column1.View.Refresh();&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[1].Column1.View.Refresh();&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[0].Column2.View.Refresh();&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[1].Column2.View.Refresh();&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddNameSort_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[0].Column1.View.SortDescriptions.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SortDescription&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;SomeName&amp;quot;&lt;/span&gt;,&lt;span style="color: #2b91af"&gt;ListSortDirection&lt;/span&gt;.Ascending));&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddValueSort_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[0].Column1.View.SortDescriptions.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SortDescription&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;SomeValue&amp;quot;&lt;/span&gt;, &lt;span style="color: #2b91af"&gt;ListSortDirection&lt;/span&gt;.Ascending));&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li&gt;&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ClearSort_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color: #2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; theDataContext[0].Column1.View.SortDescriptions.Clear();&lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/li&gt;          &lt;li&gt;}&lt;/li&gt;          &lt;li style="background: #f3f3f3"&gt;           &lt;br /&gt;&lt;/li&gt;       &lt;/ol&gt;        &lt;br /&gt;&lt;/div&gt;      &lt;br /&gt;&lt;/div&gt;    &lt;br /&gt;&lt;/div&gt;  &lt;p&gt;See my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/11/silverlight-3-and-collectionviewsource.html" target="_blank"&gt;previous post&lt;/a&gt; to get the supporting code.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0ff26bf2-6576-40b2-9b6b-2dbd9d3910fa" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Silverlight+3" rel="tag"&gt;Silverlight 3&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CollectionViewSource" rel="tag"&gt;CollectionViewSource&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ObservableCollection" rel="tag"&gt;ObservableCollection&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DataGrid" rel="tag"&gt;DataGrid&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SortDescription" rel="tag"&gt;SortDescription&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-3581754519329434323?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/3581754519329434323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/11/collectionviewsource-and-sorting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3581754519329434323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3581754519329434323'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/11/collectionviewsource-and-sorting.html' title='Silverlight 3, the CollectionViewSource and sorting'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_04HDQqptby8/SxBiDSz6T3I/AAAAAAAAAJE/utngqtsR1mo/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-4856220161321988346</id><published>2009-11-23T20:55:00.001-06:00</published><updated>2009-11-27T17:38:22.240-06:00</updated><title type='text'>Silverlight 3 and the CollectionViewSource</title><content type='html'>&lt;p&gt;I have been working on a really cool Silverlight application for the last several weeks.&amp;#160; The application is a graphically intensive businesses application with some pretty challenging lists nested in a grid and some very cool drag and drop functionality.&amp;#160; Here is the scenario:&amp;#160; &lt;/p&gt;  &lt;p&gt;When the app starts up we make a call to a WCF service and get several hundred to several thousand objects back in an observable Collection.&amp;#160; We slice, dice, and manipulate the ObservableCollection&amp;lt;T&amp;gt; and now the challenge is we have to present several dozen to several hundred different views into this same data.&amp;#160; Throwing several hundred different views of the same data at a user all at once is not particularly useful so the views are stored in cells of a scrollable grid.&amp;#160; As I mentioned, each cell in the grid is a list of items that needs to be generated based on some attributes of the column and row in the grid.&amp;#160; Conceptually I want to break my original collection into a bunch of smaller collections but I didn’t want to physically break the collection&amp;#160; into multiple collections because the drag and drop functionality I spoke of would force me to get into the business of removing an item from one collection and adding it to another.&amp;#160; Additionally once the items are placed where we want them I would have to reassemble the master collection and send it back to the server.&amp;#160; Using a single ObservableCollection&amp;lt;T&amp;gt;) collection is a good fit.&amp;#160; How do we get multiple independent views into this ObservableCollection&amp;lt;T&amp;gt;) ?&amp;#160; &lt;/p&gt;  &lt;p&gt;Enter the CollectionViewSource.&amp;#160; The CollectionViewSource allows us to set a source property (in our case the ObservableCollection&amp;lt;T&amp;gt; we got from the WCF call) then set one or many filters and finally we bind each cell to the View property of the CollectionViewSource to allow us to get a list of objects that satisfy our filter criteria. &lt;/p&gt;  &lt;p&gt;Let’s whip up a very simple application and demonstrate the behavior.&amp;#160; &lt;/p&gt;  &lt;p&gt;Here is the screen:&amp;#160; We have a grid with 2 rows and 2 columns.&amp;#160; Each Cell represents a list of type TestClass.&amp;#160; TestClass has two properties, SomeName – a string property, and SomeValue an integer property.&amp;#160; Below the grid we have two text boxes and and add button.&amp;#160; This will allow us to demonstrate that we can add items to the observable collection and have the UI automatically update.&amp;#160; Ignore the bottom 3 buttons for the moment.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/SwtLFiQVP0I/AAAAAAAAAIc/rF35_nNaKjc/s1600-h/image%5B7%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SwtLGCAmtJI/AAAAAAAAAIg/p95QhTAz8ek/image_thumb%5B3%5D.png?imgmax=800" width="424" height="422" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Rather than make a WCF call we are building the “Main” collection of objects&amp;#160; in the MainPage constructor:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c2a1974e-74a1-4f68-af42-dbb966797101" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;             theMainCollection = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;&amp;gt;()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 { &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"A"&lt;/span&gt;,SomeValue=11},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"A"&lt;/span&gt;,SomeValue=12},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;,SomeValue=13},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;,SomeValue=14},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"AB"&lt;/span&gt;,SomeValue=21},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"BC"&lt;/span&gt;,SomeValue=22},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"AB"&lt;/span&gt;,SomeValue=23},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"BC"&lt;/span&gt;,SomeValue=24}&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 };&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Now we need to create a collection for the grid to bind to.&amp;#160; Remember, what we want is for each grid cell to be a view into our “main” collection.&amp;#160; In our Example we are using a DataGrid object to display our views and we want the DataGrid to automatically update if we add an object to or remove an object from the main collection .&amp;#160; What we need here is an ObeservableCollection of objects with a CollectionViewSource property for each column.&amp;#160; In our example we have called the object TheRowClass. TheRowClass has two properties of type CollectionViewSource; Column1 and Column2.&lt;/p&gt;  &lt;p&gt;Here is the code I use to initialize the ObservableCollection&amp;lt;TheRowClass&amp;gt;:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:99bc3c29-3f79-41d3-ae84-9e3f1affd253" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 25px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;             theDataContext = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;&amp;gt;();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theDataContext.Add(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;(theMainCollection));&lt;/li&gt;&lt;li&gt;             theDataContext.Add(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;(theMainCollection));&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;We have two items in the ObservableCollection&amp;lt;TheRowClass&amp;gt;, each item has two properties of type CollectionViewSource for a total of four CollectionViewSource objects – one for each cell.&amp;#160; We are passing the main collection into the constructor and using it as the Source property for all of our CollectionViewSources.&amp;#160; All we have left to do is add a filter to each of these collections.&amp;#160; The filter we are adding is very simple: &lt;/p&gt;  &lt;p&gt;if TestClass.SomeName contains the letter A and TestClass.SomeValue contains the number 1 display the item in row 1, column 1&lt;/p&gt;  &lt;p&gt;if TestClass.SomeName contains the letter A and TestClass.SomeValue contains the number 2 display the item in row 1, column 2&lt;/p&gt;  &lt;p&gt;if TestClass.SomeName contains the letter B and TestClass.SomeValue contains the number 1 display the item in row 2, column 1&lt;/p&gt;  &lt;p&gt;if TestClass.SomeName contains the letter B and TestClass.SomeValue contains the number 2 display the item in row 2, column 2&lt;/p&gt;  &lt;p&gt;Here is the code to pull that off:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7679930d-5d98-4f22-b26d-0a855625ac1b" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 25px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;             AddFilter(theDataContext[0].Column1, 1, 1);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             AddFilter(theDataContext[0].Column2, 1, 2);&lt;/li&gt;&lt;li&gt;             AddFilter(theDataContext[1].Column1, 2, 1);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             AddFilter(theDataContext[1].Column2, 2, 2);&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;And the AddFilter method:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e7ed9f5-1949-42bf-9072-bcc7ac7917b1" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; AddFilter(&lt;span style="color:#2b91af"&gt;CollectionViewSource&lt;/span&gt; cvs, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; row, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; column)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             cvs.Filter += &lt;span style="color:#0000ff"&gt;delegate&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; o, &lt;span style="color:#2b91af"&gt;FilterEventArgs&lt;/span&gt; eArgs)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#008000"&gt;//Simple filter saying if column = 1 look for an A in the SomeName property&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#008000"&gt;//Else look for a B.  If we are in Row 1 look for a 1 in the SomeValue property&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#008000"&gt;//Else look for a 2&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; columnFilter;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (row == 1)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     columnFilter = &lt;span style="color:#a31515"&gt;"A"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     columnFilter = &lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; ((eArgs.Item &lt;span style="color:#0000ff"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;).SomeValue.ToString().Contains(column.ToString()) &amp;amp;&amp;amp; (eArgs.Item &lt;span style="color:#0000ff"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;).SomeName.Contains(columnFilter))&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     eArgs.Accepted = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     eArgs.Accepted = &lt;span style="color:#0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;             };&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Run the app, notice that the item with SomeName=’AB’ and SomeValue=21 is in all of the cells, this is because that item satisfies the filter criteria for each CollectionViewSource in each cell.&amp;#160; Very cool.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Add the letter ‘A’ to the first textbox and 111 to the second textbox and click the add button.&amp;#160; Notice that an item is added to column 1 and row 1 of the grid without doing anything more than making a call to Collection.Add. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SwtLGYFEw1I/AAAAAAAAAIo/GwktCXYiRfo/s1600-h/image%5B15%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SwtLG6X7nUI/AAAAAAAAAIs/BeUgVK-vG2o/image_thumb%5B7%5D.png?imgmax=800" width="161" height="321" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Play around with a few more combinations and see how the grid updates.&lt;/p&gt;  &lt;p&gt;Now let’s look at the bottom 3 buttons, the first button changes the SomeName value of the last item in the main collection to “B”.&amp;#160; Here is the event handler:&lt;/p&gt;  &lt;p&gt;theMainCollection[theMainCollection.Count-1].SomeName = &amp;quot;B&amp;quot;;&lt;/p&gt;  &lt;p&gt;Again, add the letter ‘A’ to the first textbox and 111 to the second textbox and click the add button.&amp;#160; Now click the Change Name button.&amp;#160; Notice that nothing happens.&amp;#160; I assure The item has changed.&lt;/p&gt;  &lt;p&gt;Now click the Change Value button.&amp;#160; Notice that the last item in row 1 cell 1 has changed, the value has become 25. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/SwtLHNuACqI/AAAAAAAAAIw/CoPHv6saX74/s1600-h/image%5B14%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SwtLHigEwDI/AAAAAAAAAI0/LqtvLkjkkiU/image_thumb%5B6%5D.png?imgmax=800" width="155" height="316" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We changed the SomeValue property to 25 in the button click event handler.&amp;#160;&amp;#160; Here is the event handler:&lt;/p&gt;  &lt;p&gt;theMainCollection[theMainCollection.Count - 1].SomeValue = 25;&lt;/p&gt;  &lt;p&gt;Why did SomeValue change while SomeName remained the same?&amp;#160; Take a look at the TestClass and you will notice that it implements the INotifyPropertyChanged interface and in the SomeValue setter we call NotifyPropertyChanged which raises an event.&amp;#160; Silverlight has a Pub/Sub eventing system that the UI uses to determine when to update databound objects.&amp;#160; With just a few lines of code we were able to wire TestClass into this eventing system and force the UI to update anytime our SomeValue property changes.&lt;/p&gt;  &lt;p&gt;This is all fine and good, call that event for SomeName and we are good to go, well…almops.&amp;#160; We still have a problem with the UI!&amp;#160; The last item in cell 1 column 1 is displaying an incorrect SomeName value, and since we changed SomeValue to 25 it should no longer be visible in this cell.&amp;#160; What is happening is that the Filter on the collection view source is applied when an item is added to or removed from the collection but NOT when an item changes.&amp;#160; To manually reapply the filter call CollectionViewSource.View.Refresh (for each CollectionViewSource) and you will see the grid display correctly.&amp;#160; Click the Refresh CVS button to see this functionality in action:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/SwtLHzepnvI/AAAAAAAAAI4/sbcWVPB09_k/s1600-h/image%5B19%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SwtLIW3gY2I/AAAAAAAAAI8/jQDst92qys0/image_thumb%5B9%5D.png?imgmax=800" width="163" height="357" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Below is all of the source code.&lt;/p&gt;  &lt;p&gt;Click &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/11/collectionviewsource-and-sorting.html" target="_blank"&gt;here&lt;/a&gt; to see how to sort the grid cells.&lt;/p&gt;  &lt;p&gt;Here is the XAML:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56a8544d-1a6a-410e-be5d-839b512ed5f3" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;UserControl&lt;/span&gt;&lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"&lt;/span&gt; &lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="SilverlightApplication1.MainPage"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;mc&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;    &lt;span style="color:#ff0000"&gt; mc&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Ignorable&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="d"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;DesignWidth&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="640"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;DesignHeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="480"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;  &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="LayoutRoot"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Vertical"&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGrid&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="TheMainDataGrid"&lt;/span&gt;  &lt;span style="color:#ff0000"&gt; AutoGenerateColumns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="False"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; HeadersVisibility&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Column"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGrid.Columns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Header&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Column 1"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; MinHeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="15"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=Column1.View}" &amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Horizontal"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="10"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=SomeName}" /&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="10"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; SomeValue&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}" /&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Header&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Column 2"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; MinHeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="15"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=Column2.View}" &amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Horizontal"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="10"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; SomeName&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}" /&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="10"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; SomeValue&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}" /&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;ListBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGrid.Columns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;data&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;DataGrid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Horizontal"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Left"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="5"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Name:"/&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="tbNAme"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="5"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="5"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Value:"/&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="tbValue"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="5"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="AddButton"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="5"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Add"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="AddButton_Click"/&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Left"&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="ChangeNameButton"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Change Name"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="ChangeNameButton_Click"/&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="ChangeValueButton"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Change Value"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="ChangeValueButton_Click"/&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="refresh"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Refresh CVS"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="refresh_Click" /&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;  &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;UserControl&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Here is the code behind:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:17dbc0a2-80fc-44ab-b54e-ca9492a393b3" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.ObjectModel;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows.Data;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; SilverlightApplication1&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; {&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MainPage&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;UserControl&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;&amp;gt; theMainCollection ;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;&amp;gt; theDataContext;&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             InitializeComponent();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theMainCollection = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;&amp;gt;()&lt;/li&gt;&lt;li&gt;                 { &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"A"&lt;/span&gt;,SomeValue=11},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"A"&lt;/span&gt;,SomeValue=12},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;,SomeValue=13},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;,SomeValue=14},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"AB"&lt;/span&gt;,SomeValue=21},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"BC"&lt;/span&gt;,SomeValue=22},&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"AB"&lt;/span&gt;,SomeValue=23},&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;() {SomeName=&lt;span style="color:#a31515"&gt;"BC"&lt;/span&gt;,SomeValue=24}&lt;/li&gt;&lt;li&gt;                 };&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;            &lt;/li&gt;&lt;li&gt;             theDataContext = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;&amp;gt;();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theDataContext.Add(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;(theMainCollection));&lt;/li&gt;&lt;li&gt;             theDataContext.Add(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;(theMainCollection));&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;             TheMainDataGrid.DataContext = theDataContext;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             AddFilter(theDataContext[0].Column1, 1, 1);&lt;/li&gt;&lt;li&gt;             AddFilter(theDataContext[0].Column2, 1, 2);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             AddFilter(theDataContext[1].Column1, 2, 1);&lt;/li&gt;&lt;li&gt;             AddFilter(theDataContext[1].Column2, 2, 2);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; AddFilter(&lt;span style="color:#2b91af"&gt;CollectionViewSource&lt;/span&gt; cvs, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; row, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; column)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             cvs.Filter += &lt;span style="color:#0000ff"&gt;delegate&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; o, &lt;span style="color:#2b91af"&gt;FilterEventArgs&lt;/span&gt; eArgs)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#008000"&gt;//Simple filter saying if column = 1 look for an A in the SomeName property&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#008000"&gt;//Else look for a B.  If we are in Row 1 look for a 1 in the SomeValue property&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#008000"&gt;//Else look for a 2&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; columnFilter;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (column == 1)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     columnFilter = &lt;span style="color:#a31515"&gt;"A"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     columnFilter = &lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; ((eArgs.Item &lt;span style="color:#0000ff"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;).SomeValue.ToString().Contains(column.ToString()) &amp;amp;&amp;amp; (eArgs.Item &lt;span style="color:#0000ff"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;).SomeName.Contains(columnFilter))&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     eArgs.Accepted = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     eArgs.Accepted = &lt;span style="color:#0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;             };&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; AddButton_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt; tc = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             tc.SomeName = tbNAme.Text;&lt;/li&gt;&lt;li&gt;             tc.SomeValue = &lt;span style="color:#0000ff"&gt;int&lt;/span&gt;.Parse(tbValue.Text);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theMainCollection.Add(tc);&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ChangeNameButton_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             theMainCollection[theMainCollection.Count-1].SomeName = &lt;span style="color:#a31515"&gt;"B"&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ChangeValueButton_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theMainCollection[theMainCollection.Count - 1].SomeValue = 25;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; refresh_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             theDataContext[0].Column1.View.Refresh();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theDataContext[1].Column1.View.Refresh();&lt;/li&gt;&lt;li&gt;             theDataContext[0].Column2.View.Refresh();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             theDataContext[1].Column2.View.Refresh();&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Here is the TestClass Code:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ef41eff2-fd42-4c8f-a41c-0e38aff4a3a4" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; SilverlightApplication1&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;:&lt;span style="color:#2b91af"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;String&lt;/span&gt; SomeName { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; _someValue;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; SomeValue&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; _someValue;&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;value&lt;/span&gt; != &lt;span style="color:#0000ff"&gt;this&lt;/span&gt;._someValue)&lt;/li&gt;&lt;li&gt;                 {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;this&lt;/span&gt;._someValue = &lt;span style="color:#0000ff"&gt;value&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                     NotifyPropertyChanged(&lt;span style="color:#a31515"&gt;"SomeValue"&lt;/span&gt;);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 }&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; INotifyPropertyChanged Members&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;event&lt;/span&gt; &lt;span style="color:#2b91af"&gt;PropertyChangedEventHandler&lt;/span&gt; PropertyChanged;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; NotifyPropertyChanged(&lt;span style="color:#2b91af"&gt;String&lt;/span&gt; info)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (PropertyChanged != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 PropertyChanged(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;PropertyChangedEventArgs&lt;/span&gt;(info));&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Here is TheRowClass:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c41a9b03-ce1b-450e-8a04-91aca155de87" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 300px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows.Data;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; SilverlightApplication1&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;TheRowClass&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; TheRowClass(&lt;span style="color:#2b91af"&gt;IEnumerable&lt;/span&gt; source)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             Column1 = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CollectionViewSource&lt;/span&gt;();&lt;/li&gt;&lt;li&gt;             Column1.Source = source;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             Column2 = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CollectionViewSource&lt;/span&gt;();&lt;/li&gt;&lt;li&gt;             Column2.Source = source;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CollectionViewSource&lt;/span&gt; Column1 { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CollectionViewSource&lt;/span&gt; Column2 { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:957650ae-6299-4ec4-8173-3fd1bf71db06" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Silverlight+3" rel="tag"&gt;Silverlight 3&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CollectionViewSource" rel="tag"&gt;CollectionViewSource&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ObservableCollection" rel="tag"&gt;ObservableCollection&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DataGrid" rel="tag"&gt;DataGrid&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-4856220161321988346?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/4856220161321988346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/11/silverlight-3-and-collectionviewsource.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4856220161321988346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4856220161321988346'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/11/silverlight-3-and-collectionviewsource.html' title='Silverlight 3 and the CollectionViewSource'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_04HDQqptby8/SwtLGCAmtJI/AAAAAAAAAIg/p95QhTAz8ek/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-899929587974888243</id><published>2009-10-30T09:43:00.001-05:00</published><updated>2009-10-30T09:43:15.331-05:00</updated><title type='text'>Design and Code Review Checklist - scoping</title><content type='html'>&lt;p&gt;Here is my scoping/access modifier cheat sheet.&lt;/p&gt;  &lt;p&gt;Classes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Public Class - Access is not restricted.&lt;/li&gt;    &lt;li&gt;Private Class - Only valid for nested classes&lt;/li&gt;    &lt;li&gt;Internal Class - only visible to the assembly&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Members:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Private Member - only available to the containing type&lt;/li&gt;    &lt;li&gt;Protected Member - Available to the containing type and anything derived from the containing type.&lt;/li&gt;    &lt;li&gt;Internal Member - available to current assembly.&lt;/li&gt;    &lt;li&gt;Protected Internal Member - Available to current assembly &lt;strong&gt;&lt;em&gt;or&lt;/em&gt;&lt;/strong&gt; anything derived from containing type.&lt;/li&gt;    &lt;li&gt;Public Member - Access is not restricted&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Valid Member Access Modifiers:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Enum - public&lt;/li&gt;    &lt;li&gt;Interface - public&lt;/li&gt;    &lt;li&gt;Class - public, private, internal, protected, protected internal&lt;/li&gt;    &lt;li&gt;Struct - public, private, internal &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Inheritance:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Abstract class - cannot be instantiated. May have abstract and non abstract methods. Derived class must implement all abstract methods.&lt;/li&gt;    &lt;li&gt;Sealed Class - Cannot be inherited&lt;/li&gt;    &lt;li&gt;Virtual Method - may be overridden&lt;/li&gt;    &lt;li&gt;Abstract method - no implementation, must be overridden&lt;/li&gt;    &lt;li&gt;Sealed method - Cannot be overridden&lt;/li&gt;    &lt;li&gt;Sealed Override Method - No longer may be overridden. Public sealed override MyMeth()&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;(&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html"&gt;My design review checklist&lt;/a&gt;)&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:746642f5-d888-4a45-a394-0db3b23ec487" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Design+review" rel="tag"&gt;Design review&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Architecture" rel="tag"&gt;Architecture&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Agile+principles" rel="tag"&gt;Agile principles&lt;/a&gt;,&lt;a href="http://technorati.com/tags/YAGNI" rel="tag"&gt;YAGNI&lt;/a&gt;,&lt;a href="http://technorati.com/tags/c%23+coding+standards" rel="tag"&gt;c# coding standards&lt;/a&gt;,&lt;a href="http://technorati.com/tags/code+review" rel="tag"&gt;code review&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-899929587974888243?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/899929587974888243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/design-and-code-review-checklist.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/899929587974888243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/899929587974888243'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/design-and-code-review-checklist.html' title='Design and Code Review Checklist - scoping'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-351516667434576552</id><published>2009-10-30T09:38:00.002-05:00</published><updated>2009-11-09T20:21:44.525-06:00</updated><title type='text'>Design and Code Review – Look at the code.</title><content type='html'>&lt;p&gt;Many things need to be considered when we do a code review (&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html"&gt;My design review checklist&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;Is the code logically correct?&lt;/p&gt;&lt;p&gt;Are we following best practices?&lt;/p&gt;&lt;p&gt;Are we considering security?&lt;/p&gt;&lt;p&gt;Did we run a code review?  If you have a team or enterprise developer edition, the code review may be found in the Analyze menu.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/Sur6gU-RKhI/AAAAAAAAAIU/l45FOmqI9tQ/s1600-h/image%5B3%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Sur6g55SOWI/AAAAAAAAAIY/J0B311QmouU/image_thumb%5B1%5D.png?imgmax=800" width="309" height="171" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Is the code maintainable?&lt;/p&gt;&lt;p&gt;Is our code unnecessarily complex? I always favor simplicity until forced to do otherwise.&lt;/p&gt;&lt;p&gt;Is the error handling effective?&lt;/p&gt;&lt;p&gt;Will our code perform?  I &lt;em&gt;tend&lt;/em&gt; to assume it will until proven otherwise.&lt;/p&gt;&lt;p&gt;Are our objects loosely coupled?&lt;/p&gt;&lt;p&gt;Did we follow our coding standards? idesign has a pretty good C# and WCF coding standard freely available on their website (right hand side).  &lt;a title="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=" href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;amp;tabid=1" tabid="1"&gt;http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;amp;tabid=1&lt;/a&gt;&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:768a36bb-1298-4cc9-84b7-ab08ac6fcbfe" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Design+review" rel="tag"&gt;Design review&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Architecture" rel="tag"&gt;Architecture&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Agile+principles" rel="tag"&gt;Agile principles&lt;/a&gt;,&lt;a href="http://technorati.com/tags/YAGNI" rel="tag"&gt;YAGNI&lt;/a&gt;,&lt;a href="http://technorati.com/tags/c%23+coding+standards" rel="tag"&gt;c# coding standards&lt;/a&gt;,&lt;a href="http://technorati.com/tags/code+review" rel="tag"&gt;code review&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-351516667434576552?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/351516667434576552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/design-and-code-review-look-at-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/351516667434576552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/351516667434576552'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/design-and-code-review-look-at-code.html' title='Design and Code Review – Look at the code.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_04HDQqptby8/Sur6g55SOWI/AAAAAAAAAIY/J0B311QmouU/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-281314878965386447</id><published>2009-10-21T22:35:00.001-05:00</published><updated>2009-10-21T22:35:50.912-05:00</updated><title type='text'>Intertech R&amp;D: Share your thoughts!</title><content type='html'>&lt;p&gt;James White, who oversees R&amp;amp;D at Intertech, is conducting a survey to help define our 2010 R&amp;amp;D plan. If you complete the survey, you'll be eligible to save $250 on any Intertech course.&amp;#160; &lt;a href="http://www.intertech.com/Feature/Feature.aspx?FID=86"&gt;Intertech R&amp;amp;D Survey&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I have been an Intertech employee for just over a year but I have been an Intertech customer since about 1998.&amp;#160; I started with learning COM + ATL and most recently completed the &lt;a href="http://www.intertech.com/Courses/Course.aspx?CourseID=99330" target="_blank"&gt;WPF&lt;/a&gt; course and there are about 7 other classes I have taken in between.&amp;#160;&amp;#160; I have been writing software professionally since 1993 and I still take take every chance I get to step into the classroom and keep my skills sharp.&amp;#160; The course are terrific and the instructors are the best I have ever seen.&amp;#160; I highly recommend Intertech training. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-281314878965386447?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/281314878965386447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/intertech-r-share-your-thoughts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/281314878965386447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/281314878965386447'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/intertech-r-share-your-thoughts.html' title='Intertech R&amp;amp;D: Share your thoughts!'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-6972438652805261920</id><published>2009-10-20T22:33:00.001-05:00</published><updated>2009-10-20T22:35:08.951-05:00</updated><title type='text'>A look at test planning with Microsoft Test and Lab Manager. Part 3, Executing manual tests.</title><content type='html'>&lt;p&gt;In part three of my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/microsoft-test-and-lab-manager-test.html"&gt;series&lt;/a&gt; on using Microsoft Test and Lab Manager we are going to take a look at running and analyzing test results.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Let’s first look at the right hand side of the screen again.&amp;#160; &lt;/p&gt;  &lt;p&gt;Notice that we have to run a test for each test case &lt;em&gt;and&lt;/em&gt; configuration combination so even though we defined 2 test cases we see that we need to execute 5 tests because each of the test cases must be run on more than one configuration.&amp;#160; &lt;/p&gt;  &lt;p&gt;The tests are grouped by results; in our case we have one test at the ready state, 3 completed tests, and 1 test that has been marked as not ready.&amp;#160; &lt;/p&gt;  &lt;p&gt;There is a cool visual indicator at the top of the grid so we can quickly assess the state of the test plan.&lt;/p&gt;  &lt;p&gt;Finally we have some quick tools that allow us to block, unblock, and reset a test to a ready state.&amp;#160; This would be useful if we determine a test is flawed and we want to block the execution of the test until we have a chance to fix it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/St6A-GEPRzI/AAAAAAAAAHo/FKFfCM57Xfg/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/St6A-WOzzEI/AAAAAAAAAHs/mRzv_IdkxeM/image_thumb%5B3%5D.png?imgmax=800" width="403" height="277" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If we click on the analyze test runs section we get the following screen.&amp;#160; We have a summary section at the top, the middle section is an overview section and the bottom is a fully editable grid view of the test results.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/St6A-0_2UDI/AAAAAAAAAHw/yqqz5KcdTic/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/St6A_AjQNsI/AAAAAAAAAH0/qMoxJLkkL0s/image_thumb%5B5%5D.png?imgmax=800" width="399" height="310" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;By clicking on the my bugs section we get a list of TFS work items that are assigned to us.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/St6A_jKzluI/AAAAAAAAAH4/LFpfHXRKtUI/s1600-h/image%5B13%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/St6A_6iaL4I/AAAAAAAAAH8/7tr2-wqj9C4/image_thumb%5B7%5D.png?imgmax=800" width="409" height="171" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Moving on to the track tab we see the screen where we can assign the build.&amp;#160;&amp;#160; When we assign the build we get a list of work items that have been fixed and need to be verified.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/St6BAMeJRkI/AAAAAAAAAIA/5MTL3AHyM4U/s1600-h/image%5B17%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/St6BAjH22FI/AAAAAAAAAIE/19w9S3FtOOA/image_thumb%5B9%5D.png?imgmax=800" width="416" height="215" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;If we move on to the recommended tests section we can select a build and look at the impact the code changes have on testing. We will discuss in the &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_20.html" target="_blank"&gt;test impact analysis section&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/St6BA0uFEOI/AAAAAAAAAII/NsQi1q6UDrg/s1600-h/image%5B21%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/St6BBBAc__I/AAAAAAAAAIM/Lg-eLotILvc/image_thumb%5B11%5D.png?imgmax=800" width="406" height="195" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6bfcf9af-a258-4b7f-ad84-c1d1d7949884" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VSTS+2010+beta+1" rel="tag"&gt;VSTS 2010 beta 1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Microsoft+test+and+lab+manager" rel="tag"&gt;Microsoft test and lab manager&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VSTT+2010" rel="tag"&gt;VSTT 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/test+planning" rel="tag"&gt;test planning&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TFS+testing" rel="tag"&gt;TFS testing&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-6972438652805261920?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/6972438652805261920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_6337.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6972438652805261920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6972438652805261920'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_6337.html' title='A look at test planning with Microsoft Test and Lab Manager. Part 3, Executing manual tests.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_04HDQqptby8/St6A-WOzzEI/AAAAAAAAAHs/mRzv_IdkxeM/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-3700493895380081630</id><published>2009-10-20T21:53:00.001-05:00</published><updated>2009-10-20T22:36:05.697-05:00</updated><title type='text'>A look at test planning with Microsoft Test and Lab Manager. Part 5,Test Impact Analysis</title><content type='html'>&lt;p&gt;In part five of my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/microsoft-test-and-lab-manager-test.html"&gt;series&lt;/a&gt; on using Microsoft Test and Lab Manager we are going to take a look at test impact analysis. &lt;/p&gt;  &lt;p&gt;I find the test impact analysis feature to be one of the most exciting new features of VSTS.&amp;#160; As you read through this blog entry keep in mind this is based on beta 1 (beta 2 was released to MSDN subscribers)&lt;/p&gt;  &lt;p&gt;From a high level, following are the steps we need to take to enable test impact analysis.&lt;/p&gt;  &lt;p&gt;• Add the test project to source control.&lt;/p&gt;  &lt;p&gt;• Create the build definition.&lt;/p&gt;  &lt;p&gt;• Make sure “Analyze Test Impacts” in the Process tab is set to “True”.&lt;/p&gt;  &lt;p&gt;• Queue a new build.&lt;/p&gt;  &lt;p&gt;• Make sure the “Test Impact Collector” option is set in test settings file.&lt;/p&gt;  &lt;p&gt;• Run the tests in the test project (this collects the test impact data)&lt;/p&gt;  &lt;p&gt;• Change the code.&lt;/p&gt;  &lt;p&gt;• Run a new build. (the test impact analysis runs)&lt;/p&gt;  &lt;p&gt;• Test manager – Assign the new build &lt;/p&gt;  &lt;p&gt;• Test Manager - Track/Recommended tasks&lt;/p&gt;  &lt;p&gt;Here is a very good walk through: &lt;a href="http://blogs.msdn.com/densto/archive/2009/06/29/test-impact-walk-through.aspx"&gt;http://blogs.msdn.com/densto/archive/2009/06/29/test-impact-walk-through.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Once we get things lined up there are a couple places we can see the recommended tests:&lt;/p&gt;  &lt;p&gt;1) In the test and lab manager we can see the impacted tests in the Testing Center area - Track tab under the recommended tests section.&amp;#160; By comparing the build in use to the previous build, VSTS recommends what tests to run based on the code changes. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/St53seEfDyI/AAAAAAAAAHQ/0xQajq3kbN0/s1600-h/image%5B4%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/St53snRjsQI/AAAAAAAAAHU/ENTk95lMWrM/image_thumb%5B2%5D.png?imgmax=800" width="417" height="204" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;2) In Visual Studio the developer can use the test impact view to get a list of tests that will be impacted by a code change &lt;strong&gt;&lt;em&gt;before&lt;/em&gt;&lt;/strong&gt; the change is checked in.&amp;#160; The idea here is rather than running all unit tests, the developer can run a subset (the impacted tests) of the tests and be confident that the change is safe.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/St53tG8XZCI/AAAAAAAAAHY/Tnj2jqeOELI/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/St53tcNVbZI/AAAAAAAAAHc/LU8oi1LdvRw/image_thumb%5B5%5D.png?imgmax=800" width="412" height="381" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3) The build report will include an interactive list of tests that had been impacted by the code changes in the build.&amp;#160; Anybody that gets the build report can get a list of all tests impacted by the changes in the build.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/St53t2j_-VI/AAAAAAAAAHg/cagcPCCqOik/s1600-h/image%5B13%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/St53uewWivI/AAAAAAAAAHk/cNu4VwZ6_SM/image_thumb%5B7%5D.png?imgmax=800" width="416" height="341" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The new test impact analysis is a must use feature.&amp;#160; As a former development manager I can’t tell you how many times I was forced to make a decision about how to hot fix a bug while minimizing the possibility of braking anything and all I had to go on was a gut feel and experience.&amp;#160; This new feature gives the developer a way to fully understand the potential impact of a change before making it.&amp;#160; It also gives a clear set of tests to perform to insure that the released code is of the highest quality possible.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4e4d9604-207b-4e25-bca4-7631ff196165" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VSTS+2010+beta+1" rel="tag"&gt;VSTS 2010 beta 1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Microsoft+test+and+lab+manager" rel="tag"&gt;Microsoft test and lab manager&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VSTT+2010" rel="tag"&gt;VSTT 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/test+planning" rel="tag"&gt;test planning&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TFS+testing" rel="tag"&gt;TFS testing&lt;/a&gt;,&lt;a href="http://technorati.com/tags/test+impact+analysis" rel="tag"&gt;test impact analysis&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-3700493895380081630?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/3700493895380081630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3700493895380081630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3700493895380081630'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_20.html' title='A look at test planning with Microsoft Test and Lab Manager. Part 5,Test Impact Analysis'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_04HDQqptby8/St53snRjsQI/AAAAAAAAAHU/ENTk95lMWrM/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-2807182730767179006</id><published>2009-10-10T16:29:00.001-05:00</published><updated>2009-10-10T16:34:47.165-05:00</updated><title type='text'>A couple basic WPF databinding examples.</title><content type='html'>&lt;p&gt;The databinding options available to us in WPF are numerous and powerful.&amp;#160; We can bind a UI element to an object, a list, another UI element, a collection, an ADO.Net object and the list goes on and on.&amp;#160; You can bind declaratively or programmatically.&amp;#160; You can bind one way, two way, or one time.&amp;#160; &lt;/p&gt;  &lt;p&gt;Let’s take a look at just a couple of these databinding options.&amp;#160; Say we are creating a user preference page and from this page we want to allow the user to specify the foreground color of a textbox by typing an ARGB number in a textbox.&amp;#160; Further, we want the color of the text in the textbox to represent the color that was typed into the textbox.&amp;#160; We are trying to bind the foreground property of the textbox to the value of the textbox’s Text property.&lt;/p&gt;  &lt;p&gt;Here is what our app looks like:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/StD8mc2lM7I/AAAAAAAAAHA/-PC3MbWF1mk/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/StD8mjTxBsI/AAAAAAAAAHE/wwfwNTFo--0/image_thumb%5B1%5D.png?imgmax=800" width="411" height="189" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is the code that will pull that off:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bf88e716-9eef-423e-9160-407d005db193" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Window&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="WpfSelfBinding.Window1"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; Title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Window1"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="300"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="300"&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Label&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="28"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="12,47,0,0"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="label1"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;               &lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Left"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Text Color&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="tbColor"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="23"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="110,49,48,0"&lt;/span&gt; &lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#ff0000"&gt; Foreground&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Self&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}}"&lt;/span&gt; &lt;span style="color:#0000ff"&gt; &amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Window&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;The key bit of XAML we need to focus on is the textbox’s Foreground property:&lt;/p&gt;  &lt;p&gt;Foreground=&amp;quot;{Binding Text,RelativeSource={RelativeSource Self}}&amp;quot;&lt;/p&gt;  &lt;p&gt;This binding is telling the app to bind the Textbox’s Foreground property to the value of the Text property of myself.&amp;#160; If you run the App you will notice that as you change the &lt;em&gt;value&lt;/em&gt; of the textbox, the &lt;em&gt;color&lt;/em&gt; of the text will also change.&lt;/p&gt;  &lt;p&gt;Now &lt;em&gt;I&lt;/em&gt; can’t get even close to the color I want by using ARGB so let’s see if we can make the user experience a little more pleasant.&amp;#160; let’s give the user the option of selecting the color from a color picker.&amp;#160; WPF does not have a color picker dialog so we will have to use the Windows Forms library.&amp;#160; We’ll modify the app a little bit and add a button that will&amp;#160; launch the color picker and populate the textbox with the result.&lt;/p&gt;  &lt;p&gt;Here is the new UI:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/StD8nFBy9TI/AAAAAAAAAHI/qWDM_QoWaIo/s1600-h/image%5B7%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/StD8oieN0JI/AAAAAAAAAHM/PVlrQVZI8yg/image_thumb%5B3%5D.png?imgmax=800" width="407" height="412" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The new XAML:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f6519696-31e4-4815-81f4-38d42517db18" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Window&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="WpfSelfBinding.Window1"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; Title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Window1"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="300"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="300"&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Label&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="28"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="12,47,0,0"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="label1"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;               &lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Left"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Text Color&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="tbColor"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="23"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="110,49,48,0"&lt;/span&gt; &lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#ff0000"&gt; Foreground&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Self&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}}"&lt;/span&gt; &lt;span style="color:#0000ff"&gt; &amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnColor"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="23"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Right"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="0,49,24,0"&lt;/span&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="18"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnColor_Click"&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;...&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Window&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;And the code behind:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7d1f5d7c-4bfc-4ebf-9010-a691ea1390c8" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; WpfSelfBinding&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; {&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; Interaction logic for Window1.xaml&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Window1&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;Window&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Window1()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             InitializeComponent();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; btnColor_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             System.Windows.Forms.&lt;span style="color:#2b91af"&gt;ColorDialog&lt;/span&gt; colorDialog = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; System.Windows.Forms.&lt;span style="color:#2b91af"&gt;ColorDialog&lt;/span&gt;();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             System.Windows.Forms.&lt;span style="color:#2b91af"&gt;DialogResult&lt;/span&gt; result = colorDialog.ShowDialog();&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (result == System.Windows.Forms.&lt;span style="color:#2b91af"&gt;DialogResult&lt;/span&gt;.OK)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 tbColor.Text = SysDrawColorWinMediaColor(colorDialog.Color).ToString();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Color&lt;/span&gt; SysDrawColorWinMediaColor(System.Drawing.&lt;span style="color:#2b91af"&gt;Color&lt;/span&gt; color)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             System.Windows.Media.&lt;span style="color:#2b91af"&gt;Color&lt;/span&gt; bColor;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; i = color.ToArgb();&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; a = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)((i &amp;gt;&amp;gt; 24) &amp;amp; 255);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; r = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)((i &amp;gt;&amp;gt; 16) &amp;amp; 255);&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; g = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)((i &amp;gt;&amp;gt; 8) &amp;amp; 255);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; b = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)(i &amp;amp; 255);&lt;/li&gt;&lt;li&gt;             bColor = &lt;span style="color:#2b91af"&gt;Color&lt;/span&gt;.FromArgb(a, r, g, b);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; bColor;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Two things are worth noting in the code.&amp;#160; Rather than importing the System.Windows.Forms namespace, we just use the fully qualified class name.&amp;#160; This is because there are several conflicts between WPF classes and windows forms classes in the&amp;#160; System.Windows.Forms namespace.&amp;#160; The second thing we have to do is convert the color returned by the color picker (System.Drawing.Color) to a System.Windows.Media color.&amp;#160; We use bit shifting and a bit mask to pull this off in the SysDrawColorWinMediaColor function.&amp;#160; &lt;/p&gt;  &lt;p&gt;Rather than using the color dialog result to directly set the text property of the textbox let’s say we want to populate an object ( so we can persist the selection to a database or isolated storage).&amp;#160; It would be cool if we could bind directly to this class.&lt;/p&gt;  &lt;p&gt;The UI looks exactly the same but here is our new class&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:412de4b0-978b-464d-b9d8-d559eee8d5c9" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; WpfSelfBinding&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; {&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BindableColorClass&lt;/span&gt;:&lt;span style="color:#2b91af"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; textColor = &lt;span style="color:#a31515"&gt;"#FF0F0FF0"&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;event&lt;/span&gt; &lt;span style="color:#2b91af"&gt;PropertyChangedEventHandler&lt;/span&gt; PropertyChanged;&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; OnPropertyChanged(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; name)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#2b91af"&gt;PropertyChangedEventHandler&lt;/span&gt; handler = PropertyChanged;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (handler != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 handler(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;PropertyChangedEventArgs&lt;/span&gt;(name));&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; TextColor&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; textColor; }&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (textColor != &lt;span style="color:#0000ff"&gt;value&lt;/span&gt;)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 {&lt;/li&gt;&lt;li&gt;                     textColor = &lt;span style="color:#0000ff"&gt;value&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     OnPropertyChanged(&lt;span style="color:#a31515"&gt;"TextColor"&lt;/span&gt;);&lt;/li&gt;&lt;li&gt;                 }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt; &lt;/p&gt;  &lt;p&gt;The key here is that our class implements INotifyPropertyChanged.&amp;#160; We raise the PropertyChanged event when the TextColor property changes.&amp;#160; This event is what wires our class into WPF’s Data Change Notification mechanism.&lt;/p&gt;  &lt;p&gt;Here is the new Window1 code:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:98656b0d-f1a6-4b89-a3c8-0ce9ba58c10b" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; WpfSelfBinding&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; {&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; Interaction logic for Window1.xaml&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Window1&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;Window&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#2b91af"&gt;BindableColorClass&lt;/span&gt; colorClass = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;BindableColorClass&lt;/span&gt;();&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Window1()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             InitializeComponent();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             tbColor.DataContext = &lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.colorClass;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; btnColor_Click(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             System.Windows.Forms.&lt;span style="color:#2b91af"&gt;ColorDialog&lt;/span&gt; colorDialog = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; System.Windows.Forms.&lt;span style="color:#2b91af"&gt;ColorDialog&lt;/span&gt;();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             System.Windows.Forms.&lt;span style="color:#2b91af"&gt;DialogResult&lt;/span&gt; result = colorDialog.ShowDialog();&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (result == System.Windows.Forms.&lt;span style="color:#2b91af"&gt;DialogResult&lt;/span&gt;.OK)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 colorClass.TextColor = SysDrawColorWinMediaColor(colorDialog.Color).ToString();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Color&lt;/span&gt; SysDrawColorWinMediaColor(System.Drawing.&lt;span style="color:#2b91af"&gt;Color&lt;/span&gt; color)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             System.Windows.Media.&lt;span style="color:#2b91af"&gt;Color&lt;/span&gt; bColor;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; i = color.ToArgb();&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; a = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)((i &amp;gt;&amp;gt; 24) &amp;amp; 255);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; r = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)((i &amp;gt;&amp;gt; 16) &amp;amp; 255);&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; g = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)((i &amp;gt;&amp;gt; 8) &amp;amp; 255);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;byte&lt;/span&gt; b = (&lt;span style="color:#0000ff"&gt;byte&lt;/span&gt;)(i &amp;amp; 255);&lt;/li&gt;&lt;li&gt;             bColor = &lt;span style="color:#2b91af"&gt;Color&lt;/span&gt;.FromArgb(a, r, g, b);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; bColor;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;There are a couple things to pay particular attention to here.&amp;#160; First we have a class variable referencing an instance of our BindableColorClass.&amp;#160; Next, notice in our btnColor_Click event we are updating the TextColor of the BindableColorClass, NOT the textbox’s text value.&amp;#160; Finally notice that on class construction we are setting the textbox’s DataContext to our instance of the BindableColorClass.&lt;/p&gt;  &lt;p&gt;Here is the ne XAML:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d7da16b3-f36e-4715-b5cc-920d690bf8e6" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Window&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="WpfSelfBinding.Window1"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;    &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#ff0000"&gt; Title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Window1"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="300"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="300"&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Label&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="28"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="12,47,0,0"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="label1"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;               &lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Left"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="100"&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Background Color&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="tbColor"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="23"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="110,49,48,0"&lt;/span&gt; &lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#ff0000"&gt; Foreground&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Self&lt;/span&gt;&lt;span style="color:#0000ff"&gt;}}"&lt;/span&gt; &lt;span style="color:#0000ff"&gt; &amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox.Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;                &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="TextColor"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Mode&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="TwoWay"/&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;            &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox.Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnColor"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="23"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Right"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="0,49,24,0"&lt;/span&gt; &lt;/li&gt;&lt;li&gt;                &lt;span style="color:#ff0000"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Top"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="18"&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnColor_Click"&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;...&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;span style="color:#a31515"&gt;    &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Window&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;The XAML we want to focus on:&lt;/p&gt;  &lt;p&gt;&amp;lt;TextBox.Text&amp;gt;   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Binding Path=&amp;quot;TextColor&amp;quot; Mode=&amp;quot;TwoWay&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;lt;/TextBox.Text&amp;gt;&lt;/p&gt;  &lt;p&gt;This tells WPF to bind the TextBox.Text property to the “TextColor” property.&amp;#160; The “TextColor” property of what??&amp;#160; Our background property uses the source property to tell WPF which item’s text property to bind to but we didn’t specify one here.&amp;#160; Since we didn’t set the source property, WPF is going to look for a DataContext which we &lt;em&gt;DO&lt;/em&gt; set in our code behind.&amp;#160; &lt;/p&gt;  &lt;p&gt;tbColor.DataContext = this.colorClass;&lt;/p&gt;  &lt;p&gt;WPF knows to bind the textbox’s text property to TextColor property of the windows colorClass.&lt;/p&gt;  &lt;p&gt;The intention is to persist the BindableColorClass eventually so we need the TextColor property to be changed either from the color picker or by typing the ARGB color into the TextBox.&amp;#160; To pull this off all we have to do is set the binding Mode to TwoWay.&amp;#160; Set a break point on the TextColor getter and setter to see when they fire.&amp;#160; If you are typing the ARGB color into the textbox by hand you will need to tab out of the textbox to get the change to take place.&amp;#160; This is the default textbox binding behavior.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1f6eef25-00ae-4132-b73f-01d84b82c1f3" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/WPF" rel="tag"&gt;WPF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/databinding" rel="tag"&gt;databinding&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TwoWay" rel="tag"&gt;TwoWay&lt;/a&gt;,&lt;a href="http://technorati.com/tags/RelativeSource" rel="tag"&gt;RelativeSource&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Self" rel="tag"&gt;Self&lt;/a&gt;,&lt;a href="http://technorati.com/tags/INotifyPropertyChanged" rel="tag"&gt;INotifyPropertyChanged&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-2807182730767179006?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/2807182730767179006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/couple-basic-wpf-databinding-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/2807182730767179006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/2807182730767179006'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/couple-basic-wpf-databinding-examples.html' title='A couple basic WPF databinding examples.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_04HDQqptby8/StD8mjTxBsI/AAAAAAAAAHE/wwfwNTFo--0/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-3578951443005913587</id><published>2009-10-03T10:47:00.001-05:00</published><updated>2009-10-03T10:54:24.363-05:00</updated><title type='text'>A look at test planning with Microsoft Test and Lab Manager. Part 2, test planning.</title><content type='html'>&lt;p&gt;In part two of my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/microsoft-test-and-lab-manager-test.html" target="_blank"&gt;series&lt;/a&gt; on using Microsoft Test and Lab Manager we are going to take a look at test planning.&amp;#160; &lt;/p&gt;  &lt;h3&gt;The Testing Center Area&lt;/h3&gt;  &lt;p&gt;From a high level the testing center is where we create and execute our test plans, track our testing progress, assign builds, and determine our recommended tests.&lt;/p&gt;  &lt;h4&gt;Plan Tab&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Ssdx4lil63I/AAAAAAAAAFQ/L9bqvzyr5ME/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/Ssdx5CPDtZI/AAAAAAAAAFU/m5nVtIN8Za8/image_thumb%5B1%5D.png?imgmax=800" width="421" height="159" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the contents view of the plan tab we have a split screen.&amp;#160; The left hand side is used for managing and organizing requirements.&amp;#160; The right hand side is for managing test cases.&amp;#160; Let’s drill into some other plan concepts before we explore the plan contents screen.&lt;/p&gt;  &lt;h4&gt;Plan - Properties&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Ssdx5d4O5YI/AAAAAAAAAFY/DzNkeJyPmzw/s1600-h/image%5B7%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Ssdx5zZFsjI/AAAAAAAAAFc/DlHq4HXSnwE/image_thumb%5B3%5D.png?imgmax=800" width="421" height="206" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Each test plan has some properties associated to it.&amp;#160; These properties include the test plan name and description, the&amp;#160; TFS project it is associated to, some default test settings and configurations, build information, and some tracking info such as owner, state, and dates.&lt;/p&gt;  &lt;p&gt;If we drill into the test settings we see the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Ssdx6NYw5xI/AAAAAAAAAFg/AvHCghYunEM/s1600-h/image%5B11%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/Ssdx6VpuJOI/AAAAAAAAAFk/wYL71cFlIyQ/image_thumb%5B5%5D.png?imgmax=800" width="422" height="181" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The general tab is used to name and describe the settings as well as set some options regarding how the tests will be run. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Ssdx6-WsnAI/AAAAAAAAAFo/IdBkMgU5afI/s1600-h/image%5B15%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Ssdx7Su3pDI/AAAAAAAAAFs/qIPcIu0aMHw/image_thumb%5B7%5D.png?imgmax=800" width="428" height="372" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The data and diagnostics tab is where we configure what we want to collect during a test run.&lt;/p&gt;  &lt;p&gt;Action recording and log is used to record and play back the test as well as capturing a textual description of what is happening during the test.&amp;#160; Have a look at this log the descriptions are good, we could record an exploratory type test and then copy paste entries from this log into the steps of a more specific test case.&lt;/p&gt;  &lt;p&gt;ASP.Net profiler is used to collect asp.net performance data during a test run.&lt;/p&gt;  &lt;p&gt;Collecting code coverage data allows us to track how much of the code we are covering during our test runs.&lt;/p&gt;  &lt;p&gt;Diagnostic trace collector captures events and call stack information for the historical debugger.&lt;/p&gt;  &lt;p&gt;When we collect the event log information, any new event log entry created during a test run is attached to the test run.&lt;/p&gt;  &lt;p&gt;Network Emulation is used to emulate different qualities of network such as T1, DSL and dial up.&lt;/p&gt;  &lt;p&gt;By collecting the system information with the test run we are attaching the OS version, amount of ram, CPU speed, and a handful of other details to our test results.&lt;/p&gt;  &lt;p&gt;The test impact is a really cool feature.&amp;#160; If we collect this information during a test run, TFS can tie the test to the code paths that are being executed.&amp;#160; This information is later used during a build to allow TFS to actually suggest which tests to run.&amp;#160; Or at development time to tell developers what tests will be impacted by changes to code.&amp;#160; Important: we may not collect test impact data at the same time as we collect code coverage data.&lt;/p&gt;  &lt;p&gt;Collecting the video recording will attach a video of exactly what the tester is doing during a test run.&amp;#160; Developers can later replay this video to see exactly how a bug was produced.&lt;/p&gt;  &lt;h4&gt;Plan – Set Plan Context&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/Ssdx7lubExI/AAAAAAAAAFw/1eQ1p3gWQiM/s1600-h/image%5B46%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Ssdx7xjBEWI/AAAAAAAAAF0/YPPF7Yl8gQQ/image_thumb%5B18%5D.png?imgmax=800" width="423" height="156" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is the screen we use to manage our list of test plans and set our plan context.&amp;#160; The list of plans in this screen is limited to all plans associated to the TFS project displayed in the title bar.&amp;#160; Select the plan we want to work with and click the set context icon.&lt;/p&gt;  &lt;h4&gt;Plan - Contents &lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Ssdx87dl1VI/AAAAAAAAAF4/JcZGhWYsrCk/s1600-h/image%5B47%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/Ssdx9WzBYbI/AAAAAAAAAF8/MCCLw000BMw/image_thumb%5B19%5D.png?imgmax=800" width="424" height="160" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We find ourselves back at the plan contents screen.&amp;#160; Remember, the context of this screen is determined by the plan we selected in the last step.&amp;#160; We’ll explore the left side of the screen first.&amp;#160; This is the place we select and organize user stories (requirements) and ultimately associate them to the test cases on the left hand side.&amp;#160; I want to mention that Microsoft has introduced the notion of a suite.&amp;#160; A suite is a generic bucket used to build a hierarchy any way we want.&amp;#160; Think of them as folders in windows explorer, they are just used to group and associate our user stories.&lt;/p&gt;  &lt;p&gt;To start things out we need some user stories to exist in TFS.&amp;#160; If we bounce over to team explorer we can see an example of the default user story template.&amp;#160; The QA team is not typically responsible for entering user stories.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Ssdx9p6CVNI/AAAAAAAAAGA/EoHdwpwg6G4/s1600-h/image%5B48%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Ssdx99kh8YI/AAAAAAAAAGE/tYLVWzONcQ8/image_thumb%5B20%5D.png?imgmax=800" width="416" height="238" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Once the user stories exist in TFS, we can click the add requirement button in the test and lab manager and we will get a list of the user stories associated to the team project.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Ssdx-ZBzpwI/AAAAAAAAAGI/4YbnOWp2Xig/s1600-h/image%5B49%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/Ssdx-qd3R0I/AAAAAAAAAGM/B8FpYKlviE4/image_thumb%5B21%5D.png?imgmax=800" width="421" height="174" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If we select Import we can copy the user stories and test cases from an existing test plan.&amp;#160; This copy may be individual user stories, suites (groups of user stories), or all of the stories in the entire test plan.&amp;#160; There is even a nice feature that allows us to configure a &lt;a href="http://msdn.microsoft.com/en-us/library/dd286723(VS.100).aspx" target="_blank"&gt;query based suite&lt;/a&gt;.&amp;#160; In a query based suite, the test case list is dynamic. As test cases are added to TFS that match the query parameters, the list of test cases in the suite will change dynamically.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Ssdx_Jw3WqI/AAAAAAAAAGQ/9Msl4X5hMMA/s1600-h/image%5B50%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/Ssdx_Ww9USI/AAAAAAAAAGU/KiZNj66ro4M/image_thumb%5B22%5D.png?imgmax=800" width="422" height="267" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now let’s take a look at the right hand side of the plan contents screen.&amp;#160; This is the test case area.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Ssdx_6_AwGI/AAAAAAAAAGY/W8_Bgd7qGNI/s1600-h/image%5B51%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/SsdyAK4r4cI/AAAAAAAAAGc/sCbMnyguWtw/image_thumb%5B23%5D.png?imgmax=800" width="427" height="169" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;From here we can add an existing test case.&amp;#160;&amp;#160; The following screen is used to search our TFS project for existing test cases.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/SsdyAWAiDrI/AAAAAAAAAGg/JBHNm90On7E/s1600-h/image%5B52%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/SsdyA8B0A5I/AAAAAAAAAGk/nxwp2czbunc/image_thumb%5B24%5D.png?imgmax=800" width="424" height="167" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We can also add new test cases from the plan contents screen.&amp;#160; Following is the default test case work item template.&amp;#160; Notice at the bottom of the test case I have configured 3 steps.&amp;#160; From here I can also configure variables for data binding and insert shared steps.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/SsdyBf62ixI/AAAAAAAAAGo/8-T_aPFuUPE/s1600-h/image%5B53%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SsdyBzU7EQI/AAAAAAAAAGs/gKFzdhSIE1o/image_thumb%5B25%5D.png?imgmax=800" width="421" height="295" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If we click on the configurations button in the plan contents screen we get the following screen.&amp;#160; Here we configure which tests run against which configuration.&amp;#160; In my example I have 2 test cases, the first is configured to run on; a Vista machine with the 3.5 version of the .Net framework installed and a Vista machine with the 4.0 version of the .Net framework installed.&amp;#160; The second case runs against both of those configurations and additionally needs to run on a machine with Vista and IE7 installed.&amp;#160; The cool thing about this is the configurations have a multiplier effect.&amp;#160; When it comes time to execute these two test cases 5 tests will be created, one for each configuration.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/SsdyCHnrG8I/AAAAAAAAAGw/JbHZQUOBH34/s1600-h/image%5B54%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SsdyCoA-lJI/AAAAAAAAAG0/IKAgIDbtAN4/image_thumb%5B26%5D.png?imgmax=800" width="422" height="176" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The last screen I want to look at in this post is the “Assign Testers” screen.&amp;#160; To get here we click the assign button from the test contents screen.&amp;#160; This is where we assign TFS users to each individual test (a combination of a test case + a configuration).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/SsdyCyj5ptI/AAAAAAAAAG4/huq5AI9QbXc/s1600-h/image%5B55%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SsdyDC9iKNI/AAAAAAAAAG8/nu8qCSq3skA/image_thumb%5B27%5D.png?imgmax=800" width="424" height="184" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bc21f7b9-eec4-47cb-9bf7-2fa0959bfe98" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VSTS+2010+beta+1" rel="tag"&gt;VSTS 2010 beta 1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Microsoft+test+and+lab+manager" rel="tag"&gt;Microsoft test and lab manager&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VSTT+2010" rel="tag"&gt;VSTT 2010&lt;/a&gt;,&lt;a href="http://technorati.com/tags/test+planning" rel="tag"&gt;test planning&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TFS+testing" rel="tag"&gt;TFS testing&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-3578951443005913587?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/3578951443005913587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3578951443005913587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3578951443005913587'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft.html' title='A look at test planning with Microsoft Test and Lab Manager. Part 2, test planning.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_04HDQqptby8/Ssdx5CPDtZI/AAAAAAAAAFU/m5nVtIN8Za8/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-146885472726966562</id><published>2009-10-01T22:52:00.001-05:00</published><updated>2009-10-01T23:14:18.239-05:00</updated><title type='text'>YAGNI – You ain’t gonna need it</title><content type='html'>&lt;p&gt;The YAGNI principle states that programmers should not implement functionality until it is necessary.&amp;#160; It is a pretty simple principle but oddly enough it is a difficult principle to follow.&lt;/p&gt;  &lt;p&gt;I’ll take a crack at what I think the upside of breaking this rule is.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;It seems to me the biggest benefit to breaking this principle is that we can architect and design our code by taking into account both current and future features thus implementing a more robust design. &lt;/li&gt;    &lt;li&gt;Another big argument is that by implementing this feature our software will be more useful.&amp;#160; If our software is more useful we may sell more licenses or we may be more productive. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s look at the most obvious negatives of implementing a feature before you need it. This is a longer list.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;If we don’t need it yet, maybe we should be spending our time and money implementing something we do need now. &lt;/li&gt;    &lt;li&gt;If we implement a feature we should have some corresponding documentation describing the feature – this takes time. &lt;/li&gt;    &lt;li&gt;If we implement something we need to test it -every release and this takes a lot of time. &lt;/li&gt;    &lt;li&gt;When we add a feature in an agile/TDD shop, we need to write unit tests for the feature so we can automatically test it every release.&amp;#160; Writing the tests can take as long as or longer than writing the feature and anyone who has to run unit tests before a check in will probably agree that adding time to this automated process is not good. &lt;/li&gt;    &lt;li&gt;When we add a feature we need to train the support crew and user base on how to use the feature. &lt;/li&gt;    &lt;li&gt;A feature is hard enough to implement correctly when it is needed, how do we expect to implement it optimally when we are still guessing whether or not we need it? &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;A quick summary of the negatives:&amp;#160; We are spending time writing code for something we might need.&amp;#160; We are writing the feature the way we think we will need it in the future.&amp;#160; We are spending time and money documenting and testing a feature that we are guessing we will need and by the way we are also guessing how to best implement it.&lt;/p&gt;  &lt;p&gt;If all of those (mostly financial) arguments aren’t enough to convince you, let’s take a look at some down sides from an architect or developer’s point of view.&lt;/p&gt;  &lt;p&gt;If code is in a release you have to assume it is being used.&amp;#160; When it comes time to change the code you think you needed, you are going to spend time figuring out how to change it without breaking the (imagined?) user base.&amp;#160; This might involve migrating data, configurations, backup procedures, reports, integration work flows etc.&amp;#160; When it comes time to change the code you really do need you must consider all of the code.&amp;#160; This includes the code you don’t realize that you don’t need – if it is in production, how can you be confident in saying “oh, we really don’t need that code”.&amp;#160; This really stifles our ability to modernize our code.&amp;#160; Even if you do find a way to refactor the bloated code base not only will you have to change the existing code but you will have to change the tests, documentation, and training materials.&lt;/p&gt;  &lt;p&gt;Let the business analysts, user base, and marketing folks decide what features your product needs and when it needs it.&amp;#160; I would rather architect and design a system based on things that are known.&amp;#160; I don’t ever want to tell somebody that the system is the way it is because I thought we needed some functionality that turns out to be useless.&amp;#160; When we do a good job of designing and reviewing our system we can be confident that we can refactor our code to implement major functional changes when they are understood, needed, and the highest priority. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html" target="_blank"&gt;My design review checklist&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:857a3a50-f9fc-4201-83de-8656f0b11e5a" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Design+review" rel="tag"&gt;Design review&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Architecture" rel="tag"&gt;Architecture&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Agile+principles" rel="tag"&gt;Agile principles&lt;/a&gt;,&lt;a href="http://technorati.com/tags/YAGNI" rel="tag"&gt;YAGNI&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-146885472726966562?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/146885472726966562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/yagni-you-aint-gonna-need-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/146885472726966562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/146885472726966562'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/10/yagni-you-aint-gonna-need-it.html' title='YAGNI – You ain’t gonna need it'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-4703142926588945111</id><published>2009-09-24T06:55:00.003-05:00</published><updated>2009-09-24T07:03:40.650-05:00</updated><title type='text'>WPF Styles and Animations</title><content type='html'>&lt;p&gt;I have been working with WPF lately and I’m really impressed with the style capabilities. From a high level our goal when using styles is to be able to set some standard properties of various controls one time in one place and have them affect many or all of the controls of that type in our window or application.&lt;/p&gt;&lt;p&gt;Let’s start with a really basic window and a hand type a few controls.&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31adb7fe-424d-4b39-9a5b-c8ed1769b85b" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 35px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Lesson1Styles.Window1"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;Title&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Window1"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="300"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="300"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,25,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top" &amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven Label&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,100,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven TextBox&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,175,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top" &amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven Button&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt; &lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;One of the reasons for hand typing the controls is that I chose to only set the margin and alignment of the controls and I didn’t want the designer to add any height and width properties. If we run the application now here is what we see.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/SrteDeiJciI/AAAAAAAAAEw/1uuE_1Jn93c/s1600-h/image%5B3%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SrteDkg39BI/AAAAAAAAAE0/l3-Z-0Qj1N8/image_thumb%5B1%5D.png?imgmax=800" width="341" height="344" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Now let’s create a style for each of our controls by adding a Window.Resources element.&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:95902a93-fe17-4275-b3bb-5104a4165731" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 35px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Yellow"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="BorderBrush"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="135"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="30"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Yellow"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="135"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="33"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Yellow"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="135"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="30"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Our new window now looks like this:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SrteD8L6eiI/AAAAAAAAAE4/W2UBYuEwpDE/s1600-h/image%5B7%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SrteEbzXE4I/AAAAAAAAAE8/OK7xHXywNrU/image_thumb%5B3%5D.png?imgmax=800" width="390" height="393" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Note - I did not have to set a style property on any of the UI Elements. This is because I set the TargetType property in each style and the runtime knew to apply each style to their corresponding controls. Any label, button, or textbox you add to the window will inherit these styles unless you explicitly override the style or individual properties of the style.&lt;/p&gt;&lt;p&gt;It would be highly unusual (ok…ugly) for us to want our labels, buttons, and textboxes to have the same size and color scheme but if we did, it would be nice to &lt;em&gt;not&lt;/em&gt; have to duplicate these attributes for each control.&lt;/p&gt;&lt;p&gt;With style inheritance we can do just that. We declare a base style with a TargetType of Control and move all of the common properties into this style.  The following refactored code will render the window exactly as we see above.&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8c282402-6578-47e7-8f65-e5bc8b44cdec" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 35px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="baseStyle"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Control"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Yellow"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="BorderBrush"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="135"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="30"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Let’s look at how we can override a portion of the style.  If we want our textbox style to have a different height and width than the base style we can simply duplicate the height and width property setter in the style for the textbox and set the value to whatever we want.  For example, if we change the textbox style as follows:&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9174b5ce-b423-4448-9e12-bf45b5388409" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 25px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="60"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="60"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Our window looks like this:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/SrteEurhnwI/AAAAAAAAAFA/mUXv7jxL8PU/s1600-h/image%5B11%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SrteFC48Z_I/AAAAAAAAAFE/EMDS3QekyMg/image_thumb%5B5%5D.png?imgmax=800" width="390" height="387" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;We can even override these properties at the control level. Let’s add a Height property to our textbox control.&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c3fb484c-43f7-40dd-a572-6504005783e2" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 25px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,100,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="200"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven TextBox&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Now when we run, the textbox width is based on the property we set in the control – we override the style defined for the Button which in turn overrides the style we have set for all Controls.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SrteFWasqSI/AAAAAAAAAFI/y9t9q0uuVJY/s1600-h/image%5B15%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SrteFvGI0kI/AAAAAAAAAFM/40boybQDRls/image_thumb%5B7%5D.png?imgmax=800" width="392" height="390" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;To close things out let’s take a look at adding triggers to a style. If we want all labels to change their background color when the mouse is over the label we can add a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx" target="_blank"&gt;Dependency Property&lt;/a&gt; Trigger to the style. &lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b91021a-cf50-41b3-bdf1-d7973e4bb422" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 25px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="IsMouseOver"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="True"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Gray"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;If we want to animate the textbox when the mouse is over the control we can add a Dependency Property Trigger with a StoryBoard and Animation defined. This animation changes the Font Size, height, width, and background color of the textbox.&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f836e3c-cd86-4bcf-a7d5-50c5bfb839f1" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 35px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="60"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="60"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="IsMouseOver"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="True"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.EnterActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story1"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:5"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="FontSize"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="20"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColorAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="(Background).(SolidColorBrush.Color)"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Gray"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="50"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="270"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.EnterActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.ExitActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StopStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BeginStoryboardName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story1"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.ExitActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Finally we’ll add a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.routedevent.aspx" target="_blank"&gt;Routed Event&lt;/a&gt; trigger to the button just to demonstrate the different trigger options.&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8a3e35aa-e22a-4400-a45b-bc9353976177" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 35px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; RoutedEvent&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Mouse.MouseEnter" &amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story3"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:2"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:0.2"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="90"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; RoutedEvent&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Mouse.MouseLeave" &amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story34"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:2"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:0.2"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height" /&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;We could do all of the styling and animation in code if we want but the good thing about doing this declaratively is if we are not happy with our Minnesota Viking look and feel, we can have a UI designer use a tool like Expression Blend to make things look nice without requiring that they understand code or XAML.&lt;/p&gt;&lt;p&gt;Try adding some other textboxes, labels, and buttons to see what style properties are inherited.&lt;/p&gt;&lt;p&gt;Here is the XAML in it’s entirety:&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:29c716f1-b10f-4759-ac79-ad6e1cbc7d45" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #ddd; MAX-HEIGHT: 500px; OVERFLOW: scroll; PADDING-TOP: 0px"&gt;&lt;br /&gt;&lt;ol style="MARGIN: 0px 0px 0px 35px; WHITE-SPACE: nowrap; BACKGROUND: #ffffff"&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Lesson1Styles.Window1"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;Title&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Window1"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="300"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="300"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="baseStyle"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Control"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Yellow"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="BorderBrush"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Purple"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="135"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="30"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="60"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="60"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="IsMouseOver"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="True"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.EnterActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story1"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:5"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="FontSize"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="20"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColorAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="(Background).(SolidColorBrush.Color)"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Gray"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="50"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Width"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="270"/&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.EnterActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.ExitActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StopStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BeginStoryboardName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story1"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger.ExitActions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Label"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="IsMouseOver"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="True"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Background"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Gray"/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Trigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; baseStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;}"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; RoutedEvent&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Mouse.MouseEnter" &amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story3"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:2"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:0.2"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;To&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="90"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; RoutedEvent&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Mouse.MouseLeave" &amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="story34"&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:2"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DoubleAnimation&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#ff0000;"&gt;Duration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0:0:0.2"&lt;/span&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;span style="color:#ff0000;"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Height" /&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Storyboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,25,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top" &amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven Label&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Label&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,100,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="200"&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven TextBox&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="0,175,0,0"&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Top" &amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Style Driven Button&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Window&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/li&gt;&lt;li style="BACKGROUND: #f3f3f3"&gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f63e5e4d-2ec5-4b5a-99cc-e030104b7fe9" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/WPF" rel="tag"&gt;WPF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Style" rel="tag"&gt;Style&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Style+Trigger" rel="tag"&gt;Style Trigger&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Windows+PResentation+Foundation" rel="tag"&gt;Windows PResentation Foundation&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-4703142926588945111?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/4703142926588945111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/wpf-styles-and-animations.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4703142926588945111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/4703142926588945111'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/wpf-styles-and-animations.html' title='WPF Styles and Animations'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_04HDQqptby8/SrteDkg39BI/AAAAAAAAAE0/l3-Z-0Qj1N8/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-7964832469319401532</id><published>2009-09-19T09:50:00.001-05:00</published><updated>2009-10-21T13:27:08.935-05:00</updated><title type='text'>VSTS 2010 Test Run recording</title><content type='html'>&lt;p&gt;In part four of my &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/microsoft-test-and-lab-manager-test.html"&gt;series&lt;/a&gt; on using Microsoft Test and Lab Manager we are going to take a look at test runner. &lt;/p&gt;  &lt;p&gt;Here is the recording I showed at the VSTS MN user group.&amp;#160; By way of setting things up I am executing a single manual test that results in a failure in our expected result.&amp;#160; It is the first time I ran (and recorded) the test so when test runner comes up I do not have the option of executing the recorded test.&amp;#160; Here is a screen grab of what it would look like if I had the recording in place:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SrTvvDMsJ0I/AAAAAAAAAEg/6dfjvT-WDO0/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SrTvv4ENdRI/AAAAAAAAAEk/KPMyC0lusNA/image_thumb%5B1%5D.png?imgmax=800" width="287" height="385" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Of special note is the very powerful Start test and play option.&amp;#160; This will allow you to execute each step via the recording (no room for mistakes) and enter the results as each step is finished.&lt;/p&gt;  &lt;p&gt;In my video I run through creating a bug and then click through what things were attached to the bug based on my run settings.&amp;#160; &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:e898aabe-beb3-4132-ae2d-b248b9946204" class="wlWriterEditableSmartContent"&gt;&lt;div id="0ef98f6f-92cb-4366-8461-bdc5946ac180" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=dFGSk16wfW8" target="_new"&gt;&lt;img src="http://lh4.ggpht.com/_04HDQqptby8/St9Se6CxbKI/AAAAAAAAAIQ/QkzQxjy6XiE/videod68f9d5e2a6b%5B2%5D.jpg?imgmax=800" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('0ef98f6f-92cb-4366-8461-bdc5946ac180'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/dFGSk16wfW8&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/dFGSk16wfW8&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-7964832469319401532?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/7964832469319401532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/vsts-2010-test-run-recording.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7964832469319401532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7964832469319401532'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/vsts-2010-test-run-recording.html' title='VSTS 2010 Test Run recording'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_04HDQqptby8/SrTvv4ENdRI/AAAAAAAAAEk/KPMyC0lusNA/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-6472521794655986181</id><published>2009-09-19T09:07:00.001-05:00</published><updated>2009-10-20T22:35:27.429-05:00</updated><title type='text'>Microsoft Test and Lab Manager. Test planning and execution.</title><content type='html'>&lt;p&gt;I was the presenter at the &lt;a href="http://vstsmn.net/" target="_blank"&gt;Minnesota VSTS Users Group&lt;/a&gt; this week.&amp;#160; The topics I discussed included; test planning and execution with Microsoft Test and Lab Manager, test impact analysis, coded UI testing, and historical debugger.&amp;#160; You can get a PDF version of my slide deck &lt;a href="http://vstsmn.net/Downloads/2009-09-16%20-%20UI%20Testing%20and%20Test%20Plan%20Management%20with%20VSTS%202010.pdf" target="_blank"&gt;here&lt;/a&gt;.&amp;#160; I had a couple presentation gremlins when I was introducing the historical debugger so I added a couple new slides explaining the configuration necessary to get the behavior I was describing during the presentation.&lt;/p&gt;  &lt;p&gt;The slides themselves will do little more than wet your appetite so I’ll do a series of posts and add some narration describing what we are seeing and how it fits into the QA process.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/look-at-test-planning-with-microsoft.html" target="_blank"&gt;Part 1, Getting organized.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft.html" target="_blank"&gt;Part 2, Test planning&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_6337.html" target="_blank"&gt;Part 3, Executing manual tests&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/vsts-2010-test-run-recording.html" target="_blank"&gt;Part 4, the test run.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/look-at-test-planning-with-microsoft_20.html" target="_blank"&gt;Part 5, Test impact analysis&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I’ll cover the Coded UI test and Historical debugger elsewhere.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-6472521794655986181?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/6472521794655986181/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/microsoft-test-and-lab-manager-test.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6472521794655986181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6472521794655986181'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/microsoft-test-and-lab-manager-test.html' title='Microsoft Test and Lab Manager. Test planning and execution.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-7660511827554803221</id><published>2009-09-19T08:42:00.001-05:00</published><updated>2009-09-19T08:42:28.014-05:00</updated><title type='text'>A look at test planning with Microsoft Test and Lab Manager.  Part 1, getting organized</title><content type='html'>&lt;p&gt;Let’s start with a high level look at the Test and Lab Manager.&amp;#160; Test and Lab Manager is broken into 3 different areas; Lab Center, Test Center, and Organize.&amp;#160; I’m not going to go into the lab center, I’m primarily going to look at the area of the product that a QA professional would use on a day to day basis.&amp;#160; &lt;/p&gt;  &lt;h3&gt;The Lab Center:&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/SrTfrq6bc4I/AAAAAAAAAD4/vGsmJoC379w/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/SrTfscdUhbI/AAAAAAAAAD8/AE2Barwuiqc/image_thumb%5B3%5D.png?imgmax=800" width="426" height="219" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is where you manage environments, test run settings, environment templates and test controllers. We’ll drill into a couple of these concepts later.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;The Organize area:&lt;/strong&gt;&lt;/h3&gt;  &lt;h4&gt;Test Plan tab.&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SrTfs9qZkBI/AAAAAAAAAEA/hhFe-gntDUg/s1600-h/image%5B11%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/SrTftYXi_OI/AAAAAAAAAEE/3zDfjj3gm3I/image_thumb%5B7%5D.png?imgmax=800" width="423" height="229" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Test Plan tab of the organize area is where you manage test plan definitions and their context. This page contains a list of all plans associated with a TFS project.&lt;/p&gt;  &lt;h4&gt;Configuration tab.&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/SrTftwlcyCI/AAAAAAAAAEI/MAidE7FuxbI/s1600-h/image%5B18%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SrTfuagDkCI/AAAAAAAAAEM/5KtkQOcjP8E/image_thumb%5B12%5D.png?imgmax=800" width="422" height="223" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The configuration tab is used to manage the different configurations you want to use during testing.&amp;#160; In our example we have defined 4 configurations;&lt;/p&gt;  &lt;blockquote&gt;   &lt;ul&gt;     &lt;li&gt;&lt;font color="#333333"&gt;Vista with .Net framework 3.5&lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#333333"&gt;Vista with .Net framework 4.0&lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#333333"&gt;Vista with the Firefox browser&lt;/font&gt;&lt;/li&gt;      &lt;li&gt;&lt;font color="#333333"&gt;Vista with IE 7&lt;/font&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/blockquote&gt;  &lt;p&gt;The configuration variables are just name value pairs which may be managed by drilling into this tab.&lt;/p&gt;  &lt;h4&gt;Test Cases tab&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/SrTfvCzGXHI/AAAAAAAAAEQ/MvLo6twxbyk/s1600-h/image%5B27%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SrTfvm4i3AI/AAAAAAAAAEU/eOf_ZHa_tiw/image_thumb%5B19%5D.png?imgmax=800" width="424" height="262" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Test Cases may be created copied and edited here.&amp;#160; This is a place QA can go to create test cases rather than using team explorer and visual studio.&amp;#160; The list is all test cases associated to the configured team project.&amp;#160; Note: the context at the top center of the screen is a link that may be used to change your team project.&lt;/p&gt;  &lt;h4&gt;Shared Steps tab:&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/SrTfwVPTLwI/AAAAAAAAAEY/zHpMeuML4yw/s1600-h/image%5B33%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_04HDQqptby8/SrTfwzIZW8I/AAAAAAAAAEc/96ArRAERTwo/image_thumb%5B23%5D.png?imgmax=800" width="417" height="237" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The idea of a shared step is that you may define commonly executed testing steps in this one place (login for example). When defining other tests that include these common steps, you may reference this shared step rather than duplicating the steps necessary to perform the common task. Not only is it less work to create tests when you use shared steps (less typing) but maintaining this common logic is much simpler as a change to the common task only needs to be made in the shared step – not in every test that calls it.&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;The shared steps tab is the place you would go to create, edit, copy, and record a shared step.&amp;#160; Like test plans and test cases, the list is all shared steps associated to a team project.&amp;#160; &lt;/p&gt;  &lt;p&gt;In future posts I’ll go into more detail about creating the plans and tests as well as cover executing the test plans.&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c355f465-9dd6-48c3-9071-cde51afab983" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VSTS+2010+beta+1" rel="tag"&gt;VSTS 2010 beta 1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Microsoft+test+and+lab+manager" rel="tag"&gt;Microsoft test and lab manager&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-7660511827554803221?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/7660511827554803221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/look-at-test-planning-with-microsoft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7660511827554803221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7660511827554803221'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/look-at-test-planning-with-microsoft.html' title='A look at test planning with Microsoft Test and Lab Manager.  Part 1, getting organized'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_04HDQqptby8/SrTfscdUhbI/AAAAAAAAAD8/AE2Barwuiqc/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-6291451561681782695</id><published>2009-09-08T17:29:00.001-05:00</published><updated>2010-02-05T17:20:15.502-06:00</updated><title type='text'>Design and Code Review Checklist</title><content type='html'>&lt;p&gt;I have been blogging about some of the principles I use in design/code reviews reviews.&amp;#160; Here is the full list of topics I look for, I’ll create links as I blog about more individual items in the future.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Review Unit Tests &lt;/li&gt;    &lt;li&gt;Is the code in the right place? &lt;/li&gt;    &lt;li&gt;Does the name space make sense? &lt;a href="http://blogs.msdn.com/brada/articles/361363.aspx"&gt;http://blogs.msdn.com/brada/articles/361363.aspx&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/design-and-code-review-checklist.html" target="_blank"&gt;Is the class / procedure / variable scope correct.&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Are the Classes, methods, and variables named correctly? &lt;a href="http://blogs.msdn.com/brada/articles/361363.aspx"&gt;http://blogs.msdn.com/brada/articles/361363.aspx&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Are the methods, and variables typed correctly? &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/design-and-code-review-look-at-code.html" target="_blank"&gt;Look at the code.&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-openclosed-principle.html" target="_blank"&gt;Review for OCP&lt;/a&gt;&amp;#160; (open closed principle - Open for extension closed for modification) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-dry-principle.html" target="_blank"&gt;Review for DRY Principle&lt;/a&gt; (Don't Repeat Yourself - abstract common things and put in single place). &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-single-responsibility.html" target="_blank"&gt;Review for SRP&lt;/a&gt; (Single Responsibility Principle - every object has a single responsibility. All the object's services should be focused on that responsibility). &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-review-liskov-substitution.html" target="_blank"&gt;Review for LSP&lt;/a&gt; (Liskov Substitution Principle Subtypes must be substitutable for their base types). &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/12/design-review-and-delegation-vs.html" target="_blank"&gt;Consider delegation over inheritance.&lt;/a&gt; If you don't need to change base class behavior, consider delegating (handing over responsibility of a task) rather than inheritance. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2010/02/consider-composition-over-inheritance.html" target="_blank"&gt;Consider Composition over inheritance&lt;/a&gt;. Similar to delegation except the owner class uses a set of behaviors and chooses which one to use at runtime. When the delegating class is destroyed, so are all the child classes. &lt;/li&gt;    &lt;li&gt;Aggregation. Similar to composition except when the delegating class is destroyed, the child classes are not. &lt;/li&gt;    &lt;li&gt;Consider Polymorphism. Make a group of heterogeneous classes look homogeneous &lt;/li&gt;    &lt;li&gt;Consider generics. &lt;/li&gt;    &lt;li&gt;Testability considerations? &lt;/li&gt;    &lt;li&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/10/yagni-you-aint-gonna-need-it.html" target="_blank"&gt;YAGNI&lt;/a&gt; (You aint gonna need it) When in doubt, leave it out! &lt;/li&gt;    &lt;li&gt;Does object wake up in a known good state (constructor) &lt;/li&gt;    &lt;li&gt;Consider Security. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dd60e878-4793-46e7-964e-113a144b2be8" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Architecture" rel="tag"&gt;Architecture&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Code+Review" rel="tag"&gt;Code Review&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Design+Review" rel="tag"&gt;Design Review&lt;/a&gt;&lt;/div&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-6291451561681782695?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/6291451561681782695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6291451561681782695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6291451561681782695'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html' title='Design and Code Review Checklist'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-1795801341616952466</id><published>2009-09-05T11:51:00.001-05:00</published><updated>2009-10-01T22:56:52.613-05:00</updated><title type='text'>Design Review – Liskov Substitution Principle</title><content type='html'>&lt;p&gt;The (Barbara) Liskov Substitution principle states:&lt;/p&gt;  &lt;p&gt;&lt;cite&gt;If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T. &lt;/cite&gt;&lt;/p&gt;  &lt;p&gt;That hurts my head.&amp;#160; Let’s again go with the definition from “Agile Principles, Patterns, And Practices in C#” Robert C Martin and Micah Martin:&amp;#160; &lt;strong&gt;Subtypes must be substitutable for their base type&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;There are two angles from which I want to look at this principle. Let’s look at it first from a structural standpoint.&amp;#160; I’m going to reuse the refactored code from &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-openclosed-principle.html"&gt;my last post&lt;/a&gt; with a slight change.&amp;#160; Rather than having the conditions and actions implement the ISupportRules interface, they will be derived from an abstract class named RuleBase. This means our RulesEngine’s ExecuteRules method needs to accept a generic list of RuleBase.&lt;/p&gt;  &lt;p&gt;The Code:&lt;/p&gt;  &lt;p&gt;We have our enums :&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ae2ca189-afdb-4790-8dea-65ecbe2b5802" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; OpenClosePrinciple&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         CreateOrder,&lt;/li&gt;&lt;li&gt;         CreateBackorder,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         CloseOrder,&lt;/li&gt;&lt;li&gt;         ShipOrder,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         StoreOrder,&lt;/li&gt;&lt;li&gt;         ReduceInventory&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Conditions&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         IsComplete,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         IsInStock,&lt;/li&gt;&lt;li&gt;         CanShip&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         Condition,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         Action&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;An Action derived from RuleBase:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3d5be9b0-fa67-4c8a-bc9b-9bf2cc0e46ef" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; OpenClosePrinciple&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CreateOrderAction&lt;/span&gt;:&lt;span style="color:#2b91af"&gt;RuleBase&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; ISupportRules Members&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; Execute()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;override&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt; TypeOfRule()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Action;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;A Condition derived from RuleBase:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4adf8f0b-917c-449e-a29b-2d1f97f8585d" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; OpenClosePrinciple&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CanShipCondition&lt;/span&gt;:&lt;span style="color:#2b91af"&gt;RuleBase&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; ISupportRules Members&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; Execute()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;override&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt; TypeOfRule()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Condition;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;RuleBase:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:65739ec0-fa46-4f32-a5da-0a061ce66258" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; OpenClosePrinciple&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleBase&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; Execute()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;abstract&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt; TypeOfRule();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;The Rule Engine.&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09ad54e4-700f-4ea5-aa08-9ebc9e0df231" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; OpenClosePrinciple&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RefactoredRuleEngine&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ExecuteRules(&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;RuleBase&lt;/span&gt;&amp;gt; rules)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; ruleIndex = 0;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;while&lt;/span&gt; (executing)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (rules[ruleIndex].TypeOfRule() == &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Action)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 {&lt;/li&gt;&lt;li&gt;                     executing = rules[ruleIndex].Execute();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     ruleIndex++;&lt;/li&gt;&lt;li&gt;                 }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (rules[ruleIndex].Execute())&lt;/li&gt;&lt;li&gt;                     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         ruleIndex++;&lt;/li&gt;&lt;li&gt;                         executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     }&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     {&lt;/li&gt;&lt;li&gt;                         ruleIndex += 2;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 }&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#008000"&gt;//Implement some exit strategy here&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Our Base class simply supports an Execute and a RuleType Method.&amp;#160; Both our condition and Action class derive from RuleBase and may be “passed around” as a RuleBase and therefore we have satisfied the structural idea of being able to substitute a derived class for it’s base class.&lt;/p&gt;  &lt;p&gt;The second angle I want to look at this principle is from a behavioral perspective.&amp;#160; Most examples I read demonstrating an LSP violation use the Rectangle base class and the square subclass.&amp;#160;&amp;#160; Proof of the LSP violation is based on setting the length and width of the Square to unique values then discovering that an assert in a unit test that calculates a rectangles area returns an incorrect result.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;I agree that this is a violation.&amp;#160; I believe the problem lies in the claim that a square “is-a” rectangle.&amp;#160; Now don’t go running to a dictionary and grab the definition of a rectangle and tell me that a square fits the definition of a rectangle – I’m not talking about the English language.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The classic implementation of the rectangle when discussing the LSP principle is to expose a Width and a Height property and a CalculateArea method which returns Width X Height.&amp;#160; This makes sense.&amp;#160; The problem in claiming that the Square “is-a” Rectangle is that with a Square there is not a notion of a Width &lt;strong&gt;&lt;em&gt;and&lt;/em&gt;&lt;/strong&gt; a Height that are different.&amp;#160; The Width and Height must be the same.&amp;#160; It doesn’t make sense to expose 2 properties, it is misleading and a consumer can logically assume that they would be independent properties.&amp;#160; But in the implementation of the square this is not the case.&amp;#160; Our Square is not (logically) a Rectangle because it does not have a Length and Width that are independent of each other.&lt;/p&gt;  &lt;p&gt;To consider whether our design above has violated LSP from a behavior standpoint we have to take a look at the RuleEngine.&amp;#160; At a glance it looks like we have a violation, notice that we have some logic in the engine that concerns itself with the RuleType.&lt;/p&gt;  &lt;p&gt;if (rules[ruleIndex].TypeOfRule() == RuleType.Action) …&lt;/p&gt;  &lt;p&gt;This does have the “smell” of bad code that we need to constantly look for but I maintain that if we take a closer look this is NOT a violation.&amp;#160; When we cooked up the notion of the RuleEngine we decided we would support 2 types of rules, Conditions and Actions.&amp;#160; It is reasonable to do this.&amp;#160; We would never get our code out the door if we didn’t put some constraints on the types of rules we could support.&amp;#160; The line of code in question is simply executing code based on whether it is a condition or an action. &lt;/p&gt;  &lt;p&gt;An example of code that &lt;strong&gt;would&lt;/strong&gt; violate LSP or OCP would be as follows:&lt;/p&gt;  &lt;p&gt;if (TypeOf(rules[ruleIndex]) == CanShipCondition) &lt;/p&gt;  &lt;p&gt;Here we are trying to execute logic based on the derived type which is a violation of OCP and LSP.&amp;#160; The consumer of the base class would not have to worry about the derived type if the derived type was substitutable for it’s base class and by worrying about derived types, the rules engine is no longer open for extension.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html" target="_blank"&gt;My design review checklist&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-1795801341616952466?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/1795801341616952466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/design-review-liskov-substitution.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/1795801341616952466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/1795801341616952466'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/09/design-review-liskov-substitution.html' title='Design Review – Liskov Substitution Principle'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-892616796751295996</id><published>2009-08-29T10:17:00.001-05:00</published><updated>2009-08-29T10:21:21.550-05:00</updated><title type='text'>Calling a WCF Service from JavaScript</title><content type='html'>&lt;p&gt;I spent the last couple of days working with SketchUp, WCF, and JavaScript.&amp;#160; SketchUp is a really cool tool for creating, modifying, and sharing 3D models.&amp;#160; I am certainly not a modeling expert but I do have some experience working with 3D models and I have to say I am was impressed with the free version.&amp;#160; The pro version is only $500.&amp;#160; While this is not a trivial sum of money, it is very affordable compared to some of the packages I have seen.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;My job was to create a web service that could be called using JavasSript.&amp;#160; I will mention that this was a proof of concept and I specifically did not address security.&amp;#160; The following code will work but there is no security of any kind so if the resulting service is exposed to the internet, anybody can call it.&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The first thing I did was use the create WCF project wizard.&amp;#160; I wasn’t particularly worried about passing&amp;#160; complex data types at this point so I defined a simple Service Contract.&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8d91ebcc-2f79-4b9f-bfce-dc144a29f3b5" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Web;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; WcfModelService&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     [&lt;span style="color:#2b91af"&gt;ServiceContract&lt;/span&gt;(Namespace = &lt;span style="color:#a31515"&gt;"WcfModelService"&lt;/span&gt;)]&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IModel&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {        &lt;/li&gt;&lt;li&gt;         [&lt;span style="color:#2b91af"&gt;OperationContract&lt;/span&gt;]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         [&lt;span style="color:#2b91af"&gt;WebGet&lt;/span&gt;]&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; GetData(&lt;span style="color:#0000ff"&gt;int&lt;/span&gt; value);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         [&lt;span style="color:#2b91af"&gt;OperationContract&lt;/span&gt;]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         [&lt;span style="color:#2b91af"&gt;WebGet&lt;/span&gt;]&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; HelloWorld();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         [&lt;span style="color:#2b91af"&gt;OperationContract&lt;/span&gt;]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         [&lt;span style="color:#2b91af"&gt;WebGet&lt;/span&gt;]&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; HelloSomeone(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; message);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;When you apply the WebGet attribute to&amp;#160; a service contract decorated with the OperationContract attribute you are adding some extra metadata to the operation.&amp;#160; This metadata doesn’t actually do anything unless a service behavior is looking for it.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Here is the implementation:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b3acea46-3e8a-4d75-84b0-c53b46667f58" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: auto; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.ServiceModel.Activation;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; WcfModelService&lt;/li&gt;&lt;li&gt; {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     [&lt;span style="color:#2b91af"&gt;AspNetCompatibilityRequirements&lt;/span&gt;(RequirementsMode = &lt;span style="color:#2b91af"&gt;AspNetCompatibilityRequirementsMode&lt;/span&gt;.Allowed)]&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Model&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IModel&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; IModel Members&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; GetData(&lt;span style="color:#0000ff"&gt;int&lt;/span&gt; value)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;"You entered: {0}"&lt;/span&gt;, value);&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; HelloWorld()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Hello World."&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; HelloSomeone(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; message)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Hello World and "&lt;/span&gt; + message + &lt;span style="color:#a31515"&gt;" too."&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;As I mentioned, adding the WebGet attribute doesn’t actually have any effect on our ability to call the service via JavaScript unless we have a service behavior that will use the metadata.&amp;#160; In our configuration file we add the AjaxBehavior.&amp;#160; Notice the enableWebScript element in the behavior.&amp;#160; This is logically equivalent to adding the ScriptService attribute to an ASMX service.&amp;#160; The final thing we need to do is to expose an endpoint using the webHttpBinding.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:477ab913-748b-42a1-a8ae-6b756d1831cb" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: auto; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceHostingEnvironment&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;aspNetCompatibilityEnabled&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/li&gt;&lt;li&gt;     &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;services&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;service&lt;/span&gt;&lt;span style="color:#0000ff"&gt;  &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;WcfModelService.Model&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;                 &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;endpoint&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;address&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;""&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;webHttpBinding&lt;/span&gt;"&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;contract&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;WcfModelService.IModel&lt;/span&gt;"&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;AjaxBehavior&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;endpoint&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;             &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;service&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;services&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;         &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;                 &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;AjaxBehavior&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;           &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;enableWebScript&lt;/span&gt;&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/li&gt;&lt;li&gt;                 &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt;         &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;behaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;All we have left to do now is to call the service from JavaScript.&amp;#160; We will keep things simple and add a ScriptManager with a ServiceReference to the Model service.&amp;#160; Now in JavaScript create the service proxy:&lt;/p&gt;  &lt;p&gt;var proxy = new WcfModelService.IModel()&lt;/p&gt;  &lt;p&gt;and call an operation:&lt;/p&gt;  &lt;p&gt;proxy.HelloSomeone(s2, onSuccess, onFail, null);&amp;#160; &lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:788f1794-62b6-4334-a144-ea1f49927e2c" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 45px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="background:#ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;@&lt;/span&gt; &lt;span style="color:#a31515"&gt;Page&lt;/span&gt; &lt;span style="color:#ff0000"&gt;Language&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="C#"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="true"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;CodeBehind&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="WcfTest.aspx.cs"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;Inherits&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="WcfModelService.Test"&lt;/span&gt; &lt;span style="background:#ffee62"&gt;%&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color:#a31515"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color:#ff0000"&gt;html&lt;/span&gt; &lt;span style="color:#ff0000"&gt;PUBLIC&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;html&lt;/span&gt; &lt;span style="color:#ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="http://www.w3.org/1999/xhtml"&amp;gt;&lt;/li&gt;&lt;li&gt; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;head&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;Wcf AJAX Service Client Page&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;script&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="text/javascript"&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;     &lt;span style="color:#008000"&gt;// This function creates an asynchronous call to the service&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; makeCall(operation){&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; n1 = document.getElementById(&lt;span style="color:#a31515"&gt;"num1"&lt;/span&gt;).value;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; s2 = document.getElementById(&lt;span style="color:#a31515"&gt;"string1"&lt;/span&gt;).value;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;/li&gt;&lt;li&gt;         &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;// Instantiate a service proxy&lt;/span&gt;&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; proxy = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; WcfModelService.IModel();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;// Call correct operation on proxy       &lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;switch&lt;/span&gt;(operation){&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Data"&lt;/span&gt;:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     proxy.GetData( parseInt(n1),  onSuccess, onFail, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);            &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;break&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Hello"&lt;/span&gt;:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     proxy.HelloWorld( onSuccess, onFail, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);                        &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;break&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Someone"&lt;/span&gt;:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     proxy.HelloSomeone(s2, onSuccess, onFail, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);            &lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;break&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;     &lt;span style="color:#008000"&gt;// This function is called when the result from the service call is received&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; onSuccess(callResult){&lt;/li&gt;&lt;li&gt;         document.getElementById(&lt;span style="color:#a31515"&gt;"result"&lt;/span&gt;).value = callResult;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#008000"&gt;// This function is called if the service call fails&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; onFail(){&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         document.getElementById(&lt;span style="color:#a31515"&gt;"result"&lt;/span&gt;).value = &lt;span style="color:#a31515"&gt;"Error"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;     &lt;span style="color:#008000"&gt;// ]]&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;script&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;style&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="text/css"&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#a31515"&gt;#num1&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;303px&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#a31515"&gt;#string1&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;317px&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#a31515"&gt;#result&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;333px&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#a31515"&gt;#btnData&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;118px&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#a31515"&gt;#btnHelloWorld&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;99px&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;head&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;body&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;h1&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         Wcf AJAX Service Client Page&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;h1&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         A Number:&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="text"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="num1"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;         A String:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="text"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="string1"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnData"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="button"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="return makeCall('Data');"&lt;/span&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#ff0000"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Get Data"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnHelloWorld"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="button"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="return makeCall('Hello');"&lt;/span&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#ff0000"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Hello"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="btnHelloSomeone"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="button"&lt;/span&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="return makeCall('Someone');"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="Hello Someone"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#ff0000"&gt;&amp;amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;       Result:&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="text"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="result"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;form&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="aForm"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;action&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=""&lt;/span&gt; &lt;span style="color:#ff0000"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="server"&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;ScriptManager&lt;/span&gt; &lt;span style="color:#ff0000"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="ScriptManager"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="server"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Services&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;ServiceReference&lt;/span&gt; &lt;span style="color:#ff0000"&gt;Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;="~/Model.svc"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Services&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;ScriptManager&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;form&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;body&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li&gt; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;html&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Here is an ASMX version of the same service.&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d74d0868-e2bc-46df-b5f7-0ce4d0e641c7" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Web;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Web.Services;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Web.Script.Services;&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; AsmxModelService&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; {&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; Summary description for AsmxModelService&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#808080"&gt;///&lt;/span&gt;&lt;span style="color:#008000"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     [&lt;span style="color:#2b91af"&gt;WebService&lt;/span&gt;(Namespace = &lt;span style="color:#a31515"&gt;"WcfModelService"&lt;/span&gt;)]&lt;/li&gt;&lt;li&gt;     [&lt;span style="color:#2b91af"&gt;WebServiceBinding&lt;/span&gt;(ConformsTo = &lt;span style="color:#2b91af"&gt;WsiProfiles&lt;/span&gt;.BasicProfile1_1)]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     [System.ComponentModel.&lt;span style="color:#2b91af"&gt;ToolboxItem&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;false&lt;/span&gt;)]&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#008000"&gt;// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. &lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     [System.Web.Script.Services.&lt;span style="color:#2b91af"&gt;ScriptService&lt;/span&gt;]&lt;/li&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;AsmxModelService&lt;/span&gt; : System.Web.Services.&lt;span style="color:#2b91af"&gt;WebService&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         [&lt;span style="color:#2b91af"&gt;WebMethod&lt;/span&gt;]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         [&lt;span style="color:#2b91af"&gt;ScriptMethod&lt;/span&gt;(UseHttpGet = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;,ResponseFormat = &lt;span style="color:#2b91af"&gt;ResponseFormat&lt;/span&gt;.Json)]&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; GetData(&lt;span style="color:#0000ff"&gt;int&lt;/span&gt; value)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;"You entered: {0}"&lt;/span&gt;, value);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         [&lt;span style="color:#2b91af"&gt;WebMethod&lt;/span&gt;]&lt;/li&gt;&lt;li&gt;         [&lt;span style="color:#2b91af"&gt;ScriptMethod&lt;/span&gt;(UseHttpGet = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;, ResponseFormat = &lt;span style="color:#2b91af"&gt;ResponseFormat&lt;/span&gt;.Json)]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; HelloWorld()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Hello World"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         [&lt;span style="color:#2b91af"&gt;WebMethod&lt;/span&gt;]&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         [&lt;span style="color:#2b91af"&gt;ScriptMethod&lt;/span&gt;(UseHttpGet = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;, ResponseFormat = &lt;span style="color:#2b91af"&gt;ResponseFormat&lt;/span&gt;.Json)]&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; HelloSomeone(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; message)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"Hello World and "&lt;/span&gt; + message + &lt;span style="color:#a31515"&gt;" too."&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     }&lt;/li&gt;&lt;li&gt; }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;If you need to secure the call, we could force the user to login before accessing the aspx page containing the JavaScript service call.&amp;#160; An Authentication cookie will now be passed to the application with each request.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;By setting aspNetCompatibilityEnabled=true we can access the identity using a call to HttpContext.Current.User.Identity.Name.&amp;#160; Each operation should now verify the user is authorized to make the call before executing the operation logic.&lt;/p&gt;  &lt;p&gt;Reference:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/magazine/cc793961.aspx#id0070025" href="http://msdn.microsoft.com/en-us/magazine/cc793961.aspx#id0070025"&gt;http://msdn.microsoft.com/en-us/magazine/cc793961.aspx#id0070025&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-892616796751295996?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/892616796751295996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/calling-wcf-from-javascript.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/892616796751295996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/892616796751295996'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/calling-wcf-from-javascript.html' title='Calling a WCF Service from JavaScript'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-3914853336261900437</id><published>2009-08-15T07:41:00.001-05:00</published><updated>2009-08-15T07:41:30.076-05:00</updated><title type='text'>Extraction Rules</title><content type='html'>&lt;h4&gt;&lt;a name="_Toc214186864"&gt;Adding an Extraction Rule&lt;/a&gt;&lt;/h4&gt;  &lt;p&gt;Right click the request and select Add Extraction Rule…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Soas79uuZXI/AAAAAAAAADY/xoJ6y33fpAY/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/Soas8RRiz6I/AAAAAAAAADc/B67FYaQlEAY/image_thumb%5B1%5D.png?imgmax=800" width="372" height="274" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Fill out the properties in the popup. And select Ok.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/Soas819YNHI/AAAAAAAAADg/6yr_KqMhIiU/s1600-h/image%5B7%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/Soas9BCXRWI/AAAAAAAAADk/zGnnzy7k4rg/image_thumb%5B3%5D.png?imgmax=800" width="380" height="291" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h4&gt;&lt;a name="_Toc214186865"&gt;Using an Extracted parameter&lt;/a&gt;&lt;/h4&gt;  &lt;p&gt;You can use an extracted parameter in requests following the request where the parameter was extracted. You can do several things with this extracted value for example add a query string variable to a request or add a form post parameter:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_04HDQqptby8/Soas9adhtOI/AAAAAAAAADo/1ir7wN2S24w/s1600-h/image%5B14%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Soas9tT_fuI/AAAAAAAAADs/o1o9VbD6Hw0/image_thumb%5B6%5D.png?imgmax=800" width="388" height="162" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Soas95G6QsI/AAAAAAAAADw/lipRVMlAn2c/s1600-h/image%5B15%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/Soas-UaW3QI/AAAAAAAAAD0/f_l6nsWmHPE/image_thumb%5B7%5D.png?imgmax=800" width="393" height="183" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:93dacef8-b5ba-4bc7-9e3a-946e6655c327" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/VSTT" rel="tag"&gt;VSTT&lt;/a&gt;,&lt;a href="http://technorati.com/tags/VSTS+Team+Test" rel="tag"&gt;VSTS Team Test&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Extraction+Rules" rel="tag"&gt;Extraction Rules&lt;/a&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-3914853336261900437?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/3914853336261900437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/extraction-rules.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3914853336261900437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3914853336261900437'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/extraction-rules.html' title='Extraction Rules'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_04HDQqptby8/Soas8RRiz6I/AAAAAAAAADc/B67FYaQlEAY/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-6617713210514610831</id><published>2009-08-09T16:04:00.002-05:00</published><updated>2009-08-09T16:06:37.903-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VSTT'/><category scheme='http://www.blogger.com/atom/ns#' term='VSTS Test Edition'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Test'/><title type='text'>Creating an ASMX web service web test with VSTS 2008</title><content type='html'>&lt;p&gt;Right click on the test project and select Add &amp;gt; Web Test… &lt;/p&gt;&lt;p&gt;IE will be opened with the Web Test Recorder available on the left side.&lt;/p&gt;&lt;p&gt;Click the stop button.&lt;/p&gt;&lt;p&gt;Right Click on the webtest node and select Add Web Service Request.&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Sn85tvMpmOI/AAAAAAAAACo/hYlq82mAgQM/s1600-h/clip_image002%5B4%5D.jpg"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://lh4.ggpht.com/_04HDQqptby8/Sn85uGVAHGI/AAAAAAAAACs/8pW3ILPMn5M/clip_image002_thumb%5B1%5D.jpg?imgmax=800" width="380" height="201" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Fill out the properties in the properties window.&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Sn85ucT7UrI/AAAAAAAAACw/Ur8rgW3VcZY/s1600-h/image%5B7%5D.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_04HDQqptby8/Sn85u4dHT6I/AAAAAAAAAC0/q_X2KR4VhE0/image_thumb%5B3%5D.png?imgmax=800" width="407" height="270" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If you include the full path to the web method under test, the web method query variable will be extracted and created for you. &lt;/p&gt;&lt;p&gt;&lt;i&gt;(example: http://localhost/VSTSLoadTest/VstsLoadTestWebService.asmx?&lt;b&gt;op=ReverseTheString&lt;/b&gt;).&lt;a href="http://lh3.ggpht.com/_04HDQqptby8/Sn85vBmvfpI/AAAAAAAAAC4/mefiqV11BPo/s1600-h/image%5B6%5D.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/Sn85vT6SCWI/AAAAAAAAAC8/MbGiraiFY1o/image_thumb%5B2%5D.png?imgmax=800" width="412" height="78" /&gt;&lt;/a&gt; &lt;/i&gt;&lt;/p&gt;&lt;p&gt;Assemble the soap request (I suggest using Internet Explorer to browse the web service and capture a sample soap request.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_04HDQqptby8/Sn85v__TAZI/AAAAAAAAADA/0Jl6FmmPItI/s1600-h/image%5B11%5D.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_04HDQqptby8/Sn85wfoXkxI/AAAAAAAAADE/cjWdRpVGjb8/image_thumb%5B5%5D.png?imgmax=800" width="419" height="258" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Drill down into the web request to fill out the String Body properties.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Sn85wi8ygCI/AAAAAAAAADI/Di48Iup6yP0/s1600-h/image%5B23%5D.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/Sn85xD6PwGI/AAAAAAAAADM/BAdt9_J9KKU/image_thumb%5B15%5D.png?imgmax=800" width="408" height="285" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Set the content type to text/XML.&lt;/p&gt;&lt;p&gt;Click the ellipses button on the string body.&lt;/p&gt;&lt;p&gt;Paste the soap request into the popup – make sure and modify the placeholders with actual values.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_04HDQqptby8/Sn85xi1OPbI/AAAAAAAAADQ/hmc-IxkHb34/s1600-h/image%5B27%5D.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_04HDQqptby8/Sn85xyxYMiI/AAAAAAAAADU/zO6kWc9zrrI/image_thumb%5B17%5D.png?imgmax=800" width="415" height="332" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-6617713210514610831?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/6617713210514610831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/creating-asmx-web-service-web-test-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6617713210514610831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/6617713210514610831'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/creating-asmx-web-service-web-test-with.html' title='Creating an ASMX web service web test with VSTS 2008'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_04HDQqptby8/Sn85uGVAHGI/AAAAAAAAACs/8pW3ILPMn5M/s72-c/clip_image002_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-777667885974023755</id><published>2009-08-03T00:40:00.002-05:00</published><updated>2009-08-03T07:11:48.462-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Development'/><category scheme='http://www.blogger.com/atom/ns#' term='VSTS Test Edition'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Staying current</title><content type='html'>&lt;p&gt;As an &lt;a href="https://www.intertech.com/Consulting/Consulting.aspx"&gt;Intertech consultant&lt;/a&gt; I am asked to do all kinds of things.  Architect applications, code in C#, code in VB.Net, write SSRS reports, write TFS Team build test scripts, work with VSTS GDR database scripts the list goes on and on and that suites me just fine.  Jumping around and doing so many different things is a challenge and once I get up the learning curve on something I don’t want to lose it.  Here are a couple things I do to keep my skills sharp.&lt;/p&gt;&lt;p&gt;I recently earned my&lt;b&gt; &lt;/b&gt;MCPD Enterprise Application Developer on the 3.5 framework.  Even if you don’t think much of certifications, the real value for me was reading all of the 4500 or so pages of the Microsoft training kits and doing a couple hundred exercises.  I was introduced to some things I would never have considered had I not gone through this process.  Another great way to stay sharp is going to local users groups.&lt;/p&gt;&lt;p&gt;I’m a big fan of VSTS Test Edition but that sort of work only comes along every couple months.  To stay sharp in this area I have gotten active on the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vstswebtest/threads"&gt;Web test and load test forums&lt;/a&gt; (TimJim is my display name; you will also find me on the General Architecture and WCF forums).  I try to answer a question that has gone unanswered for a while every day or so. It keeps me sharp and it is a great way to help the user community. The user base seems to be relatively small right now and this is a tool I don’t want to see go away. I was blown away by the preview I got of the 2010 version and I expect the user base to grow substantially with that release. I also keep my VSTS skills sharp by frequenting the &lt;a href="http://vstsmn.net/"&gt;VSTS Minnesota users group.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Finally, I have a massive book collection. I try to read 4 or 5 technical books a year but good old classroom education is hard to beat.  Back in my days as a manager I always budgeted some training dollars but we only seemed to actually see the inside of a classroom every few years.   At Intertech I am required (yes &lt;em&gt;required&lt;/em&gt;!) to get 40 hours of training per year.  A couple weeks ago I took Intertech’s &lt;a href="http://www.intertech.com/Courses/Course.aspx?CourseID=99330"&gt;WPF&lt;/a&gt; class and went through our &lt;a href="http://www.intertech.com/Courses/Course.aspx?CourseID=99428"&gt;Silverlight&lt;/a&gt; training material.  I had the opportunity to do some Silverlight work right away.  I was delighted with how well the class prepared me for the actual work I had to do and I definitely hit the ground running.  I also have to say I was pleasantly surprised to find out how feature rich Silverlight is.  I’m sure I’ll be blogging on these subjects soon.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-777667885974023755?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/777667885974023755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/staying-current.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/777667885974023755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/777667885974023755'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/staying-current.html' title='Staying current'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-7580760078468348088</id><published>2009-08-02T23:49:00.003-05:00</published><updated>2009-08-03T08:33:00.733-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VSTS Test Edition'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Test'/><category scheme='http://www.blogger.com/atom/ns#' term='Load test'/><title type='text'>More VSTS 2008 Team Test Edition Tips and tricks.</title><content type='html'>&lt;p&gt;It has been about a month since I posted any VSTS Test edition tips or tricks. Here is a few I think are particularly important.&lt;/p&gt;&lt;h4&gt;BEST PRACTICE: Can we copy/paste (and rename) web tests if we want to? What effect does this have on the data source? Is it advisable from a source control standpoint?&lt;/h4&gt;&lt;p&gt;Doing a copy, paste, or rename operation is totally fine. The data source will have to be added again to copied tests. Consider using extract web test rather than copy. Extracting a webtest is a way of grouping a request or requests into another callable web test.   This is a very powerful feature. If you make 3 copies of a web test and the test has to change, you will have to modify all three copies of that test. Rather than doing a copy paste, use the extract web test functionality.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Go to the test editor window &lt;/li&gt;&lt;li&gt;Select the first request you want to include in the test &lt;/li&gt;&lt;li&gt;Right click and select Extract Web Test… &lt;/li&gt;&lt;li&gt;Enter a meaningful name in the text box &lt;/li&gt;&lt;li&gt;The top drop down will contain the first request to include in the test &lt;/li&gt;&lt;li&gt;Use the second drop down to select the final request you want to include in the test &lt;/li&gt;&lt;li&gt;Check both check boxes at the bottom of the dialog &lt;/li&gt;&lt;li&gt;Select OK &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;In the Test Editor you will see that the requests that you extracted are removed and replaced with a single request that points to another web test.&lt;/p&gt;&lt;p&gt;Now if you need to change that test you change it in one single place. This test may also be included in any other web test by right clicking in the test editor and selecting Insert Call to Web Test…&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h4&gt;Can a web test record pop-ups?&lt;/h4&gt;&lt;p&gt;If you are having difficulty recording pop-ups using the web recorder, try using &lt;a href="http://www.blogger.com/www.fiddlertool.com"&gt;Fiddler&lt;/a&gt; to capture the HTTP traffic. Once you are done executing your test and capturing the http traffic in fiddler, &lt;/p&gt;&lt;ul&gt;&lt;li&gt;highlight the requests, &lt;/li&gt;&lt;li&gt;Right click and select save select Session(s) select as Visual Studio Web Test (&lt;a href="http://blogs.msdn.com/vstsqualitytools/archive/2006/12/21/testing-web-applications-with-pop-ups.aspx"&gt;http://blogs.msdn.com/vstsqualitytools/archive/2006/12/21/testing-web-applications-with-pop-ups.aspx&lt;/a&gt;) &lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;&lt;a name="_Toc230084012"&gt;BEST PRACTICE: Use validation levels&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;During a standalone web test you want to run all validations but during a load test you want to only run the most critical validations so you can leave the client or agents to do the work they are intended to do – load the server. Execution of validation rules in a load test has impact on performance. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The default validation rule level of a&lt;/strong&gt; &lt;strong&gt;request is “high”.&lt;/strong&gt; When you create a load test you can specify what level of validation rules you want to execute under the Run Settings node. &lt;strong&gt;The default rule validation level of the load test is “low”&lt;/strong&gt; therefore if you do nothing with validation levels no validations will be executed during a load test.&lt;/p&gt;&lt;p&gt;If you want to run a validation rule during a load test you want to change the validation level on the most critical rules to ‘‘low’’. In this case low&lt;em&gt; &lt;/em&gt;means that it is a low-level, or fundamental, verification; &lt;i&gt;low &lt;/i&gt;does &lt;i&gt;not &lt;/i&gt;refer to the priority of the verification. Setting the level to ‘‘high’’ means that it will &lt;i&gt;only &lt;/i&gt;be run if the load test has been set to a validation level of ‘‘high’’.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="top" width="200"&gt;Load test level&lt;/td&gt;&lt;td valign="top" width="200"&gt;Validations that will run&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="top" width="200"&gt;Low&lt;/td&gt;&lt;td valign="top" width="200"&gt;Low&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="top" width="200"&gt;Medium&lt;/td&gt;&lt;td valign="top" width="200"&gt;Low, Medium&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="top" width="200"&gt;High&lt;/td&gt;&lt;td valign="top" width="200"&gt;Low, Medium, High&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-7580760078468348088?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/7580760078468348088/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/more-vsts-2008-team-test-edition-tips.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7580760078468348088'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/7580760078468348088'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/08/more-vsts-2008-team-test-edition-tips.html' title='More VSTS 2008 Team Test Edition Tips and tricks.'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-2781861387965613818</id><published>2009-07-25T16:26:00.002-05:00</published><updated>2009-07-25T20:48:44.087-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Development'/><category scheme='http://www.blogger.com/atom/ns#' term='Management'/><title type='text'>Bootlegging</title><content type='html'>&lt;p&gt;Remember back in the days of prohibition when a person wanted a beer they had to know the secret knock to get into the backroom of a club concealed by a false bookcase?  Me neither. I’m talking about &lt;a href="http://en.wikipedia.org/wiki/Bootlegging_%28business%29"&gt;permitted bootlegging&lt;/a&gt; in the business sense of the word.&lt;/p&gt;&lt;p&gt;As I mentioned in my bio I spent 8 or 9 years of my career managing a team of developers.  One of the first policies I implemented as a manager was permitted bootlegging.  I encouraged every one of my developers to spend 10% of their time working on a software project of their choice that had nothing to do with the standard product we were building.  I got the idea from my dad who worked for 3M.  Software Developers can be odd ducks (to other people – us developers think you are the odd duck) and like most development organizations we had several kinds of developers.   I’m going to use a broad brush and group them into 3 categories. &lt;/p&gt;&lt;p&gt;We had people that insisted on pounding out code 12 hours a day 7 days a week.  These folks could do amazing things in short periods of times.  They could get a late project back on track or whip out a feature in no time.  It is a luxury to have one or two of these people on your team as nobody can reasonably ask for anyone to work these kinds of hours.  The difficulty in managing this sort of person was if you pointed them in the wrong direction look out!  They were a bit like  rhinos in that they would very quickly blaze a trail through the code base doing all kinds of “damage”.  Check in with these folks early and often to make sure they are doing what you think they are doing. They don’t like to undo hours upon hours of work because of a miscommunication and who can blame them?   It is also quite a challenge keeping them busy.  We’ll call this group the rhinos.&lt;/p&gt;&lt;p&gt;Another group of developers wanted to be told exactly what to do, when to have it done, and to be left alone.  They will let you know if they have a problem and won’t tend to try to move forward with something they don’t understand – it is just not in their nature.  They don’t care too much about what they are assigned to work on as long as it is in their comfort zone. These are the people that can tend to fly under the radar so make sure and share credit for your success with these folks.  You need a lot of these people on your team. We’ll call this group the workhorses.&lt;/p&gt;&lt;p&gt;The final group of people I want to talk about could probably best be described as the mad scientists.  These are the kinds of people that are not happy unless they are challenged.  These are the folks you want working on critical parts of the framework.  You would go over a problem with them in painful detail and turn them loose.  They would disappear into their dark laboratory only to return days, weeks, or months later when they were done.  Schedule means very little to these folks because…well…it is not done until it is done!  You want one or &lt;em&gt;maybe&lt;/em&gt; two of these people on your team but you can not afford more – you’d never get anything built.  The challenge with managing this type of person was that it was hard to schedule their activities and you don’t always have an interesting problem for them to work on.  Let’s call this group the Einsteins.&lt;/p&gt;&lt;p&gt;By way of an apology for pigeonholing these good people I will admit that the personality of every individual I managed really fit into all 3 of these groups to one degree or another (well maybe not the Einstein group).  My job was to figure out a way to get this crew to build software.  I had to ask the Einsteins to write mundane code, I had to keep the rhinos from running further ahead than we could test, I had to ask the workhorses to do work they weren't comfortable with.  So how do I keep the Einsteins challenged when they are doing mundane work, how do I keep the Rhinos out of the code during the definition phase and how do I get the workhorses to get comfortable doing something they have never been asked to do before?  That is where bootlegging comes in.  &lt;/p&gt;&lt;p&gt;The role that bootlegging played for the Einsteins was that it kept things interesting all the time.  I never had to encourage these folks to spread their wings and learn something new.  I used bootlegging as a way to keep them from leaving the company.  They knew that, I knew that, they appreciated it, and most importantly they never left the team.  For the rhinos I used bootlegging as a way to keep them busy during slow times.  At the end of the day what drives the rhino is they just want to be busy doing something useful.  Their bootleg projects were usually related to productivity tools.  Tools that made the development team more productive but had nothing to do with our product.  Workhorses were not wild about bootlegging.  I would really have to push a project onto a workhorse.  I would try to recognize a new technology or feature coming up in the project and use the bootlegging task as a way to introduce them to it.  To be honest, the bootleg projects didn’t mean much to these folks but it was always there if they wanted to use it.&lt;/p&gt;&lt;p&gt;As a manager I was very proud of the fact that I never had a developer leave my team to join another team.  I think giving each team member the freedom to work on whatever software project they wanted with 10% of their time was a big part of it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-2781861387965613818?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/2781861387965613818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/07/bootlegging.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/2781861387965613818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/2781861387965613818'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/07/bootlegging.html' title='Bootlegging'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk/S220/tjs.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-234416327021972627.post-3511981074945388614</id><published>2009-07-17T08:23:00.003-05:00</published><updated>2009-10-01T22:58:08.178-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Open Closed Principle'/><category scheme='http://www.blogger.com/atom/ns#' term='Design Review'/><category scheme='http://www.blogger.com/atom/ns#' term='OCP'/><title type='text'>Design Review and the Open/Closed Principle</title><content type='html'>&lt;p&gt;In &lt;a href="http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-single-responsibility.html"&gt;my last blog&lt;/a&gt; I talked about the Single Responsibility Principle. SRP it is an easy concept to understand but breaking down a system into the “correct” objects is difficult to do well. It is imprecise and there is a lot of room for opinions. You seldom know the correct breakdown until you are finished. In this blog I want to take a look at the OCP or Open/Closed Principle. The Open/Closed principle states that &lt;strong&gt;Software entities (classes, modules, functions etc.) should be open for extension but closed for change.&lt;/strong&gt; (“Agile Principles, Patterns, And Practices in C#” Robert C Martin and Micah Martin). In other words this means that we would like to be able to change the behavior of existing entities without changing the code or binary assembly. This concept is not as easy to understand. Did I just say to change something without changing it? &lt;/p&gt;  &lt;p&gt;Let’s use a configurable rule engine as an example. Assume the simple rule engine has 2 types of entities, a Condition and an Action. The Action is simple, execute some logic and return true on success or false on failure. The condition is also simple, it checks some binary condition and returns true or false. The rules engine takes a list of conditions and actions and executes them. If an Action returns false, the rules stop executing and a rollback is performed. If a condition returns true, the next action is executed. If the condition is false, the next action is skipped and the following action is executed. Pretty simple so let’s look at some sample code:&lt;/p&gt;  &lt;p&gt;Define our Conditions, Actions, and Rule Type with enums&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d4b2d8d5-f67f-4310-962a-5352f0d0af5c" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         CreateOrder,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         CreateBackorder,&lt;/li&gt;&lt;li&gt;         CloseOrder,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         ShipOrder,&lt;/li&gt;&lt;li&gt;         StoreOrder,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         ReduceInventory&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Conditions&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         IsComplete,&lt;/li&gt;&lt;li&gt;         IsInStock,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         CanShip&lt;/li&gt;&lt;li&gt;     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;&lt;/li&gt;&lt;li&gt;     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         Condition,&lt;/li&gt;&lt;li&gt;         Action&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Here is a &lt;em&gt;&lt;u&gt;very&lt;/u&gt;&lt;/em&gt; &lt;em&gt;&lt;u&gt;crude&lt;/u&gt;&lt;/em&gt; implementation of a rule engine&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; width: 402px; padding-right: 5px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:843483de-9bc3-49d8-a42c-a3f27473ec83" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleEngine&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ExecuteRules(&lt;span style="color:#0000ff"&gt;int&lt;/span&gt; rulesId)&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//Gather all the conditions and actions&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//assume we have a Ruleset table that looks like this:&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//ID - Int&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//Index - Int&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//RuleType - Int (corresponds to RuleTypeEnum)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//Rule - Int (corresponds to Conditions or Actions enum)&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//Note, transaction logic, creating the parameter&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#008000"&gt;//Error handling, and safe DataReader.Read() logic&lt;/span&gt;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//has been omitted for brevity&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;SqlConnection&lt;/span&gt; connection = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;SqlConnection&lt;/span&gt;(&lt;span style="color:#a31515"&gt;"ConnectString"&lt;/span&gt;))&lt;/li&gt;&lt;li&gt;             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; ( &lt;span style="color:#2b91af"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;SqlCommand&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     (&lt;span style="color:#a31515"&gt;"SELECT RuleType, Rule FROM Ruleset where ID = ? ORDER BY Index"&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     , connection))&lt;/li&gt;&lt;li&gt;                 {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#2b91af"&gt;SqlDataReader&lt;/span&gt; rules = cmd.ExecuteReader();&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;while&lt;/span&gt; (executing)&lt;/li&gt;&lt;li&gt;                     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         &lt;/li&gt;&lt;li&gt;                         rules.Read();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; ((&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)rules[0] == (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Action)&lt;/li&gt;&lt;li&gt;                         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                             executing = ExecuteAction((&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)rules[1]);&lt;/li&gt;&lt;li&gt;                         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt;(ExecuteCondition((&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)(rules[1])))&lt;/li&gt;&lt;li&gt;                             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                                 executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                             &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                             {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                                 rules.Read();&lt;/li&gt;&lt;li&gt;                                 executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                             }&lt;/li&gt;&lt;li&gt;                         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         &lt;span style="color:#008000"&gt;//Implement some exit strategy here&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 }&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; ExecuteCondition(&lt;span style="color:#0000ff"&gt;int&lt;/span&gt; theCondition)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;switch&lt;/span&gt; (theCondition)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Conditions&lt;/span&gt;.IsComplete:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#008000"&gt;//Is the order complete?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Conditions&lt;/span&gt;.CanShip:&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#008000"&gt;//Can we ship the order?&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Conditions&lt;/span&gt;.IsInStock:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#008000"&gt;//Is this item in stock?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;default&lt;/span&gt;:&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515"&gt;"Unsupported Condition"&lt;/span&gt;);&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; ExecuteAction(&lt;span style="color:#0000ff"&gt;int&lt;/span&gt; theAction)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;switch&lt;/span&gt; (theAction)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;.CreateOrder:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#008000"&gt;//Execute order create logic&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;.CreateBackorder:&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#008000"&gt;//Execute backorder logic&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;.ShipOrder:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#008000"&gt;//Execute shipping logic&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;.StoreOrder:&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#008000"&gt;//send to warehouse&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;.CloseOrder:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#008000"&gt;//Execute order close logic&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;case&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)&lt;span style="color:#2b91af"&gt;Actions&lt;/span&gt;.ReduceInventory:&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#008000"&gt;//Remove item from inventory&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;            &lt;span style="color:#008000"&gt;//or false&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;default&lt;/span&gt;:&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color:#a31515"&gt;"Unsupported Action"&lt;/span&gt;);&lt;/li&gt;&lt;li&gt;             }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Never mind the problems with error handling, transactions, and the lack of support for nested conditions, the point of the blog is OCP, not creating a rule engine. What we have will work but does it satisfy the OCP? No, there are a couple problems with this type of implementation that will make it difficult to maintain. The first problem is that the logic for the Rule Engine, Conditions, and Actions are all in one class and therefore one assembly. Any system that wants to use &lt;em&gt;any&lt;/em&gt; of this logic will be tied to &lt;em&gt;all&lt;/em&gt; of this logic. The second problem is that any time you want the rule engine to do something new, you have to modify this assembly which is a violation of the Open/Closed Principle.&lt;/p&gt;  &lt;p&gt;Let’s take a look at a more robust design.&lt;/p&gt;  &lt;p&gt;We will still use an enum to distinguish between Actions and Conditions:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8ac1a879-7413-4555-9239-ddc21e51699e" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 25px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         Condition,&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         Action&lt;/li&gt;&lt;li&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Now let’s declare an interface&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31ba25a2-1bbd-470a-9e65-704ac8ec93da" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 25px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ISupportRules&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; Execute();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt; TypeOfRule();&lt;/li&gt;&lt;li&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;We will put both the enum and the Interface in an assembly called Rule.Types.&lt;/p&gt;  &lt;p&gt;Now lets add a few classes&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:99a4a75f-cea0-4d0f-9d44-1ce3c5e6e455" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CreateOrderAction&lt;/span&gt;:&lt;span style="color:#2b91af"&gt;ISupportRules&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; ISupportRules Members&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; Execute()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//Order Create Logic Here&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt; TypeOfRule()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Action;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;We will put this in an assembly called Rule.Actions.CreateOrder.&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d3ef9c2f-2121-429b-bf98-1f0cacc5f2e1" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CanShipCondition&lt;/span&gt;:&lt;span style="color:#2b91af"&gt;ISupportRules&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     {&lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;        #region&lt;/span&gt; ISupportRules Members&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; Execute()&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#008000"&gt;//Execute Can Ship Logic here&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt; TypeOfRule()&lt;/li&gt;&lt;li&gt;         {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Condition;&lt;/li&gt;&lt;li&gt;         }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt; &lt;/li&gt;&lt;li&gt; &lt;span style="color:#0000ff"&gt;        #endregion&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;We will put this class in Rules.Conditions.CanShip.&lt;/p&gt;  &lt;p&gt;In fact we will create a separate assembly for each condition and action we defined in the enums. &lt;/p&gt;  &lt;p&gt;Here is our new rules engine which goes in the Rule.Engine assembly:&lt;/p&gt;  &lt;div style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e537e26b-5cfd-4006-8772-81651cb48d28" class="wlWriterEditableSmartContent"&gt;&lt;br /&gt;&lt;div style="border: #000080 1px solid; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;&lt;br /&gt;&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;&lt;br /&gt;&lt;div style="background: #ddd; max-height: 500px; overflow: scroll; padding: 0"&gt;&lt;br /&gt;&lt;ol style="background: #ffffff; margin: 0 0 0 35px; white-space: nowrap"&gt;&lt;br /&gt;&lt;li&gt;         &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ExecuteRules(&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;ISupportRules&lt;/span&gt;&amp;gt; rules)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         {&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; ruleIndex = 0;&lt;/li&gt;&lt;li&gt;             &lt;span style="color:#0000ff"&gt;while&lt;/span&gt; (executing)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             {&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (rules[ruleIndex].TypeOfRule() == &lt;span style="color:#2b91af"&gt;RuleType&lt;/span&gt;.Action)&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 {&lt;/li&gt;&lt;li&gt;                     executing = rules[ruleIndex].Execute();&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     ruleIndex++;&lt;/li&gt;&lt;li&gt;                 }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li&gt;                 {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (rules[ruleIndex].Execute())&lt;/li&gt;&lt;li&gt;                     {&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         ruleIndex++;&lt;/li&gt;&lt;li&gt;                         executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     }&lt;/li&gt;&lt;li&gt;                     &lt;span style="color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                     {&lt;/li&gt;&lt;li&gt;                         ruleIndex += 2;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                         executing = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;                     }&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;                 }&lt;/li&gt;&lt;li&gt;                 &lt;span style="color:#008000"&gt;//Implement some exit strategy here&lt;/span&gt;&lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;             }&lt;/li&gt;&lt;li&gt; &lt;/li&gt;&lt;li style="background: #f3f3f3"&gt;         }&lt;/li&gt;&lt;li&gt;     \&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;p&gt;Notice that the ExecuteRules method takes a generic list of type ISupportRules as a parameter but has no reference to any of the conditions or actions. Also notice that the condition and action classes have no reference to each other or the rules engine. This is key to both code reuse and extensibility. the refactored rule engine, condition, and action classes are completely independent of each other. All they share is a reference to Rule.Type. Some other system may use any of these assemblies independent of each other with the only caveat being they will need to reference the Rule.Type assembly. The other thing we gained with this approach is we can now &lt;em&gt;Extend&lt;/em&gt; the rule engine (make it execute new conditions and actions) by simply adding a new Condition or Action that implements ISupportRules and passing it into the ExecuteRules method as a part of the generic list. We can do all of this without recompiling the RefactoredRulesEngine which is the goal of the OCP. By the way, this design approach is called the Strategy Pattern.&lt;/p&gt;  &lt;p&gt;If you haven’t noticed yet I’m leaving out one major piece of the puzzle. How does the generic list of rules get generated? I’m going to wave my hands here a little bit and save the details for another blog. We would use a creational pattern (one of the factory patterns). If we assume we are consuming the table outlined in our first solution this factory would accept a Ruleset ID and magically return the generic List&amp;lt;IsupportRules&amp;gt; of rules. The implementation of the factory pattern could be written in such a way that each time you add a Condition or an Action the factory would need to be recompiled or we could use a provider pattern and use a configuration file to allow us to create these new Conditions and Actions without a recompile. &lt;/p&gt;  &lt;p&gt;To summarize things a bit: conceptually we have this RulesEngine that is relatively complex (much more complex than I have written) and we want to write it, test it, and leave it alone. At the same time though we have this need to enhance the system by adding more rules. By using using the strategy pattern we now have this stable rule execution engine that can execute any condition or action that implements the ISupprotRules interface. Because we inject a list of conditions and rules into the ExecuteRules method we can do all of this without recompiling the refactored rules engine. Another approach we might have taken to satisfy the OCP is the Template Method pattern. In the template method pattern we would make use of an abstract class to define the skeleton of an algorithm, then allow the concrete classes to implement subclass specific operations. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://timsbrownbaglunch.blogspot.com/2009/09/design-and-code-review-checklist.html" target="_blank"&gt;My design review checklist&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One of my favorite design pattern web sites: &lt;a href="http://www.dofactory.com/Patterns/Patterns.aspx"&gt;http://www.dofactory.com/Patterns/Patterns.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/234416327021972627-3511981074945388614?l=timsbrownbaglunch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://timsbrownbaglunch.blogspot.com/feeds/3511981074945388614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-openclosed-principle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3511981074945388614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/234416327021972627/posts/default/3511981074945388614'/><link rel='alternate' type='text/html' href='http://timsbrownbaglunch.blogspot.com/2009/07/design-review-and-openclosed-principle.html' title='Design Review and the Open/Closed Principle'/><author><name>Tim Star</name><uri>http://www.blogger.com/profile/00198407484532036006</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://4.bp.blogspot.com/_04HDQqptby8/SkjwTL_lhoI/AAAAAAAAAAU/4SDny1CjbWk
