<?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-5204554931543429996</id><updated>2012-01-12T05:35:13.193-05:00</updated><category term='C#'/><category term='Haskell'/><category term='Blend'/><category term='MVVM'/><category term='Prism'/><category term='Functional Programming'/><category term='CDS'/><category term='Expression'/><category term='PLINQ'/><category term='Parallel Extensions'/><category term='Project Euler'/><category term='TPL'/><category term='Behavior'/><category term='F#'/><category term='General Programming'/><category term='Design Patterns'/><category term='WPF'/><category term='WPF Graphics'/><category term='XAML'/><title type='text'>sparky.dasrath</title><subtitle type='html'>[Veritas Vos Liberabit]</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>65</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-2026368699640667505</id><published>2011-02-21T20:37:00.001-05:00</published><updated>2011-02-21T20:37:30.102-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='General Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>[2011.02.21] ReSharper C# snippet for MVVM ViewModel Property creation</title><content type='html'>&lt;div style="font-family: tahoma"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;p&gt;Here is a simple C# snippet for &lt;a href="http://www.jetbrains.com/resharper/"&gt;ReSharper&lt;/a&gt; (should work on most versions) to simplify the creation of ViewModel properties. It is clear that creating properties in the ViewModel can be a tedious and repetitive process, especially when there are several involved. To create the snippet, you need to add a new Live Template in R#. &lt;/p&gt;      &lt;p&gt;In Visual Studio under the ReSharper menu item, select LiveTemplates... and you will see Fig. 1. &lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/TWMTTcG04ZI/AAAAAAAAAsw/1C2w5MkDFrk/s1600-h/%5B2011.02.21%5D.ReSharper.snippet.01%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2011.02.21].ReSharper.snippet.01" border="0" alt="[2011.02.21].ReSharper.snippet.01" src="http://lh5.ggpht.com/_nJH2hOo32r8/TWMTTnfbn6I/AAAAAAAAAs0/q05HegQ-uTA/%5B2011.02.21%5D.ReSharper.snippet.01_thumb.png?imgmax=800" width="244" height="222" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.1 The Template Explorer window&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;Under the User Templates node, select the New Template option from the toolbar and you will be taken to the Template creation page. Here you can enter the shortcut used to toggle the snippet and a description. I used &lt;strong&gt;vmp&lt;/strong&gt; (&lt;strong&gt;V&lt;/strong&gt;iew&lt;strong&gt;M&lt;/strong&gt;odel &lt;strong&gt;P&lt;/strong&gt;roperty) for my shortcut here. Simply copy and paste the code below into the window and I will explain the changes you need to make. &lt;/p&gt; &lt;!--code --&gt;      &lt;div&gt;       &lt;div style="font-family: consolas; background: white; color: black; font-size: 10pt"&gt;         &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; $&lt;span style="color: red"&gt;TYPE&lt;/span&gt;$ &lt;span style="color: red"&gt;_&lt;/span&gt;$&lt;span style="color: red"&gt;NAMEFIELD&lt;/span&gt;$;&lt;/p&gt;          &lt;p style="margin: 0px"&gt;$&lt;span style="color: red"&gt;END&lt;/span&gt;$&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; $&lt;span style="color: red"&gt;TYPE&lt;/span&gt;$ $&lt;span style="color: red"&gt;NAME&lt;/span&gt;$&lt;/p&gt;          &lt;p style="margin: 0px"&gt;{&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: red"&gt;get&lt;/span&gt; {&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: red"&gt;_&lt;/span&gt;$&lt;span style="color: red"&gt;NAMEFIELD&lt;/span&gt;$; }&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: red"&gt;set&lt;/span&gt;&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt;(&lt;span style="color: red"&gt;_&lt;/span&gt;$&lt;span style="color: red"&gt;NAMEFIELD&lt;/span&gt;$ == &lt;span style="color: red"&gt;value&lt;/span&gt;) &lt;span style="color: blue"&gt;return&lt;/span&gt;;&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: red"&gt;_&lt;/span&gt;$&lt;span style="color: red"&gt;NAMEFIELD&lt;/span&gt;$ = &lt;span style="color: red"&gt;value&lt;/span&gt;;&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008b8b"&gt;OnPropertyChanged&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;$NAME$&amp;quot;&lt;/span&gt;);&lt;/p&gt;          &lt;p style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p style="margin: 0px"&gt;}&lt;/p&gt;       &lt;/div&gt;     &lt;/div&gt;      &lt;p&gt;The artifacts enclosed between dollar signs ($) can be thought of as variables that you can replace once the snippet has been activated. If we follow the naming convention of labeling fields starting with an underscore and all properties begin with uppcase letter, you will see that if you leave things the way they are as in Fig. 2, you will not get the anticipated result. &lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh3.ggpht.com/_nJH2hOo32r8/TWMTT0W4j7I/AAAAAAAAAs4/vjCSFb7DTBQ/s1600-h/%5B2011.02.21%5D.ReSharper.snippet.02%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2011.02.21].ReSharper.snippet.02" border="0" alt="[2011.02.21].ReSharper.snippet.02" src="http://lh4.ggpht.com/_nJH2hOo32r8/TWMTUAQUcuI/AAAAAAAAAs8/vjYwoe0e1a8/%5B2011.02.21%5D.ReSharper.snippet.02_thumb.png?imgmax=800" width="244" height="162" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.2 Editing the template&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;This is where the options in the right pane of the Template window comes into play. There are built in macros to help us get the correct set up. We want the $NAME$ to basically be like $_NAMEFIELD$ but without the underscore and the first letter must be upper case. So click the &amp;quot;Choose macro&amp;quot; option next to the NAME identifier in the right pane and from the list, as in Fig. 3, select:        &lt;br /&gt;&lt;i&gt;Value of another variable with the first character in upper case&lt;/i&gt; &lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/TWMTUgU6orI/AAAAAAAAAtA/aFAg1xE6iWE/s1600-h/%5B2011.02.21%5D.ReSharper.snippet.03%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2011.02.21].ReSharper.snippet.03" border="0" alt="[2011.02.21].ReSharper.snippet.03" src="http://lh6.ggpht.com/_nJH2hOo32r8/TWMTU8SLp8I/AAAAAAAAAtE/VECoX7x_XOM/%5B2011.02.21%5D.ReSharper.snippet.03_thumb.png?imgmax=800" width="231" height="244" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.3 Macro selection&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;After that, the Template window will look like Fig. 4. Note that we have not yet based the $NAME$ on the $_NAMEFIELD$ variable yet. &lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/TWMTVKB2tZI/AAAAAAAAAtI/P9tMZKg_zRU/s1600-h/%5B2011.02.21%5D.ReSharper.snippet.04%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2011.02.21].ReSharper.snippet.04" border="0" alt="[2011.02.21].ReSharper.snippet.04" src="http://lh6.ggpht.com/_nJH2hOo32r8/TWMTVWlxLKI/AAAAAAAAAtM/1y8-2B5_NOE/%5B2011.02.21%5D.ReSharper.snippet.04_thumb.png?imgmax=800" width="244" height="193" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.4 After setting the macro&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;Now click the &lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier,monospace; color: red"&gt;another variable&lt;/span&gt; link and you will get a dropdown list to select which variable $NAME$ should use as its basis. This is shown in Fig. 5. &lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/TWMTVv_qIQI/AAAAAAAAAtQ/SRyP9FVzRyM/s1600-h/%5B2011.02.21%5D.ReSharper.snippet.05%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2011.02.21].ReSharper.snippet.05" border="0" alt="[2011.02.21].ReSharper.snippet.05" src="http://lh4.ggpht.com/_nJH2hOo32r8/TWMTV-vRt7I/AAAAAAAAAtU/04yjMK5GAhg/%5B2011.02.21%5D.ReSharper.snippet.05_thumb.png?imgmax=800" width="244" height="114" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.5 Relating variables&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;Your snippet is now ready for action! &lt;/p&gt;      &lt;p&gt;&lt;strong&gt;NOTE: &lt;/strong&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier,monospace; color: #000000"&gt;OnPropertyChanged &lt;/span&gt;should be replaced by whatever method name you used when you implemented &lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier,monospace; color: #2c92af"&gt;INotifyPropertyChanged&lt;/span&gt;. For instance, you may have called yours &lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier,monospace; color: #000000"&gt;RaisePropertyChanged&lt;/span&gt; instead of &lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier,monospace; color: #000000"&gt;OnPropertyChanged&lt;/span&gt;, so modify the snippet to best suit your needs. &lt;/p&gt;   &lt;/div&gt; &lt;/div&gt; &lt;!-- END outer div --&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-2026368699640667505?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/2026368699640667505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=2026368699640667505' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/2026368699640667505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/2026368699640667505'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2011/02/20110221-resharper-c-snippet-for-mvvm.html' title='[2011.02.21] ReSharper C# snippet for MVVM ViewModel Property creation'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_nJH2hOo32r8/TWMTTnfbn6I/AAAAAAAAAs0/q05HegQ-uTA/s72-c/%5B2011.02.21%5D.ReSharper.snippet.01_thumb.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-8670756332115187800</id><published>2011-01-06T19:42:00.005-05:00</published><updated>2011-01-06T19:49:25.231-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>[2011.01.06] Drag and Drop in WPF using MVVMLight [IV/IV]</title><content type='html'>&lt;div style="font-family: tahoma;"&gt;&lt;!-- START outer div--&gt;&lt;!-- END outer div --&gt;   &lt;div&gt;&lt;a style="border-width: 0px;" href="http://www.mediafire.com/file/ar5mka95xi4di4y/DragDropUsingMvvmLight01.zip"&gt;&lt;img style="background-image: none; border: 0px none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="downloadCode02" alt="downloadCode02" src="http://lh3.ggpht.com/_nJH2hOo32r8/TSZhcIZA4LI/AAAAAAAAAso/29NmiD5lIvk/downloadCode02%5B2%5D.png?imgmax=800" border="0" height="21" width="244" /&gt;&lt;/a&gt; &lt;/div&gt;    &lt;div&gt;This is a multipart series outlining several topics is WPF.      &lt;ol&gt;       &lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110104-drag-and-drop-in-wpf-using.html"&gt;Part 1&lt;/a&gt;: MVVM via the MVVMLight framework &lt;/li&gt;        &lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110105-drag-and-drop-in-wpf-using.html"&gt;Part 2&lt;/a&gt;: Drag and Drop &lt;/li&gt;        &lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using.html"&gt;Part 3&lt;/a&gt;: The Adorner &lt;/li&gt;        &lt;li&gt;Part 4: DataTemplateSelector, StyleSelector, Unit Testing &lt;/li&gt;     &lt;/ol&gt;   &lt;/div&gt;    &lt;div&gt;&lt;!-- start data/style/test--&gt;     &lt;p&gt;In this final part, I will outline some other features that supplement the application and provides a better user experience. This was done primarily as a demonstration of the features, namely &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplateSelector&lt;/span&gt; and &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;StyleSelector&lt;/span&gt;. &lt;/p&gt;      &lt;h4&gt;The Data Template Selector&lt;/h4&gt;      &lt;p&gt;You use a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplateSelector&lt;/span&gt; to display data from the same collection differently, based on some criteria in the data. For example, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; type has a property, &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',courier,monospace;" &gt;Crew&lt;/span&gt;, which is a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Faction&lt;/span&gt; enumeration. Please take a look at the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; class in the code to download to see the definitions. In this case, I will use different &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;s&lt;/span&gt; based on which &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Faction&lt;/span&gt; each member belongs to. The different templates are defined in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;ResourceDictionary1.xaml&lt;/span&gt; file. &lt;/p&gt;      &lt;p&gt;You need to inherit from from the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplateSelector&lt;/span&gt; base class and &lt;span style="color: rgb(0, 0, 255);font-family:'Courier New',courier,monospace;" &gt;override&lt;/span&gt; the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datatemplateselector.selecttemplate.aspx"&gt;SelectTemplate()&lt;/a&gt; method. This is all illustrated in Listing 1. &lt;/p&gt;      &lt;div&gt;&lt;!-- start Listing 1--&gt;       &lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Controls&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Model&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Extended class used to change the data template of each ListBoxItem based on some custom requirement. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;FactionDataTemplateSelector&lt;/span&gt; : &lt;span style="color: rgb(0, 0, 139);"&gt;DataTemplateSelector&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DataTemplate&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;SelectTemplate&lt;/span&gt;(&lt;span style="color:blue;"&gt;object&lt;/span&gt; item, &lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt; container)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; frameworkElement = container &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;FrameworkElement&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (frameworkElement !=&lt;span style="color:blue;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; item &lt;span style="color:blue;"&gt;is&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; )&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;                 &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; contact = item &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;;  &lt;span style="color:green;"&gt;// Contact is the type hosted in each ListBoxItem&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (contact.&lt;span style="color:purple;"&gt;Crew&lt;/span&gt; == &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;                     &lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 139);"&gt;DataTemplate&lt;/span&gt;)frameworkElement.&lt;span style="color: rgb(0, 139, 139);"&gt;TryFindResource&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"SourceListBoxItemTemplate"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;                 &lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 139);"&gt;DataTemplate&lt;/span&gt;)frameworkElement.&lt;span style="color: rgb(0, 139, 139);"&gt;TryFindResource&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"SourceListBoxDataTemplate02"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt; }&lt;/p&gt;&lt;/pre&gt;      &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 1: Implementation of a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplateSelector&lt;/span&gt; &lt;/div&gt;    &lt;/div&gt;    &lt;h4&gt;The Style Selector&lt;/h4&gt;    &lt;p&gt;The reason and strategy follows the same pattern as in the template selector case, so I will just add the code to Listing 2 and let you take it from there. &lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Controls&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Model&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Extended class used to change the style of each ListBoxItem based on some custom requirement. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxStyleSelectors&lt;/span&gt; : &lt;span style="color: rgb(0, 0, 139);"&gt;StyleSelector&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Style&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;SelectStyle&lt;/span&gt;(&lt;span style="color:blue;"&gt;object&lt;/span&gt; item, &lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt; container)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;FrameworkElement&lt;/span&gt; frameworkElement = container &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;FrameworkElement&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (frameworkElement != &lt;span style="color:blue;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; item &lt;span style="color:blue;"&gt;is&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;                 &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; contact = item &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;; &lt;span style="color:green;"&gt;// Contact is the type hosted in each ListBoxItem&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (contact.&lt;span style="color:purple;"&gt;Crew&lt;/span&gt; == &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;                     &lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 139);"&gt;Style&lt;/span&gt;)frameworkElement.&lt;span style="color: rgb(0, 139, 139);"&gt;TryFindResource&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"SourceListBoxItemStyle1"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;                 &lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 139);"&gt;Style&lt;/span&gt;)frameworkElement.&lt;span style="color: rgb(0, 139, 139);"&gt;TryFindResource&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"SourceListBoxItemStyle2"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;null&lt;/span&gt;; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;         }   &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt; }&lt;/p&gt;&lt;/pre&gt;      &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 2: Implementation of a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;StyleSelector&lt;/span&gt; &lt;/div&gt;    &lt;/div&gt;    &lt;h4&gt;Unit Testing&lt;/h4&gt;    &lt;p&gt;I am brand spanking new at this. I only did tests for the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; model as I was not sure how to test the view models. I used &lt;a href="http://www.nunit.org/"&gt;NUnit&lt;/a&gt; as my testing framework. Thus far, I did not have to use any stubs or mocks. See Listing 3 for the code.&lt;br /&gt;   &lt;/p&gt;    &lt;div&gt;&lt;div    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; height: 500px; overflow: auto;font-family:consolas;font-size:8pt;color:black;"&gt;&lt;br /&gt;     &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Collections&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;ObjectModel&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;NUnit&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Framework&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Model&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Tests&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt; {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     [&lt;span style="color: rgb(0, 0, 139);"&gt;TestFixture&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ContactTests&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;     {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; &lt;span style="color:purple;"&gt;_contact&lt;/span&gt; = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Setup&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;SetUp&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;Setup&lt;/span&gt;()&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;         {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contact&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;();&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt; = &lt;span style="color:purple;"&gt;_contact&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts&lt;/span&gt;();&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;         }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;Test&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts_ReturnValueIsNotNull_ReturnsTrue&lt;/span&gt;()&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;         {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(&lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color:purple;"&gt;Not&lt;/span&gt;.&lt;span style="color:purple;"&gt;Null&lt;/span&gt;);&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;         }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;Test&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts_IsTypeofContact_ReturnsTrue&lt;/span&gt;()&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;         {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(&lt;span style="color:purple;"&gt;_contact&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;InstanceOf&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt;());   &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt;         }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;Test&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts_HasAtLeastOneItemInCollection_ReturnsTrue&lt;/span&gt;()&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;         {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(&lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;.&lt;span style="color:purple;"&gt;Count&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GreaterThanOrEqualTo&lt;/span&gt;(1));&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;         }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;Test&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts_ObjectIsInGoodState_ReturnsTrue&lt;/span&gt;()&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;         {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; contact = &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;[0];&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; firstNamePropertyIsNotNullOrEmpty = contact.&lt;span style="color:purple;"&gt;Name&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; lastNamePropertyIsNotNullOrEmpty = contact.&lt;span style="color:purple;"&gt;Alias&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; phonePropertyIsAValidNumber = contact.&lt;span style="color:purple;"&gt;Race&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; profileImageUrlPropertyIsNotNullOrEmpty = contact.&lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(&lt;span style="color:blue;"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;IsNullOrEmpty&lt;/span&gt;(firstNamePropertyIsNotNullOrEmpty), &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color:purple;"&gt;False&lt;/span&gt;);&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(&lt;span style="color:blue;"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;IsNullOrEmpty&lt;/span&gt;(lastNamePropertyIsNotNullOrEmpty), &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color:purple;"&gt;False&lt;/span&gt;);&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(phonePropertyIsAValidNumber, &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color:purple;"&gt;Not&lt;/span&gt;.&lt;span style="color:purple;"&gt;NaN&lt;/span&gt;);&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;Assert&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;That&lt;/span&gt;(&lt;span style="color:blue;"&gt;string&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;IsNullOrEmpty&lt;/span&gt;(profileImageUrlPropertyIsNotNullOrEmpty), &lt;span style="color: rgb(0, 0, 139);"&gt;Is&lt;/span&gt;.&lt;span style="color:purple;"&gt;False&lt;/span&gt;);&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt;         }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt; &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Teardown&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;TearDown&lt;/span&gt;]&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;Teardown&lt;/span&gt;()&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&gt;         {&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contact&lt;/span&gt; = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt;         }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;      &lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt;     }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt; }&lt;/p&gt;      &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt; &lt;/p&gt;    &lt;/div&gt;&lt;br /&gt;   &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 3: Unit tests for the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; model &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;The code looks mangled here due to a width of 460px and the long names of the test methods.&lt;/p&gt;  &lt;/div&gt;&lt;!-- end data/style/test--&gt;&lt;/div&gt;&lt;!-- END outer div --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-8670756332115187800?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/8670756332115187800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=8670756332115187800' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/8670756332115187800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/8670756332115187800'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using_06.html' title='[2011.01.06] Drag and Drop in WPF using MVVMLight [IV/IV]'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_nJH2hOo32r8/TSZhcIZA4LI/AAAAAAAAAso/29NmiD5lIvk/s72-c/downloadCode02%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-6777349614459888885</id><published>2011-01-06T19:37:00.004-05:00</published><updated>2011-01-06T20:00:20.370-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>[2011.01.06] Drag and Drop in WPF using MVVMLight [III/IV]</title><content type='html'>&lt;div style="font-family: tahoma;"&gt;&lt;!-- START outer div--&gt;&lt;!-- END outer div --&gt;   &lt;div&gt;&lt;a style="border-width: 0px;" href="http://www.mediafire.com/file/ar5mka95xi4di4y/DragDropUsingMvvmLight01.zip"&gt;&lt;img style="background-image: none; border: 0px none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="downloadCode02" alt="downloadCode02" src="http://lh4.ggpht.com/_nJH2hOo32r8/TSZgTZ2Qf9I/AAAAAAAAAsc/azNLHzMeZak/downloadCode02%5B2%5D.png?imgmax=800" border="0" height="21" width="244" /&gt;&lt;/a&gt; &lt;/div&gt;        &lt;div&gt;This is a multipart series outlining several topics is WPF.      &lt;ol&gt;       &lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110104-drag-and-drop-in-wpf-using.html"&gt;Part 1&lt;/a&gt;: MVVM via the MVVMLight framework &lt;/li&gt;        &lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110105-drag-and-drop-in-wpf-using.html"&gt;Part 2&lt;/a&gt;: Drag and Drop &lt;/li&gt;        &lt;li&gt;Part 3: The Adorner &lt;/li&gt;        &lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using_06.html"&gt;Part 4&lt;/a&gt;: DataTemplateSelector, StyleSelector, Unit Testing &lt;/li&gt;     &lt;/ol&gt;   &lt;/div&gt;    &lt;div&gt;&lt;!-- start adorner--&gt;     &lt;h4&gt;The Adorner&lt;/h4&gt;      &lt;p&gt;To provide a custom visual when doing the drag and drop, you can create an adorner. The look and feel of it can be anything you want, from a simple rectangle to something more complex. In this scenario, I want the dragged item to look exactly like the real item. First, recall that I am dragging the content of a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;, not the actual &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; itself. The content of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; is a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; type that is displayed using a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplate&lt;/span&gt;. Think about how the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; is shown in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; - if you look at the template in Blend, you will see as in Fig. 1, that each &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; contains nothing more than a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Border&lt;/span&gt; and a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ContentPresenter&lt;/span&gt;. This means that you can put whatever you want to be displayed in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ContentPresenter&lt;/span&gt;, which in this case will be a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplate&lt;/span&gt; &lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/TSZgT_JOUBI/AAAAAAAAAsg/XhOMLpfeVHA/s1600-h/%5B2011.01.03%5D.Drag.and.Drop.Using.MvvmLight.02%5B2%5D.png"&gt;&lt;img style="background-image: none; border: 0px none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="[2011.01.03].Drag.and.Drop.Using.MvvmLight.02" alt="[2011.01.03].Drag.and.Drop.Using.MvvmLight.02" src="http://lh5.ggpht.com/_nJH2hOo32r8/TSZgUWORGLI/AAAAAAAAAsk/njTV-AZ9UAI/%5B2011.01.03%5D.Drag.and.Drop.Using.MvvmLight.02_thumb.png?imgmax=800" border="0" height="127" width="244" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.1 A &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; template&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;Based on that, we can make the adorner a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ContentPresenter&lt;/span&gt; also and just fill it with the appropriate &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplate&lt;/span&gt; when doing the drag. You first need to inherit from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Adorner&lt;/span&gt;. Because you are creating a custom adorner, the doesn't know much about it, so you have to instruct the system how to size and lay it out on the screen. You do this by overriding several methods and a property. These are all shown in Listing 1. &lt;/p&gt;      &lt;div&gt;&lt;!-- start Listing 1--&gt;       &lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; height: 500px; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Controls&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Documents&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Media&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; An extended adorner class used to attach a visual element to a ListBoxItem as it is being dragged.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt; : &lt;span style="color: rgb(0, 0, 139);"&gt;Adorner&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ContentPresenter&lt;/span&gt; &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt; &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Point&lt;/span&gt; &lt;span style="color:purple;"&gt;_updatedMousePosition&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;UIElement&lt;/span&gt; adornedElement) : &lt;span style="color: rgb(0, 0, 139);"&gt;base&lt;/span&gt;(adornedElement)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ContentPresenter&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;             &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt; = adornedElement &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt; != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;                 &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;.&lt;span style="color:purple;"&gt;Content&lt;/span&gt; = &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;.&lt;span style="color:purple;"&gt;Content&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;                 &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;.&lt;span style="color:purple;"&gt;ContentTemplateSelector&lt;/span&gt; = &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;.&lt;span style="color:purple;"&gt;ContentTemplateSelector&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;.&lt;span style="color:purple;"&gt;Opacity&lt;/span&gt; = 0.7;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;         &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Size&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;MeasureOverride&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;Size&lt;/span&gt; constraint)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Measure&lt;/span&gt;(constraint);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;.&lt;span style="color:purple;"&gt;DesiredSize&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;         &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Size&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;ArrangeOverride&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;Size&lt;/span&gt; finalSize)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Arrange&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Rect&lt;/span&gt;(finalSize));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; finalSize;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;         &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Visual&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetVisualChild&lt;/span&gt;(&lt;span style="color:blue;"&gt;int&lt;/span&gt; index)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;_contentPresenter&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;         &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; &lt;span style="color:purple;"&gt;VisualChildrenCount&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; 1; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;GeneralTransform&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetDesiredTransform&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;GeneralTransform&lt;/span&gt; transform)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 139);"&gt;GeneralTransformGroup&lt;/span&gt; generalTransformGroup = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;GeneralTransformGroup&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt;             generalTransformGroup.&lt;span style="color:purple;"&gt;Children&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Add&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;TranslateTransform&lt;/span&gt;(&lt;span style="color:purple;"&gt;_updatedMousePosition&lt;/span&gt;.&lt;span style="color:purple;"&gt;X&lt;/span&gt;, &lt;span style="color:purple;"&gt;_updatedMousePosition&lt;/span&gt;.&lt;span style="color:purple;"&gt;Y&lt;/span&gt;));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; generalTransformGroup;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;UpdateAdornerPosition&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;Visual&lt;/span&gt; elementToGetAdornerLayerFrom, &lt;span style="color: rgb(0, 0, 139);"&gt;Point&lt;/span&gt; updatedPosition)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt;             &lt;span style="color:green;"&gt;// save the new position of the mouse that is passed in as an arguement as you drag the adorner &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt;             &lt;span style="color:purple;"&gt;_updatedMousePosition&lt;/span&gt; = updatedPosition;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adornerLayer = &lt;span style="color: rgb(0, 0, 139);"&gt;AdornerLayer&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdornerLayer&lt;/span&gt;(elementToGetAdornerLayerFrom);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (adornerLayer != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   65&lt;/span&gt;                 adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;Update&lt;/span&gt;(&lt;span style="color:purple;"&gt;AdornedElement&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   66&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   67&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   68&lt;/span&gt; }&lt;/p&gt;&lt;/pre&gt;      &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 1: The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DraggedAdorner&lt;/span&gt; class &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;The constructor of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DraggedAdorner&lt;/span&gt; class takes the element that is to be adorned. We need that to extract information from that we want to add to this adorner - namely it's content. Notice that the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',courier,monospace;" &gt;ContentTemplateSelector&lt;/span&gt; property was also set. This was done because I have multiple &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataTemplates&lt;/span&gt; that are used based on some custom logic. I will go into that later. &lt;/p&gt;  &lt;p&gt;As its name implies, the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;UpdateAdornerPosition()&lt;/span&gt; method will take the current mouse position and call the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Update()&lt;/span&gt; method. Notice in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;GetDesiredTransform()&lt;/span&gt; method, I am adding a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TranslateTransform&lt;/span&gt; to the transform group. This is what will update the position of the adorner as it is moved across the screen. &lt;/p&gt;    &lt;p&gt;Adding and removing the adorner as the application runs is provided by utility methods in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainViewModel&lt;/span&gt; class as shown in Listing 2.&lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; height: 500px; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  145&lt;/span&gt; &lt;span style="color:blue;"&gt;#region&lt;/span&gt; Helper Methods&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  146&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  147&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  148&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Adds an adorner to an element. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  149&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  150&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="elementToAdorn"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Element to add an adorner to.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  151&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="elementToGetAdornerLayerFrom"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Element to get the AdornerLayer from.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  152&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;example&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;In the case of the ListBox, if you want to adorn each ListBoxItem and the adorner layer of the &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  153&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; containing ListBox is used, then the adorner object gets clipped as it is moved out of the ListBox. In this case,&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  154&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; you need a layer that is higher up the visual tree to allow the adorner to be visible anywhere and not be clipped.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  155&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/example&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  156&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;AddAdorner&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;UIElement&lt;/span&gt; elementToAdorn, &lt;span style="color: rgb(0, 0, 139);"&gt;Visual&lt;/span&gt; elementToGetAdornerLayerFrom)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  157&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  158&lt;/span&gt;             &lt;span style="color:green;"&gt;// get the adorner layer to attach the adorner to&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  159&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adornerLayer = &lt;span style="color: rgb(0, 0, 139);"&gt;AdornerLayer&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdornerLayer&lt;/span&gt;(elementToGetAdornerLayerFrom);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  160&lt;/span&gt;             &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt;(elementToAdorn);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  161&lt;/span&gt;             adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;Add&lt;/span&gt;(&lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  162&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  163&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  164&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  165&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Removes an adorner from an element.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  166&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  167&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="adornedElement"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;The element that has an adorner associated with it.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  168&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; /// &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="elementToGetAdornerLayerFrom"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Element to get the AdornerLayer from.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  169&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;RemoveAdorner&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;UIElement&lt;/span&gt; adornedElement, &lt;span style="color: rgb(0, 0, 139);"&gt;Visual&lt;/span&gt; elementToGetAdornerLayerFrom)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  170&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  171&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adornerLayer = &lt;span style="color: rgb(0, 0, 139);"&gt;AdornerLayer&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdornerLayer&lt;/span&gt;(elementToGetAdornerLayerFrom);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  172&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adorners = adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdorners&lt;/span&gt;(adornedElement);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  173&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  174&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (adorners == &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  175&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  176&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; dragAdorner = adorners[0] &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  177&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (dragAdorner != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  178&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  179&lt;/span&gt;                 adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;Remove&lt;/span&gt;(dragAdorner);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  180&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  181&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  182&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;      &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 1: Methods to add and remove a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DraggedAdorner&lt;/span&gt; &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;So at this stage there is an adorner and ways to add, update its position and remove it from the application. In addition, &lt;a href="http://sdasrath.blogspot.com/2011/01/20110105-drag-and-drop-in-wpf-using.html"&gt;Part 2&lt;/a&gt; of this series suggests where to perform each of these operations.&lt;br /&gt;&lt;/p&gt;&lt;!-- end adorner--&gt;&lt;/div&gt;&lt;!-- END outer div --&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-6777349614459888885?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/6777349614459888885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=6777349614459888885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/6777349614459888885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/6777349614459888885'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using.html' title='[2011.01.06] Drag and Drop in WPF using MVVMLight [III/IV]'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_nJH2hOo32r8/TSZgTZ2Qf9I/AAAAAAAAAsc/azNLHzMeZak/s72-c/downloadCode02%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-1509822122244266700</id><published>2011-01-05T23:52:00.010-05:00</published><updated>2011-01-06T19:59:27.838-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>[2011.01.05] Drag and Drop in WPF using MVVMLight [II/IV]</title><content type='html'>&lt;div style="font-family: tahoma;"&gt;&lt;!-- START outer div--&gt;     &lt;div&gt;&lt;a href="http://www.mediafire.com/file/ar5mka95xi4di4y/DragDropUsingMvvmLight01.zip" style="border-width: 0px;"&gt;&lt;img alt="downloadCode02" src="http://lh3.ggpht.com/_nJH2hOo32r8/TSZhcIZA4LI/AAAAAAAAAso/29NmiD5lIvk/downloadCode02%5B2%5D.png?imgmax=800" style="background-image: none; border: 0px none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="downloadCode02" border="0" height="21" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;This is a multipart series outlining several topics is WPF  &lt;div&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110104-drag-and-drop-in-wpf-using.html"&gt;Part 1&lt;/a&gt;: MVVM via the MVVMLight framework &lt;/li&gt;&lt;li&gt;Part 2: Drag and Drop &lt;/li&gt;&lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using.html"&gt;Part 3&lt;/a&gt;: The Adorner &lt;/li&gt;&lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using_06.html"&gt;Part 4&lt;/a&gt;: DataTemplateSelector, StyleSelector, Unit Testing &lt;/li&gt; &lt;/ol&gt;&lt;/div&gt;    &lt;div&gt;&lt;!-- start d and d section --&gt;     &lt;h4&gt;Drag and Drop&lt;/h4&gt;      &lt;p&gt;MSDN has a section called &lt;a href="http://msdn.microsoft.com/en-us/library/ms742859.aspx"&gt;Drag and Drop Overview&lt;/a&gt; but as far as I can tell, it only outlines what to do with the data you are moving around. You can also get more D&amp;amp;D info from:&lt;br /&gt;&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;Jaime Rodriguez - Drag and Drop in WPF Explained End to End &lt;a href="http://blogs.msdn.com/b/jaimer/archive/2007/07/12/drag-drop-in-wpf-explained-end-to-end.aspx"&gt;Part 1&lt;/a&gt; &lt;a href="http://blogs.msdn.com/b/jaimer/archive/2007/07/12/drag-drop-in-wpf-part2.aspx"&gt;Part 2&lt;/a&gt; &lt;a href="http://blogs.msdn.com/b/jaimer/archive/2007/07/12/drag-drop-in-wpf-part-3-the-results-and-code.aspx"&gt;Part 3&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;Bea Stollnitz - &lt;a href="http://bea.stollnitz.com/blog/?p=53"&gt;How can I drag and drop items between data bound ItemsControls?&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;Clarity Consulting - &lt;a href="http://blogs.claritycon.com/blogs/lee_roth/archive/2009/04/06/wpf-drag-and-drop-between-itemscontrols.aspx"&gt;WPF Drag and Drop Between ItemsControls&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;Code Project - &lt;a href="http://www.codeproject.com/KB/WPF/WpfDragAndDropSmorgasbord.aspx"&gt;WPF Drag-and-Drop Smorgasbord&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;Marlon Grech - Drag Drop using Listboxes &lt;a href="https://marlongrech.wordpress.com/2007/12/28/drag-drop-using-listboxes-part-1/"&gt;Part 1&lt;/a&gt; &lt;a href="https://marlongrech.wordpress.com/2007/12/29/drag-drop-using-listboxes-part-2/"&gt;Part 2&lt;/a&gt; &lt;/li&gt;        &lt;li&gt;Chrisitan Mosers - &lt;a href="http://www.wpftutorial.net/DragAndDrop.html"&gt;Drag and Drop in WPF&lt;/a&gt; &lt;/li&gt;     &lt;/ul&gt;      &lt;p&gt;&lt;a href="http://www.wpftutorial.net/DragAndDrop.html"&gt;Christian Mosers's post on WPF Tutorial.net&lt;/a&gt; has the steps you need to follow to do Drag and Drop. I did mine slightly differently and I will list (re-hash) the steps he outlined basically, but for my scenario. &lt;/p&gt;      &lt;ol&gt;       &lt;li&gt;Determine if you are initiating a drag/drop operation either as a combination of &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MouseLeftButtonDown &lt;/span&gt;and &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MouseMove &lt;/span&gt;or just &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MouseLeftButtonDown &lt;/span&gt;as I have done. &lt;/li&gt;        &lt;li&gt;Determine what data is to be dragged and store that in a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataObject &lt;/span&gt;by passing in a format and the data to the constructor. See MSDN's &lt;a href="http://msdn.microsoft.com/en-us/library/ms742859.aspx"&gt;Drag and Drop Overview&lt;/a&gt; for more information regarding &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataObject&lt;/span&gt;. &lt;/li&gt;        &lt;li&gt;&lt;strong&gt;Add adorner:&lt;/strong&gt; If you want to provide rich visual feedback during the drag operation, adding an adorner can be done at this stage. &lt;/li&gt;        &lt;li&gt;Call the static &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragDrop&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;.DoDragDrop()&lt;/span&gt; passing in the source of the drag (a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem &lt;/span&gt;in this case), the actual data to be dragged and an appropriate &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragDropEffects&lt;/span&gt; enumeration [&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.dragdropeffects.aspx"&gt;see MSDN&lt;/a&gt;].  &lt;br /&gt;&lt;strong&gt;Note: &lt;/strong&gt;Steps 1-4 can all be done in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MouseLeftButtonDown &lt;/span&gt;handler as I have outlined in the demo. &lt;/li&gt;        &lt;li&gt;Set the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',courier,monospace;" &gt;AllowDrop&lt;/span&gt; property on elements that you want to be able to drop on. In this case, I made both the source and target &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;s&lt;/span&gt; droppable. The property is set in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;MainWindow.xaml&lt;/span&gt; file. &lt;/li&gt;        &lt;li&gt;Handle either the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragEnter &lt;/span&gt;or &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragOver &lt;/span&gt;event. Test in this handler if you are passing over an element that has it's &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',courier,monospace;" &gt;AllowDrop&lt;/span&gt; property set and that is accepts the type of data that is being dragged. Do this check by calling the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;GetDataPresent()&lt;/span&gt; method on the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragEventArgs &lt;/span&gt;parameter. &lt;/li&gt;        &lt;li&gt;&lt;strong&gt;Update Adorner:&lt;/strong&gt; If you are using a custom adorner, this is a good place to update its position on the screen as it is dragged around. &lt;/li&gt;        &lt;li&gt;Finally, handle the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Drop&lt;/span&gt; event when the user releases the mouse button. If the drop is done on a target that is expecting it and the correct data format is used, then retrieve the dragged &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataObject&lt;/span&gt; and do whatever you need to with it at this point. You get the data by accessing the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',courier,monospace;" &gt;Data&lt;/span&gt; property on the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragEventArgs&lt;/span&gt; parameter and calling the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;GetData()&lt;/span&gt; method.  &lt;br /&gt;&lt;/li&gt;        &lt;li&gt;&lt;strong&gt;Remove Adorner:&lt;/strong&gt; If you are using a custom adorner, once the drop is complete, this is a good place to remove it. &lt;/li&gt;     &lt;/ol&gt;      &lt;p&gt;Fig. 1 shows what the application looks like.&lt;/p&gt;      &lt;div&gt;&lt;!-- start image table--&gt;       &lt;table style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;" cellspacing="1"&gt;&lt;tbody&gt;           &lt;tr&gt;             &lt;td&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/TSVKqdFGRII/AAAAAAAAAsU/61aV6v5v6lY/s1600-h/%5B2011.01.03%5D.Drag.and.Drop.Using.MvvmLight.01%5B2%5D.png"&gt;&lt;img style="background-image: none; border: 0px none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="[2011.01.03].Drag.and.Drop.Using.MvvmLight.01" alt="[2011.01.03].Drag.and.Drop.Using.MvvmLight.01" src="http://lh6.ggpht.com/_nJH2hOo32r8/TSVKqkK28iI/AAAAAAAAAsY/Y15iFUUzj5w/%5B2011.01.03%5D.Drag.and.Drop.Using.MvvmLight.01_thumb.png?imgmax=800" border="0" height="163" width="244" /&gt;&lt;/a&gt;&lt;/td&gt;           &lt;/tr&gt;            &lt;tr&gt;             &lt;td&gt;Fig.1 Drag and Drop&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;     &lt;/div&gt; &lt;!-- end image table--&gt;      &lt;p&gt;Let's take a closer look at each of the main points in the drag and drop operation. Listing 1 shows the markup with the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; elements and the associated events that necessary for D&amp;amp;D. Notice the use of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;EventToCommand&lt;/span&gt; behavior here. &lt;/p&gt;      &lt;div&gt;&lt;!-- start Listing 1 --&gt;       &lt;pre    style="border: 1px solid silver; height: 500px; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;dragSource&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="1"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinWidth&lt;/span&gt;&lt;span style="color:blue;"&gt;="100"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinHeight&lt;/span&gt;&lt;span style="color:blue;"&gt;="40"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Margin&lt;/span&gt;&lt;span style="color:blue;"&gt;="0,0,0,0"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;AllowDrop&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;AliceBlue&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemContainerStyleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;styleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsPanel&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;SourceListBoxItemsPanelTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsSource&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Contacts&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;dataTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Style&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ListBoxStyle1&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% yellow;color:purple;" &gt;EventName&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% yellow;color:blue;" &gt;="PreviewMouseLeftButtonDown"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PreviewMouseLeftButtonDownCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% green;color:purple;" &gt;EventName&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% green;color:blue;" &gt;="DragOver"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% orange;color:purple;" &gt;EventName&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% orange;color:blue;" &gt;="Drop"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DropSourceCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Border&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="2"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="20" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;TextBlock&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="3"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;           &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;White&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   65&lt;/span&gt;           &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;FontSize&lt;/span&gt;&lt;span style="color:blue;"&gt;="18"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   66&lt;/span&gt;           &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;="Listbox to drop to" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   67&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   68&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;dropTarget&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   69&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="4"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   70&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinWidth&lt;/span&gt;&lt;span style="color:blue;"&gt;="100"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   71&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinHeight&lt;/span&gt;&lt;span style="color:blue;"&gt;="117"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   72&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Margin&lt;/span&gt;&lt;span style="color:blue;"&gt;="0,0,0,0"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   73&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;AllowDrop&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   74&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="#FFE4F3FD"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   75&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemContainerStyleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;styleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   76&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsPanel&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;SourceListBoxItemsPanelTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   77&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsSource&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;TargetContacts&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   78&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;dataTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   79&lt;/span&gt;         &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Style&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ListBoxStyle1&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   80&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   81&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% orange;color:purple;" &gt;EventName&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% orange;color:blue;" &gt;="Drop"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   82&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DropTargetCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   83&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   84&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% green;color:purple;" &gt;EventName&lt;/span&gt;&lt;span style="background: none repeat scroll 0% 0% green;color:blue;" &gt;="DragOver"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   85&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   86&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   87&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   88&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;     &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 1: Markup showing the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;s&lt;/span&gt; and the events used for Drag and Drop &lt;/div&gt;    &lt;/div&gt;    &lt;h4&gt;Steps 1-7: Drag&lt;/h4&gt;    &lt;p&gt;The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;PreviewMouseLeftButtonDown &lt;/span&gt;is a good place to determine if you want to begin a drag operation. The logic of what happens in this event is shown in Listing 2. In this case, I want to drag the data in a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;, so first I needed to get a reference to the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; that fired the mouse event as shown in Lines 76-77.&lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   72&lt;/span&gt; &lt;span style="color:purple;"&gt;PreviewMouseLeftButtonDownCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;MouseButtonEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   73&lt;/span&gt;                     e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   74&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   75&lt;/span&gt;                         &lt;span style="color:green;"&gt;// get dragged listbox&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   76&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt; listBox = e.&lt;span style="color:purple;"&gt;Source&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   77&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt; listBoxItem = &lt;span style="color: rgb(0, 0, 139);"&gt;VisualHelper&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;FindAncestor&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt;&amp;gt;((&lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt;)e.&lt;span style="color:purple;"&gt;OriginalSource&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   78&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   79&lt;/span&gt;                         &lt;span style="color:green;"&gt;// set up shared states&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   80&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt; = listBoxItem;         &lt;span style="color:green;"&gt;// adorned element&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   81&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt; = &lt;span style="color: rgb(0, 139, 139);"&gt;GetTopLevelGrid&lt;/span&gt;(e); &lt;span style="color:green;"&gt;// element to get an adorner layer from higher up the logical tree than the listboxitem&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   82&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   83&lt;/span&gt;                         &lt;span style="color:green;"&gt;// Find the data behind the listBoxItem&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   84&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (listBox == &lt;span style="color:blue;"&gt;null&lt;/span&gt; || listBoxItem == &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   85&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   86&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; contact = (&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;)listBox.&lt;span style="color:purple;"&gt;ItemContainerGenerator&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;ItemFromContainer&lt;/span&gt;(listBoxItem);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   87&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   88&lt;/span&gt;                         &lt;span style="color: rgb(0, 139, 139);"&gt;AddAdorner&lt;/span&gt;(listBoxItem, &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   89&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   90&lt;/span&gt;                         &lt;span style="color:green;"&gt;// Initialize the drag &amp;amp; drop operation&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   91&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;DataObject&lt;/span&gt; dragData = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DataObject&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myContactData"&lt;/span&gt;, contact);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   92&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;DragDrop&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;DoDragDrop&lt;/span&gt;(listBoxItem, dragData, &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropEffects&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Move&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   93&lt;/span&gt;                     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   94&lt;/span&gt;                 );&lt;/p&gt;&lt;/pre&gt;      &lt;div style="text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; color: rgb(0, 0, 0); font-size: small;"&gt;Listing 2: Command to deal with the dragging part of the operation. &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;In Line 77, I am using a helper method to actually pinpoint the correct &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; as shown in Listing 3. To create a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataObject&lt;/span&gt;, I first needed to grab the data contained in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; as shown in Line 86 by calling the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ItemFromContainer&lt;/span&gt; method on the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',courier,monospace;" &gt;ItemContainerGenerator&lt;/span&gt; property of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;. In Line 88, the adorner I used to help visualize the dragging operation is added. Lines 91-92 creates the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DataObject&lt;/span&gt; to be dragged and then call the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;DoDragDrop&lt;/span&gt; method. &lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Media&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Walks up the visual tree to find the ancestor of a given type.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;     &lt;span style="color:blue;"&gt;internal&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;VisualHelper&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Recursive method to walk up the visual tree to return an ancestor type of the supplied type.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;typeparam name="T"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Type of ancestor to search for.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="current"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Type to start search from.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;         &lt;span style="color:blue;"&gt;internal&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;T&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;FindAncestor&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;T&lt;/span&gt;&amp;gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt; current) &lt;span style="color:blue;"&gt;where&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;T&lt;/span&gt; : &lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;             &lt;span style="color:blue;"&gt;do&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (current &lt;span style="color:blue;"&gt;is&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;T&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;                 {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;                     &lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 139);"&gt;T&lt;/span&gt;)current;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;                 }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;                 current = &lt;span style="color: rgb(0, 0, 139);"&gt;VisualTreeHelper&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetParent&lt;/span&gt;(current);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;             } &lt;span style="color:blue;"&gt;while&lt;/span&gt; (current != &lt;span style="color:blue;"&gt;null&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt;         }   &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt; }&lt;/p&gt;&lt;/pre&gt;      &lt;div style="text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; color: rgb(0, 0, 0); font-size: small;"&gt;Listing 3: Helper method to find an element up the visual tree hierarchy. &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;Notice that both &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;es&lt;/span&gt; refer to the same &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragOver&lt;/span&gt; event. This is because in both cases, all I am doing is checking to see if the dragged item is over an element it can drop on and at the same time, update the position of the adorner as it is moved across the screen. See Listing 4 for all this fun stuff &lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   96&lt;/span&gt; &lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   97&lt;/span&gt;                 e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   98&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   99&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (!e.&lt;span style="color:purple;"&gt;Data&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetDataPresent&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"contact"&lt;/span&gt;))&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  100&lt;/span&gt;                         {                          &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  101&lt;/span&gt;                             e.&lt;span style="color:purple;"&gt;Effects&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropEffects&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;None&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  102&lt;/span&gt;                         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  103&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  104&lt;/span&gt;                         &lt;span style="color:blue;"&gt;var&lt;/span&gt; currentMousePosition = e.&lt;span style="color: rgb(0, 139, 139);"&gt;GetPosition&lt;/span&gt;(&lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  105&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  106&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt; != &lt;span style="color:blue;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt; != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  107&lt;/span&gt;                             &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;UpdateAdornerPosition&lt;/span&gt;(&lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;, currentMousePosition);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  108&lt;/span&gt;                     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  109&lt;/span&gt;                 );&lt;/p&gt;&lt;/pre&gt;      &lt;div style="text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; color: rgb(0, 0, 0); font-size: small;"&gt;Listing 4: Checking for a viable drop target and updating the adorner position. &lt;/div&gt;    &lt;/div&gt;    &lt;h4&gt;Steps 8-9: Drop&lt;/h4&gt;    &lt;p&gt;Each &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; raises its own version of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Drop&lt;/span&gt; event. Lines 111-122 deals with the expected case of dragging and dropping from source to target. First, check the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DragEventArgs&lt;/span&gt; parameter to see if there is data there in the format we are expecting. This is shown in Line 114. If there is correct data, then simply update the collections of &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Contact&lt;/span&gt; items that is data bound to the respective &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;. If there is a successful drop, then at this point, remove the adorner.&lt;br /&gt;&lt;br /&gt;In Line 125 which deals with the case of doing a drag/drop on the source &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;, there isn't much to do other than remove the adorner. See all this in Listing 5. &lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto;font-family:consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  111&lt;/span&gt; &lt;span style="color:purple;"&gt;DropTargetCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  112&lt;/span&gt;                 e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  113&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  114&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt;(!e.&lt;span style="color:purple;"&gt;Data&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetDataPresent&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myContactData"&lt;/span&gt;)) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  115&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; contact = e.&lt;span style="color:purple;"&gt;Data&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetData&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myContactData"&lt;/span&gt;) &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  116&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  117&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Add&lt;/span&gt;(contact); &lt;span style="color:green;"&gt;// add to new collection&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  118&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Remove&lt;/span&gt;(contact);    &lt;span style="color:green;"&gt;// remove from source collection&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  119&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  120&lt;/span&gt;                         &lt;span style="color:green;"&gt;// pass in the root grid since its adorner layer was used to add ListBoxItems adorners to&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  121&lt;/span&gt;                         &lt;span style="color: rgb(0, 139, 139);"&gt;RemoveAdorner&lt;/span&gt;(&lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;, &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  122&lt;/span&gt;                     });&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  123&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  124&lt;/span&gt;             &lt;span style="color:green;"&gt;// if dropping on the source list, remove the adorner&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  125&lt;/span&gt;             &lt;span style="color:purple;"&gt;DropSourceCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(e =&amp;gt; &lt;span style="color: rgb(0, 139, 139);"&gt;RemoveAdorner&lt;/span&gt;(&lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;, &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;));&lt;/p&gt;&lt;/pre&gt;      &lt;div style="text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; color: rgb(0, 0, 0); font-size: small;"&gt;Listing 5: The drop operation. &lt;/div&gt;&lt;!-- END outer div --&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/5204554931543429996-1509822122244266700?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/1509822122244266700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=1509822122244266700' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/1509822122244266700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/1509822122244266700'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2011/01/20110105-drag-and-drop-in-wpf-using.html' title='[2011.01.05] Drag and Drop in WPF using MVVMLight [II/IV]'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_nJH2hOo32r8/TSZhcIZA4LI/AAAAAAAAAso/29NmiD5lIvk/s72-c/downloadCode02%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-2705145315332798643</id><published>2011-01-04T22:28:00.014-05:00</published><updated>2011-01-06T20:00:52.835-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>[2011.01.04] Drag and Drop in WPF using MVVMLight [I/III]</title><content type='html'>&lt;div style="font-family: Tahoma;"&gt; &lt;!-- START outer div--&gt;    &lt;div&gt;&lt;a href="http://www.mediafire.com/file/ar5mka95xi4di4y/DragDropUsingMvvmLight01.zip" style="border-width: 0px;"&gt;&lt;img alt="downloadCode02" src="http://lh3.ggpht.com/_nJH2hOo32r8/TSZhcIZA4LI/AAAAAAAAAso/29NmiD5lIvk/downloadCode02%5B2%5D.png?imgmax=800" style="background-image: none; border: 0px none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="downloadCode02" border="0" height="21" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;This is a multipart series outlining several topics is WPF  &lt;div&gt;&lt;ol&gt;&lt;li&gt;Part 1: MVVM via the MVVMLight framework &lt;/li&gt;&lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110105-drag-and-drop-in-wpf-using.html"&gt;Part 2&lt;/a&gt;: Drag and Drop &lt;/li&gt;&lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using.html"&gt;Part 3&lt;/a&gt;: The Adorner &lt;/li&gt;&lt;li&gt;&lt;a href="http://sdasrath.blogspot.com/2011/01/20110106-drag-and-drop-in-wpf-using_06.html"&gt;Part 4&lt;/a&gt;: DataTemplateSelector, StyleSelector, Unit Testing &lt;/li&gt; &lt;/ol&gt;&lt;/div&gt;        &lt;div&gt;   &lt;p&gt;I was given a task to do a simple demo on Drag and Drop in WPF. That's it, just plain vanilla D&amp;amp;D - well except for using a    &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datatemplateselector.aspx"&gt;DataTemplateSelector&lt;/a&gt; and a    &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.styleselector.aspx"&gt;StyleSelector&lt;/a&gt;.   However, the same time, I wanted to learn and add to it, namely using an existing MVVM framework and Test Driven    Development(TDD) or at least some bastardization of it. I figure one unit test at least is better than none and was a step in the right direction.   I hadn't done D&amp;amp;D before so I had to spend some time seeing what others had done before.   &lt;/p&gt;      &lt;p&gt;In this demo, I will basically drag from one &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ListBox&lt;/span&gt; to another.   Both the source (item dragged from) and target (item dragged to) &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ListBox&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;es&lt;/span&gt;&lt;/span&gt;   will have the their respective    &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;ItemTemplateSelector &lt;/span&gt;and    &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;ItemContainerStyleSelector &lt;/span&gt;properties  set to the same    &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;ResourceKey&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;s&lt;/span&gt;&lt;/span&gt;, respectively. That is, both boxes will look    and behave the same.   &lt;/p&gt;   &lt;/div&gt;    &lt;div&gt;   &lt;h4&gt;Design and Architecture&lt;/h4&gt;   &lt;p&gt;Basically, I will follow the Model-View-ViewModel patten here. I wouldn't spend time going into the details of the pattern as there is enough literature   on it out there to sink a few ships. However, rather than re-invent the wheel at each and every step, I decided to use the    &lt;a href="http://galasoft.ch/mvvm/getstarted/"&gt;MVVMLight&lt;/a&gt; framework on this demo.   I chose MvvmLight because it is pretty popular and based on videos and podcasts with Laurent, I wanted to try it out as it provides some nice helpers to make   the development of a Mvvm based application much smoother:   &lt;/p&gt;   &lt;ul&gt;    &lt;li&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;INotifyPropertyChanged &lt;/span&gt;is already implemented in a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelBase &lt;/span&gt;class&lt;/li&gt;    &lt;li&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;RelayCommand&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;Designer support in WPF (wraps the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;GetIsInDesignMode() &lt;/span&gt;method in an &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;IsInDesignMode &lt;/span&gt;property)&lt;/li&gt;    &lt;li&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;EventToCommand &lt;/span&gt;behavior to pipe a non-click based &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Command &lt;/span&gt;to handlers in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModel&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Messenger &lt;/span&gt;to communicate between multiple views and view models&lt;/li&gt;    &lt;li&gt;a deterministic way of cleaning up&lt;/li&gt;   &lt;/ul&gt;      &lt;p&gt;   Going along with Mvvm, I will have a Model which is the data layer, the View which is the presentation layer and the ViewModel which sits between the View and Model.   In Mvvm, the view does not have a direct reference to the model and references flow in a single direction:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;View -&amp;gt; ViewModel -&amp;gt; Model&lt;/span&gt;.    This means the model knows    nothing of the view.   &lt;/p&gt;  &lt;/div&gt;    &lt;div&gt;   &lt;h4&gt;The Model&lt;/h4&gt;   &lt;p&gt;This is a simple, static piece of data in this case. The actual &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Contact&lt;/span&gt; implements the    &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;IContact&lt;/span&gt; interface which has a single method called    &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;GetContacts()&lt;/span&gt; which returns an &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ObservableCollection&lt;/span&gt;   of &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Contact&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;s&lt;/span&gt;&lt;/span&gt;. I used an interface here   to add some flexibility to the code, specifically, to use Dependency Injection to inject an instance of a type that implements &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;IContact&lt;/span&gt;   in the constructor of the view model. I have not actually done so in this case as it was not necessary. These are shown in Listings 1 and 2.   &lt;/p&gt;      &lt;div&gt; &lt;!-- start Listing 1 --&gt;    &lt;pre    style="border: 1px solid silver; overflow: auto; background: none repeat scroll 0% 0% white;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Collections&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;ObjectModel&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Model&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Contract depicting the state and behavior of what a Contact is in this context.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;interface&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;IContact&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Retrieves a collection of Contact types.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;An ObservableCollection of Conctact types.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt; }&lt;/p&gt;&lt;/pre&gt;&lt;div   style="color: rgb(0, 0, 0); width: 460px; text-align: center;font-family:Arial,Helvetica,sans-serif;font-size:small;"&gt;    Listing 1: The interface that is the basis for what a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Contact&lt;/span&gt; is&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;    &lt;div&gt;&lt;pre    style="border: 1px solid silver; overflow: auto; height: 500px; background: none repeat scroll 0% 0% white;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Collections&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;ObjectModel&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Model&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; : &lt;span style="color: rgb(0, 0, 139);"&gt;IContact&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Private Fields&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;const&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;@"images/"&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Properties&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; &lt;span style="color:purple;"&gt;Name&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; &lt;span style="color:purple;"&gt;Race&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; &lt;span style="color:purple;"&gt;Status&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt; &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;(){}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts&lt;/span&gt;()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;                                          {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Monkey D. Luffy"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Straw-Hat"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Captain"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"luffyLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt;},&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Roronoa Zoro"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Pirate Hunter"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Swordsman"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"zoroLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Nami"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Pirate Robber"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Navigator"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"namiLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Usopp"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Tell Tale Man"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Sharpshooter"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"usoppLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Sanji"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;""&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Cook"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"sanjiLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Chopper"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Tony Chopper"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;@"Reindeer-human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Doctor"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"chopperLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Nico Robin"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Miss Sunday"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Archaeologist"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"robinLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Cutty Flam"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Franky"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Cyborg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Shipwright"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"frankyLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Brook"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Dead Bones"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Musician"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"brookLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Portgas D. Ace"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Firefist Ace"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Commander"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"aceLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Whitebeard&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;                                        &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;{&lt;span style="color:purple;"&gt;Name&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Edward Newgate"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Alias&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Whitebeard"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Race&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Human"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Status&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Captain"&lt;/span&gt;, &lt;span style="color:purple;"&gt;ProfileImageUrl&lt;/span&gt; = &lt;span style="font-weight: bold;color:purple;" &gt;ImgPath&lt;/span&gt; + &lt;span style="color: rgb(163, 21, 21);"&gt;@"whitebeardLogo.jpg"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Crew&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Whitebeard&lt;/span&gt; },&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;                                    };&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Enumeration specifying which pirate crew each contact belongs to.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Faction&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;        &lt;span style="font-weight: bold;color:purple;" &gt;Strawhat&lt;/span&gt;,&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;        &lt;span style="font-weight: bold;color:purple;" &gt;Whitebeard&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt; }&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;   &lt;div   style="color: rgb(0, 0, 0); width: 460px; text-align: center;font-family:Arial,Helvetica,sans-serif;font-size:small;"&gt;    Listing 2: The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Contact&lt;/span&gt; class which implements the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;IContact&lt;/span&gt; interface&lt;br /&gt;&lt;/div&gt;  &lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;The View&lt;/h4&gt;  &lt;p&gt;The view as you would guess, is independent of the model. There isn't much to say here except to note that the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;DataContext&lt;/span&gt; property is set to a resource value which defines an instance of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator&lt;/span&gt; class that will be discussed shortly. The templates and styles used here are defined in a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ResourceDictionary&lt;/span&gt; is part of the package available for download.&lt;br /&gt;Listing 3 shows the view for this project.&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; background: none repeat scroll 0% 0% white; overflow: auto; height: 500px;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Class&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;span style="color:blue;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;MainWindow&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;="clr-namespace:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;GalaSoft&lt;/span&gt;&lt;span style="color:blue;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;MvvmLight&lt;/span&gt;&lt;span style="color:blue;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;;assembly=GalaSoft.MvvmLight.Extras.WPF4"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;d&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/expression/2010/interactivity"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;local&lt;/span&gt;&lt;span style="color:blue;"&gt;="clr-namespace:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;        &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;mc&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;        &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Title&lt;/span&gt;&lt;span style="color:blue;"&gt;="MainWindow"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="400"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;        &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;mc&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:red;"&gt;Ignorable&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;d&lt;/span&gt;&lt;span style="color:blue;"&gt;"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Resources&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;local&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;FactionDataTemplateSelector&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Key&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;dataTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;local&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxStyleSelectors&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Key&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;styleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Resources&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;DataContext&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Path&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Main&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Source&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;StaticResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Locator&lt;/span&gt;&lt;span style="color:blue;"&gt;}" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;DataContext&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;LayoutRoot&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;AliceBlue&lt;/span&gt;&lt;span style="color:blue;"&gt;"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;RowDefinitions&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Auto&lt;/span&gt;&lt;span style="color:blue;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;RowDefinitions&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;TextBlock&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="0"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt;                   &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;White&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;                   &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;FontSize&lt;/span&gt;&lt;span style="color:blue;"&gt;="18"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;                   &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;="Listbox to drag from" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;dragSource&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="1"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinWidth&lt;/span&gt;&lt;span style="color:blue;"&gt;="100"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinHeight&lt;/span&gt;&lt;span style="color:blue;"&gt;="40"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Margin&lt;/span&gt;&lt;span style="color:blue;"&gt;="0,0,0,0"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;AllowDrop&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;AliceBlue&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemContainerStyleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;styleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsPanel&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;SourceListBoxItemsPanelTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsSource&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Contacts&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;dataTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Style&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ListBoxStyle1&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;EventName&lt;/span&gt;&lt;span style="color:blue;"&gt;="PreviewMouseLeftButtonDown"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PreviewMouseLeftButtonDownCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;EventName&lt;/span&gt;&lt;span style="color:blue;"&gt;="DragOver"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;EventName&lt;/span&gt;&lt;span style="color:blue;"&gt;="Drop"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DropSourceCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Border&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="2"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;="20" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;TextBlock&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="3"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;                   &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;White&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   65&lt;/span&gt;                   &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;FontSize&lt;/span&gt;&lt;span style="color:blue;"&gt;="18"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   66&lt;/span&gt;                   &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;="Listbox to drop to" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   67&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   68&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;dropTarget&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   69&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="4"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   70&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinWidth&lt;/span&gt;&lt;span style="color:blue;"&gt;="100"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   71&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;MinHeight&lt;/span&gt;&lt;span style="color:blue;"&gt;="117"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   72&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Margin&lt;/span&gt;&lt;span style="color:blue;"&gt;="0,0,0,0"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   73&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;AllowDrop&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   74&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Background&lt;/span&gt;&lt;span style="color:blue;"&gt;="#FFE4F3FD"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   75&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemContainerStyleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;styleSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   76&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsPanel&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;SourceListBoxItemsPanelTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   77&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemsSource&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;TargetContacts&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   78&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ItemTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;dataTemplateSelector&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   79&lt;/span&gt;                 &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Style&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ListBoxStyle1&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   80&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   81&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;EventName&lt;/span&gt;&lt;span style="color:blue;"&gt;="Drop"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   82&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DropTargetCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   83&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   84&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;EventName&lt;/span&gt;&lt;span style="color:blue;"&gt;="DragOver"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   85&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;PassEventArgsToCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   86&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   87&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   88&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   89&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Button&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:red;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 139, 139);"&gt;Row&lt;/span&gt;&lt;span style="color:blue;"&gt;="5"&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   90&lt;/span&gt;                &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Content&lt;/span&gt;&lt;span style="color:blue;"&gt;="Reset Collections"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   91&lt;/span&gt;                &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Template&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DynamicResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ResourceKey&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="color:purple;"&gt;ButtonTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;}"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   92&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   93&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;EventName&lt;/span&gt;&lt;span style="color:blue;"&gt;="Click"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   94&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;cmd&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventToCommand&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Command&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;ClickCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;,&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&lt;span style="font-weight: bold;color:purple;" &gt;OneWay&lt;/span&gt;&lt;span style="color:blue;"&gt;}" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   95&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;EventTrigger&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   96&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:purple;"&gt;i&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Interaction&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Triggers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   97&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Button&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   98&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   99&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  100&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;&lt;div style="color: rgb(0, 0, 0); width: 460px; text-align: center; font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;    Listing 3: The main view of the application&lt;br /&gt;&lt;/div&gt;  &lt;/div&gt; &lt;/div&gt;  &lt;div&gt;&lt;h4&gt;The ViewModels&lt;/h4&gt;  &lt;p&gt;The MvvmLight provides a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelBase &lt;/span&gt;class. When a new MvvmLight project is created, two view models are also created, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator &lt;/span&gt;and the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;MainViewModel &lt;/span&gt;which derives from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelBase&lt;/span&gt; which takes care of implementing &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;INotifyPropertyChanged&lt;/span&gt; so you don't need to keep doing boilerplate work over again.&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;The next interesting piece of generated code is the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator &lt;/span&gt;class which can&lt;br /&gt;be thought of as a centralized place for dealing with view models. You can instantiate your ViewModels in the locator class and use the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator &lt;/span&gt;as the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;DataContext &lt;/span&gt;of the view. By doing this, you will have access to all view models defined and exposed as properties in the locator class. For instance, in this case, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;MainViewModel &lt;/span&gt;is exposed as the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;Main &lt;/span&gt;property as shown below in Listing 4.&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; overflow: auto; height: 500px; background: none repeat scroll 0% 0% white;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;ViewModel&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; This class contains static references to all the view models in the&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; application and provides an entry point for the bindings.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ViewModelLocator&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;MainViewModel&lt;/span&gt; &lt;span style="color:purple;"&gt;_main&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Initializes a new instance of the ViewModelLocator class. This instance will further be used to &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; create the MainViewModel&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ViewModelLocator&lt;/span&gt;()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;CreateMain&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Gets the Main property.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;MainViewModel&lt;/span&gt; &lt;span style="color:purple;"&gt;MainStatic&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_main&lt;/span&gt; == &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt;                 {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt;                     &lt;span style="color: rgb(0, 139, 139);"&gt;CreateMain&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;                 }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt;                 &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;_main&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Gets the Main property.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;         [&lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Diagnostics&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;CodeAnalysis&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;SuppressMessage&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"Microsoft.Performance"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"CA1822:MarkMembersAsStatic"&lt;/span&gt;, &lt;span style="color:purple;"&gt;Justification&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"This non-static member is needed for data binding purposes."&lt;/span&gt;)]&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;MainViewModel&lt;/span&gt; &lt;span style="color:purple;"&gt;Main&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;                 &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;MainStatic&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Provides a deterministic way to delete the Main property.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;ClearMain&lt;/span&gt;()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt;             &lt;span style="color:purple;"&gt;_main&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Cleanup&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt;             &lt;span style="color:purple;"&gt;_main&lt;/span&gt; = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Provides a deterministic way to create the Main property.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;CreateMain&lt;/span&gt;()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_main&lt;/span&gt; == &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;                 &lt;span style="color:purple;"&gt;_main&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;MainViewModel&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   65&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   66&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   67&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   68&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   69&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Cleans up all the resources.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   70&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   71&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;Cleanup&lt;/span&gt;()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   72&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   73&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;ClearMain&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   74&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   75&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   76&lt;/span&gt; }&lt;/p&gt;&lt;/pre&gt;&lt;div style="color: rgb(0, 0, 0); width: 460px; text-align: center; font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;    Listing 4: Everything here is automatically provided when creating a MvvmLight project&lt;br /&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;p&gt;An instance of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator &lt;/span&gt; is created in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;App.xaml&lt;/span&gt; file in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;Resources&lt;/span&gt; section as shown in Listing 2.&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; overflow: auto; background: none repeat scroll 0% 0% white;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Application&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Class&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;span style="color:blue;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;App&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt;             &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt;             &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt;             &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;vm&lt;/span&gt;&lt;span style="color:blue;"&gt;="clr-namespace:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;&lt;span style="color:blue;"&gt;.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ViewModel&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt;             &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;d&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt;             &lt;span style="color:red;"&gt; xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:purple;"&gt;mc&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;             &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;StartupUri&lt;/span&gt;&lt;span style="color:blue;"&gt;="MainWindow.xaml"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;             &lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;mc&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:red;"&gt;Ignorable&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;d&lt;/span&gt;&lt;span style="color:blue;"&gt;"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Application&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Resources&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;MergedDictionaries&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Source&lt;/span&gt;&lt;span style="color:blue;"&gt;="ResourceDictionary1.xaml"/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;MergedDictionaries&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:green;"&gt;&amp;lt;!--Global View Model Locator--&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:purple;"&gt;vm&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ViewModelLocator&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;x&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Key&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Locator&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;             &lt;span style="color:red;"&gt;    &lt;/span&gt;&lt;span style="color:purple;"&gt;d&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:red;"&gt;IsDataSource&lt;/span&gt;&lt;span style="color:blue;"&gt;="True" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Application&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;Resources&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Application&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;   &lt;div   style="color: rgb(0, 0, 0); width: 460px; text-align: center;font-family:Arial,Helvetica,sans-serif;font-size:small;"&gt;    Listing 5: Instantiation of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;p&gt;Notice that the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelLocator &lt;/span&gt;class exposes a &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;Main&lt;/span&gt; property which is set at the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;DataContext&lt;/span&gt; of the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;MainWindow&lt;/span&gt;.&lt;br /&gt;&lt;/p&gt;  &lt;pre    style="border: 1px solid silver; overflow: auto; background: none repeat scroll 0% 0% white;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;DataContext&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Binding&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Path&lt;/span&gt;&lt;span style="color:blue;"&gt;="&lt;/span&gt;&lt;span style="color:purple;"&gt;Main&lt;/span&gt;&lt;span style="color:blue;"&gt;"&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Source&lt;/span&gt;&lt;span style="color:blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;StaticResource&lt;/span&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;span style="color:purple;"&gt;Locator&lt;/span&gt;&lt;span style="color:blue;"&gt;}" /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 139);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;.&lt;/span&gt;&lt;span style="color:purple;"&gt;DataContext&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;  &lt;p&gt;As the application is started, when the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;DataContext&lt;/span&gt; property is initialized, it is seen that it is binding and the application walks up the logical tree looking for the named resource which is eventually found in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',Courier,monospace;" &gt;App.xaml&lt;/span&gt; file. Properties in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;MainViewModel&lt;/span&gt; can now be bound to as the &lt;span style="color: rgb(128, 50, 191);font-family:'Courier New',Courier,monospace;" &gt;Locator&lt;/span&gt; is used as the gateway to the rest of the properies in the view model. The plumbing of associating a view model with a view has been taken care of.&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;A &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;MainViewModel&lt;/span&gt; which derives from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;ViewModelBase&lt;/span&gt; is also created for you. This is where most of the logic for this application takes place as shown in Listing 6.&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;pre    style="border: 1px solid silver; overflow: auto; height: 500px; background: none repeat scroll 0% 0% white;font-family:Consolas;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Collections&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;ObjectModel&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Controls&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Documents&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Input&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Windows&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Media&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;GalaSoft&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;MvvmLight&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;GalaSoft&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;MvvmLight&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Command&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt; &lt;span style="color:blue;"&gt;using&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;Model&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt; &lt;span style="color:blue;"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropUsingMvvmLight01&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 139);"&gt;ViewModel&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; This class contains properties that the main View can data bind to.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;     &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;MainViewModel&lt;/span&gt; : &lt;span style="color: rgb(0, 0, 139);"&gt;ViewModelBase&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Private Fields&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;IContact&lt;/span&gt; &lt;span style="color:purple;"&gt;_contact&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt; &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;;   &lt;span style="color:green;"&gt;// adorned element&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt; &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;;         &lt;span style="color:green;"&gt;// element to get adorner layer from&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt; &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Public Properties&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt;         &lt;span style="color:green;"&gt;// collections&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;Contacts&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_contacts&lt;/span&gt; == &lt;span style="color:blue;"&gt;value&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;                     &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;                 &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt; = &lt;span style="color:blue;"&gt;value&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;                 &lt;span style="color: rgb(0, 139, 139);"&gt;RaisePropertyChanged&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"Contacts"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;TargetContacts&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;             &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt; == &lt;span style="color:blue;"&gt;value&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;                     &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;                 &lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt; = &lt;span style="color:blue;"&gt;value&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt;                 &lt;span style="color: rgb(0, 139, 139);"&gt;RaisePropertyChanged&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"TargetContacts"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt;         &lt;span style="color:green;"&gt;// commands&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;MouseButtonEventArgs&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;PreviewMouseLeftButtonDownCommand&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;DropTargetCommand&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;DropSourceCommand&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt; &lt;span style="color:purple;"&gt;ClickCommand&lt;/span&gt; { &lt;span style="color: rgb(0, 139, 139);"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Initializes a new instance of the MainViewModel class.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;MainViewModel&lt;/span&gt;()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   65&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   66&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contact&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   67&lt;/span&gt;             &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt; = &lt;span style="color:purple;"&gt;_contact&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   68&lt;/span&gt;             &lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   69&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   70&lt;/span&gt; &lt;span style="color:blue;"&gt;            #region&lt;/span&gt; CommandInvocations&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   71&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   72&lt;/span&gt;             &lt;span style="color:purple;"&gt;PreviewMouseLeftButtonDownCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;MouseButtonEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   73&lt;/span&gt;                     e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   74&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   75&lt;/span&gt;                         &lt;span style="color:green;"&gt;// get dragged listbox&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   76&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt; listBox = e.&lt;span style="color:purple;"&gt;Source&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ListBox&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   77&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt; listBoxItem = &lt;span style="color: rgb(0, 0, 139);"&gt;VisualHelper&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;FindAncestor&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;ListBoxItem&lt;/span&gt;&amp;gt;((&lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt;)e.&lt;span style="color:purple;"&gt;OriginalSource&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   78&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   79&lt;/span&gt;                         &lt;span style="color:green;"&gt;// set up shared states&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   80&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt; = listBoxItem;         &lt;span style="color:green;"&gt;// adorned element&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   81&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt; = &lt;span style="color: rgb(0, 139, 139);"&gt;GetTopLevelGrid&lt;/span&gt;(e); &lt;span style="color:green;"&gt;// element to get an adorner layer from higher up the logical tree than the listboxitem&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   82&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   83&lt;/span&gt;                         &lt;span style="color:green;"&gt;// Find the data behind the listBoxItem&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   84&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (listBox == &lt;span style="color:blue;"&gt;null&lt;/span&gt; || listBoxItem == &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   85&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   86&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; contact = (&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;)listBox.&lt;span style="color:purple;"&gt;ItemContainerGenerator&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;ItemFromContainer&lt;/span&gt;(listBoxItem);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   87&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   88&lt;/span&gt;                         &lt;span style="color: rgb(0, 139, 139);"&gt;AddAdorner&lt;/span&gt;(listBoxItem, &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   89&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   90&lt;/span&gt;                         &lt;span style="color:green;"&gt;// Initialize the drag &amp;amp; drop operation&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   91&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;DataObject&lt;/span&gt; dragData = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DataObject&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myContactData"&lt;/span&gt;, contact);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   92&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;DragDrop&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;DoDragDrop&lt;/span&gt;(listBoxItem, dragData, &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropEffects&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;Move&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   93&lt;/span&gt;                     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   94&lt;/span&gt;                 );&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   95&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   96&lt;/span&gt;             &lt;span style="color:purple;"&gt;DragOverCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   97&lt;/span&gt;                 e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   98&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   99&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (!e.&lt;span style="color:purple;"&gt;Data&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetDataPresent&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"contact"&lt;/span&gt;))&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  100&lt;/span&gt;                         {                          &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  101&lt;/span&gt;                             e.&lt;span style="color:purple;"&gt;Effects&lt;/span&gt; = &lt;span style="color: rgb(0, 0, 139);"&gt;DragDropEffects&lt;/span&gt;.&lt;span style="font-weight: bold;color:purple;" &gt;None&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  102&lt;/span&gt;                         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  103&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  104&lt;/span&gt;                         &lt;span style="color:blue;"&gt;var&lt;/span&gt; currentMousePosition = e.&lt;span style="color: rgb(0, 139, 139);"&gt;GetPosition&lt;/span&gt;(&lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  105&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  106&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt; != &lt;span style="color:blue;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt; != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  107&lt;/span&gt;                             &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;UpdateAdornerPosition&lt;/span&gt;(&lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;, currentMousePosition);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  108&lt;/span&gt;                     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  109&lt;/span&gt;                 );&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  110&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  111&lt;/span&gt;             &lt;span style="color:purple;"&gt;DropTargetCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  112&lt;/span&gt;                 e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  113&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  114&lt;/span&gt;                         &lt;span style="color:blue;"&gt;if&lt;/span&gt;(!e.&lt;span style="color:purple;"&gt;Data&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetDataPresent&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myContactData"&lt;/span&gt;)) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  115&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt; contact = e.&lt;span style="color:purple;"&gt;Data&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetData&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"myContactData"&lt;/span&gt;) &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  116&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  117&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_targetContacts&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Add&lt;/span&gt;(contact); &lt;span style="color:green;"&gt;// add to new collection&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  118&lt;/span&gt;                         &lt;span style="color:purple;"&gt;_contacts&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;Remove&lt;/span&gt;(contact);    &lt;span style="color:green;"&gt;// remove from source collection&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  119&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  120&lt;/span&gt;                         &lt;span style="color:green;"&gt;// pass in the root grid since its adorner layer was used to add ListBoxItems adorners to&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  121&lt;/span&gt;                         &lt;span style="color: rgb(0, 139, 139);"&gt;RemoveAdorner&lt;/span&gt;(&lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;, &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  122&lt;/span&gt;                     });&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  123&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  124&lt;/span&gt;             &lt;span style="color:green;"&gt;// if dropping on the source list, remove the adorner&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  125&lt;/span&gt;             &lt;span style="color:purple;"&gt;DropSourceCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(e =&amp;gt; &lt;span style="color: rgb(0, 139, 139);"&gt;RemoveAdorner&lt;/span&gt;(&lt;span style="color:purple;"&gt;_listBoxItem&lt;/span&gt;, &lt;span style="color:purple;"&gt;_topLevelGrid&lt;/span&gt;));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  126&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  127&lt;/span&gt;             &lt;span style="color:purple;"&gt;ClickCommand&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;DragEventArgs&lt;/span&gt;&amp;gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  128&lt;/span&gt;                 e =&amp;gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  129&lt;/span&gt;                     {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  130&lt;/span&gt;                         &lt;span style="color:purple;"&gt;Contacts&lt;/span&gt; = &lt;span style="color:purple;"&gt;_contact&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetContacts&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  131&lt;/span&gt;                         &lt;span style="color:purple;"&gt;TargetContacts&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Contact&lt;/span&gt;&amp;gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  132&lt;/span&gt;                     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  133&lt;/span&gt;                 );&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  134&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  135&lt;/span&gt; &lt;span style="color:blue;"&gt;            #endregion&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  136&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  137&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  138&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;GetTopLevelGrid&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;MouseEventArgs&lt;/span&gt; mouseEventArgs)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  139&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  140&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; sourceElement = mouseEventArgs.&lt;span style="color:purple;"&gt;Source&lt;/span&gt; &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DependencyObject&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  141&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; topLevelWindow = &lt;span style="color: rgb(0, 0, 139);"&gt;VisualHelper&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;FindAncestor&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(0, 0, 139);"&gt;Grid&lt;/span&gt;&amp;gt;(sourceElement);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  142&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; topLevelWindow;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  143&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  144&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  145&lt;/span&gt; &lt;span style="color:blue;"&gt;        #region&lt;/span&gt; Helper Methods&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  146&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  147&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  148&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Adds an adorner to an element. &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  149&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  150&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="elementToAdorn"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Element to add an adorner to.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  151&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="elementToGetAdornerLayerFrom"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Element to get the AdornerLayer from.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  152&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;example&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;In the case of the ListBox, if you want to adorn each ListBoxItem and the adorner layer of the &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  153&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; containing ListBox is used, then the adorner object gets clipped as it is moved out of the ListBox. In this case,&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  154&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; you need a layer that is higher up the visual tree to allow the adorner to be visible anywhere and not be clipped.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  155&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/example&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  156&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;AddAdorner&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;UIElement&lt;/span&gt; elementToAdorn, &lt;span style="color: rgb(0, 0, 139);"&gt;Visual&lt;/span&gt; elementToGetAdornerLayerFrom)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  157&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  158&lt;/span&gt;             &lt;span style="color:green;"&gt;// get the adorner layer to attach the adorner to&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  159&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adornerLayer = &lt;span style="color: rgb(0, 0, 139);"&gt;AdornerLayer&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdornerLayer&lt;/span&gt;(elementToGetAdornerLayerFrom);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  160&lt;/span&gt;             &lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt;(elementToAdorn);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  161&lt;/span&gt;             adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;Add&lt;/span&gt;(&lt;span style="color:purple;"&gt;_draggedAdorner&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  162&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  163&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  164&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  165&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Removes an adorner from an element.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  166&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  167&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="adornedElement"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;The element that has an adorner associated with it.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  168&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; /// &lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;param name="elementToGetAdornerLayerFrom"&amp;gt;&lt;/span&gt;&lt;span style="color:green;"&gt;Element to get the AdornerLayer from.&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  169&lt;/span&gt;         &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color: rgb(0, 139, 139);"&gt;RemoveAdorner&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 139);"&gt;UIElement&lt;/span&gt; adornedElement, &lt;span style="color: rgb(0, 0, 139);"&gt;Visual&lt;/span&gt; elementToGetAdornerLayerFrom)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  170&lt;/span&gt;         {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  171&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adornerLayer = &lt;span style="color: rgb(0, 0, 139);"&gt;AdornerLayer&lt;/span&gt;.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdornerLayer&lt;/span&gt;(elementToGetAdornerLayerFrom);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  172&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; adorners = adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;GetAdorners&lt;/span&gt;(adornedElement);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  173&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  174&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (adorners == &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  175&lt;/span&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  176&lt;/span&gt;             &lt;span style="color:blue;"&gt;var&lt;/span&gt; dragAdorner = adorners[0] &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 139);"&gt;DraggedAdorner&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  177&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (dragAdorner != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  178&lt;/span&gt;             {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  179&lt;/span&gt;                 adornerLayer.&lt;span style="color: rgb(0, 139, 139);"&gt;Remove&lt;/span&gt;(dragAdorner);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  180&lt;/span&gt;             }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  181&lt;/span&gt;         }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  182&lt;/span&gt; &lt;span style="color:blue;"&gt;        #endregion&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  183&lt;/span&gt;     }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  184&lt;/span&gt; }&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;    &lt;div   style="color: rgb(0, 0, 0); width: 460px; text-align: center;font-family:Arial,Helvetica,sans-serif;font-size:small;"&gt;    Listing 6: The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;MainViewModel&lt;/span&gt; where most of the logic between the view and model happen&lt;br /&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;p&gt;Two properties are created to hold the collections of data for both of the dragging from and dropping to listboxes. Following that a number of &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;RelayCommands&lt;/span&gt; are defined which are mapped to events related to the Drag and Drop infrastructure. In the constructor, the logic for the commands are exposed and can be easily followed from the documentation provided in the form of comments. Finally some adorner related helper methods are defined.&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note: &lt;/strong&gt;The constructor is also a good place to inject dependencies. For instance, if my &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;Contact&lt;/span&gt; class was not of static data, but is coming from a database or something like that, then you could have passed in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',Courier,monospace;" &gt;IContact&lt;/span&gt; interface as a constructor parameter. By doing this, you can pass in any type that implements this interface which means that you can write a test to pass in a mock implementation. Perhaps I will add this functionality on later.&lt;br /&gt;&lt;/p&gt; &lt;/div&gt;&lt;/div&gt;&lt;!-- END outer div --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-2705145315332798643?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/2705145315332798643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=2705145315332798643' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/2705145315332798643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/2705145315332798643'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2011/01/20110104-drag-and-drop-in-wpf-using.html' title='[2011.01.04] Drag and Drop in WPF using MVVMLight [I/III]'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_nJH2hOo32r8/TSZhcIZA4LI/AAAAAAAAAso/29NmiD5lIvk/s72-c/downloadCode02%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-7433511368469231073</id><published>2010-12-07T23:55:00.001-05:00</published><updated>2010-12-07T23:55:45.414-05:00</updated><title type='text'>[2010.12.07] Installing Microsoft Surface SDK 1.0 SP1</title><content type='html'>&lt;!-- START outer div--&gt;  &lt;div style="font-family: tahoma" font-weight:bold;font-size:14pt?="font-weight:bold;font-size:14pt?"&gt;Installing the SDK on a Virtual Machine running Vista&lt;/span&gt;    &lt;p&gt;Tools Required:&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;Windows Vista SP1 or higher &lt;/li&gt;      &lt;li&gt;&lt;a href="http://www.microsoft.com/express/Downloads/"&gt;Visual Studio 2008 Express&lt;/a&gt; or higher (does not work in VS2010 as far as I can tell) &lt;/li&gt;      &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=28C97D22-6EB8-4A09-A7F7-F6C7A1F000B5&amp;amp;displaylang=en"&gt;Virtual PC 2007 SP1&lt;/a&gt; (if you are not actually running Vista) &lt;/li&gt;      &lt;li&gt;&lt;a href="http://www.vmware.com/products/workstation/"&gt;VMWare 7.1 Workstation Edition&lt;/a&gt; (highly recommended alternative to VPC 2007 &lt;/li&gt;      &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=15fb9169-4a25-4dca-bf40-9c497568f102"&gt;XNA 2.0 Framework&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3db8987b-47c8-46ca-aafb-9c3b36f43bcc&amp;amp;displaylang=en"&gt;Surface SDK v1.0 SP1&lt;/a&gt; &lt;/li&gt;   &lt;/ul&gt;    &lt;p&gt;Now that the Surface SDK v1.0 SP1 is public it is the right time to get familiar with it. Of course, getting it up and running was a bit more entailed that I had anticipated so I thought I would share my experience and hopefully you would have an easier time with it. I ran into a few issues which I wanted to highlight. &lt;/p&gt;    &lt;p&gt;First off, Microsoft says that the Surface SDK needs to be installed on a Vista SP1 machine. Since I was running Windows 7 x64, I tried installing and of course it did not work. Stupid me, instead of checking the web immediately for Windows 7 related solutions, I continued to follow the rest of the install steps which was to use a Virtual Machine to host Vista. &lt;/p&gt;   &lt;span style="font-size: 12pt; font-weight: bold"&gt;[1.1] Installing Virtual PC and Vista&lt;/span&gt;     &lt;p&gt;Again, MS recommended &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=28C97D22-6EB8-4A09-A7F7-F6C7A1F000B5&amp;amp;displaylang=en"&gt;Virtual PC 2007 SP1&lt;/a&gt; which can be downloaded for free. I have not had the need to for VPC before so this was the first time I am using one. Either way, installing Virtual PC on Windows 7 went off without a hitch. While it took forever to get the Vista Ultimate x32 image created, that was also painless. However, there is a &lt;a href="http://support.microsoft.com/kb/958162"&gt;hotfix&lt;/a&gt; which takes VPC from version 6.0.192.0 to 6.0.210.0 and a security update (&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=88DE1513-8D35-410F-8896-FE668F885CA0&amp;amp;displaylang=en"&gt;KB969856&lt;/a&gt;) which follows the fix . I found that after installing the hotfix and the security update, VPC fails to recognize the Vista image and it even complains that there is some problem recognizing the host OS (Win 7). Uninstalling both made VPC works as it did before. Basically &lt;strong&gt;DO NOT&lt;/strong&gt; install the hotfix or security update unless you really need them. &lt;/p&gt;    &lt;p&gt;Due to the age of Virtual PC, you will find some limitations when it comes to dealing with graphics and widescreen support. In addition, I have tried out &lt;a href="http://www.vmware.com/products/workstation/"&gt;VMWare 7.1 Workstation Edition&lt;/a&gt; and it does a phenomenal job. The issues I describe below are non-existent and you can easily resize the guest OS as you would a normal window. I would recommend this over VPC if you can get it. &lt;/p&gt;   &lt;span style="font-size: 12pt; font-weight: bold"&gt;[1.2] Installing the XNA 2.0 Framework&lt;/span&gt;     &lt;p&gt;The next bit that you would need is the&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=15fb9169-4a25-4dca-bf40-9c497568f102"&gt; XNA 2.0&lt;/a&gt; Redistributable. As of this writing &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a88c6dec-aeae-42cd-a108-d35c013c3b97"&gt;XNA 4.0&lt;/a&gt; is out but the SDK will complain loudly as in Fig. 1 if it does not find 2.0 on the machine. Since XNA 2.0 is prerequisite, installing this on the Vista VPC did not go as smoothly as I had hoped as shown in Fig. 2. &lt;/p&gt;    &lt;div&gt;&lt;!-- start image table--&gt;     &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;         &lt;tr&gt;           &lt;td&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/TP8Pv7epLhI/AAAAAAAAArk/YBy2e-y1HCo/s1600-h/%5B2010.12.07%5D.01.xna2.needed%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2010.12.07].01.xna2.needed" border="0" alt="[2010.12.07].01.xna2.needed" src="http://lh6.ggpht.com/_nJH2hOo32r8/TP8Pwb0NOTI/AAAAAAAAAro/XhI2gxyKJ1M/%5B2010.12.07%5D.01.xna2.needed_thumb.png?imgmax=800" width="222" height="244" /&gt;&lt;/a&gt;&lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td&gt;Fig.1 XNA 2.0 Required even though 4.0 was installled&lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt; &lt;!-- end image table--&gt;    &lt;br /&gt;    &lt;div&gt;&lt;!-- start image table--&gt;     &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;         &lt;tr&gt;           &lt;td&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/TP8PwtUqekI/AAAAAAAAArs/2K5ZpugKNjk/s1600-h/%5B2010.12.07%5D.02.xna.timeout%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2010.12.07].02.xna.timeout" border="0" alt="[2010.12.07].02.xna.timeout" src="http://lh6.ggpht.com/_nJH2hOo32r8/TP8PxNKeM7I/AAAAAAAAArw/zW2Boy4X8xo/%5B2010.12.07%5D.02.xna.timeout_thumb.png?imgmax=800" width="234" height="244" /&gt;&lt;/a&gt;&lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td&gt;Fig.2 Running XNA 2.0 msi package does nothing&lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt; &lt;!-- end image table--&gt;    &lt;p&gt;As shown, you get the dialog:      &lt;br /&gt;&lt;strong&gt;&amp;quot;Please wait while the installer finishes determining your disk space requirements.&amp;quot;&lt;/strong&gt;      &lt;br /&gt;To get around this issue, you need to use the command line utility in Administrator mode to get this running. In most cases you can find the Command Prompt in the Accessories folder, Right Click one the prompt icon and choose &lt;strong&gt;&amp;quot;Run as Administrator&amp;quot;&lt;/strong&gt; as in Fig. 2. &lt;/p&gt;    &lt;div&gt;&lt;!-- start image table--&gt;     &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;         &lt;tr&gt;           &lt;td&gt;&lt;a href="http://lh3.ggpht.com/_nJH2hOo32r8/TP8PxZ2KotI/AAAAAAAAAr0/uJTmpk0vFYA/s1600-h/%5B2010.12.07%5D.03.command.prompt%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2010.12.07].03.command.prompt" border="0" alt="[2010.12.07].03.command.prompt" src="http://lh6.ggpht.com/_nJH2hOo32r8/TP8PyCwm5vI/AAAAAAAAAr8/19WegHO1ids/%5B2010.12.07%5D.03.command.prompt_thumb.png?imgmax=800" width="159" height="244" /&gt;&lt;/a&gt;&lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td&gt;Fig.3 Command Promt run as Administrator&lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt; &lt;!-- end image table--&gt;    &lt;p&gt;Now navigate to where the XNA 2.0 package (xnafx20_redist.msi) is and invoke it with the following command:      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: red; font-weight: bold"&gt;msiexec /package xnafx20_redist.msi /qr&lt;/span&gt;      &lt;br /&gt;This will skip the checking space requirement and install the framework to its default location. &lt;/p&gt;   &lt;span style="font-size: 12pt; font-weight: bold"&gt;[1.3] Installing the Surface SDK&lt;/span&gt;     &lt;p&gt;I ran into the same issue as I did with the XNA msi installer, in that, it was stuck checking the space requirements. This is shown in Fig. 4. &lt;/p&gt;    &lt;div&gt;&lt;!-- start image table--&gt;     &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;         &lt;tr&gt;           &lt;td&gt;&lt;a href="http://lh3.ggpht.com/_nJH2hOo32r8/TP8Pyj5RNqI/AAAAAAAAAsA/QF5ivT6f2Sk/s1600-h/%5B2010.12.07%5D.04.surface.timeout%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2010.12.07].04.surface.timeout" border="0" alt="[2010.12.07].04.surface.timeout" src="http://lh5.ggpht.com/_nJH2hOo32r8/TP8PzAWZuyI/AAAAAAAAAsE/I80Zr89akvQ/%5B2010.12.07%5D.04.surface.timeout_thumb.png?imgmax=800" width="232" height="244" /&gt;&lt;/a&gt;&lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td&gt;Fig.4 Surface SDK does not install normally&lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt; &lt;!-- end image table--&gt;    &lt;p&gt;The solution is the same as the XNA case - simply run the msi package as indicated above from an elevated command prompt. &lt;/p&gt;    &lt;p&gt;Fig. 5 shows the results of everything after installation. Note the Surface project templates in Visual Studio 2008 SP1. &lt;/p&gt;    &lt;div&gt;&lt;!-- start image table--&gt;     &lt;table style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid" cellspacing="1"&gt;&lt;tbody&gt;         &lt;tr&gt;           &lt;td&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/TP8Pzv221aI/AAAAAAAAAsI/q6gr-P_5eMU/s1600-h/%5B2010.12.07%5D.05.vs2008.surface.template%5B2%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="[2010.12.07].05.vs2008.surface.template" border="0" alt="[2010.12.07].05.vs2008.surface.template" src="http://lh6.ggpht.com/_nJH2hOo32r8/TP8P0KFu0tI/AAAAAAAAAsM/XzE05z6RihI/%5B2010.12.07%5D.05.vs2008.surface.template_thumb.png?imgmax=800" width="244" height="166" /&gt;&lt;/a&gt;&lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td&gt;Fig.5 Surface project template in Visual Studio 2008&lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;   &lt;/div&gt; &lt;!-- end image table--&gt;&lt;!-- END outer div --&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-7433511368469231073?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/7433511368469231073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=7433511368469231073' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/7433511368469231073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/7433511368469231073'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2010/12/20101207-installing-microsoft-surface.html' title='[2010.12.07] Installing Microsoft Surface SDK 1.0 SP1'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nJH2hOo32r8/TP8Pwb0NOTI/AAAAAAAAAro/XhI2gxyKJ1M/s72-c/%5B2010.12.07%5D.01.xna2.needed_thumb.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-1467249020010760219</id><published>2009-11-20T01:01:00.001-05:00</published><updated>2009-11-20T01:01:32.624-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General Programming'/><title type='text'>[2009.11.20] How to Download PDC2009 Videos using Firefox and DownThemAll!</title><content type='html'>&lt;div style="font-family: tahoma"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;p&gt;This is a quick little post on how to download &lt;strong&gt;all&lt;/strong&gt; the PDC 2009 videos in one go (well almost) with Firefox. &lt;/p&gt;      &lt;p&gt;All you need is the &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/201?collection_uuid=772c5082-2a86-cb22-38b9-259fb9edaf04"&gt;DownThemAll!&lt;/a&gt; extension for &lt;a href="http://www.mozilla.com/en-US/"&gt;Firefox&lt;/a&gt; and you are good to go. In case the link changes in the future just search for it on Mozilla's website. &lt;/p&gt;      &lt;h4&gt;Steps:&lt;/h4&gt;      &lt;ul&gt;       &lt;li&gt;Install DownThemAll! &lt;/li&gt;        &lt;li&gt;Go to the &lt;a href="http://microsoftpdc.com/Videos"&gt;videos&lt;/a&gt; section on the PDC2009 main page &lt;/li&gt;        &lt;li&gt;Right click and select DownThemAll! from the context menu as in Fig. 1. &lt;!-- start image div--&gt;&lt;/li&gt;     &lt;/ul&gt;      &lt;div style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/SwYwsL63ysI/AAAAAAAAAqg/ffXgBglstgA/s1600-h/%5B2009.11.20%5D.01.PDC2009%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="[2009.11.20].01.PDC2009" border="0" alt="[2009.11.20].01.PDC2009" src="http://lh4.ggpht.com/_nJH2hOo32r8/SwYwsmf_M6I/AAAAAAAAAqk/IMkGk-4-b8U/%5B2009.11.20%5D.01.PDC2009_thumb.png?imgmax=800" width="244" height="176" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;br /&gt;&lt;span&gt;Fig. 1&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;ul&gt;       &lt;li&gt;Set the location of the downloaded files (1) and add a filter (2) for the types of files you want to get. In this case, I wanted the high definition versions of the videos, but all the videos end with .wmv. The hi-def files are in the &lt;strong&gt;wmvhigh&lt;/strong&gt; folder so by using that as the filter, I can only grab the ones I wanted. You can also change the filter to get the pptx files as well. This is in Fig. 2.           &lt;br /&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Make sure you have a few gigs of hard drive space and time, because it will take a while to get them all. &lt;/li&gt;     &lt;/ul&gt; &lt;!-- start image div--&gt;      &lt;div style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/SwYwtJTjOLI/AAAAAAAAAqo/KxPAGAJ3Stk/s1600-h/%5B2009.11.20%5D.02.PDC2009%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="[2009.11.20].02.PDC2009" border="0" alt="[2009.11.20].02.PDC2009" src="http://lh4.ggpht.com/_nJH2hOo32r8/SwYwtk23J8I/AAAAAAAAAqs/qEEJxP9KUo4/%5B2009.11.20%5D.02.PDC2009_thumb.png?imgmax=800" width="244" height="191" /&gt;&lt;/a&gt;         &lt;br /&gt;&lt;span&gt;Fig. 2&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;ul&gt;       &lt;li&gt;Once the download starts (you can change the number of simultaneous downloadable files) you will see something like Fig. 3. Don't worry about the incompletes or failed files, you can always go back and resume getting them. Notice also that the files are named in the format of CL00.wmv and FT00.wmv. The PDC website has a renamer batch file you can download to change the names of the files once they are downloaded. [&lt;a href="http://microsoftpdc.com/Videos"&gt;Get the file and instructions&lt;/a&gt;] &lt;/li&gt;     &lt;/ul&gt; &lt;!-- start image div--&gt;      &lt;div style="border-bottom: #c0c0c0 1px solid; text-align: center; border-left: #c0c0c0 1px solid; width: 460px; font-family: arial, helvetica, sans-serif; font-size: small; border-top: #c0c0c0 1px solid; border-right: #c0c0c0 1px solid"&gt;&lt;a href="http://lh3.ggpht.com/_nJH2hOo32r8/SwYwubh3YAI/AAAAAAAAAqw/-YWotwmTz8g/s1600-h/%5B2009.11.20%5D.03.PDC2009%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="[2009.11.20].03.PDC2009" border="0" alt="[2009.11.20].03.PDC2009" src="http://lh5.ggpht.com/_nJH2hOo32r8/SwYwuynzNhI/AAAAAAAAAq0/R7e73tQdoe0/%5B2009.11.20%5D.03.PDC2009_thumb.png?imgmax=800" width="244" height="186" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;br /&gt;&lt;span&gt;Fig. 3&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- END outer div --&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-1467249020010760219?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/1467249020010760219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=1467249020010760219' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/1467249020010760219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/1467249020010760219'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2009/11/20091120-how-to-download-pdc2009-videos.html' title='[2009.11.20] How to Download PDC2009 Videos using Firefox and DownThemAll!'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_nJH2hOo32r8/SwYwsmf_M6I/AAAAAAAAAqk/IMkGk-4-b8U/s72-c/%5B2009.11.20%5D.01.PDC2009_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-613590729945772719</id><published>2009-11-01T20:39:00.001-05:00</published><updated>2009-11-01T20:39:39.322-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Design Patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='Prism'/><category scheme='http://www.blogger.com/atom/ns#' term='General Programming'/><title type='text'>[2009.11.01] I spent a Week in PRISM</title><content type='html'>&lt;div style="font-family: Tahoma;&lt;br /&gt;	&lt;br /&gt;	font-size: medium;&lt;br /&gt;	&lt;br /&gt;	padding: 2px;&lt;br /&gt;	&lt;br /&gt;	margin: 2px;&lt;br /&gt;	&lt;br /&gt;	width: 460px;&lt;br /&gt;	&lt;br /&gt;	text-align: justify;"&gt; &lt;!-- START outer div--&gt;  	&lt;div&gt; 		&lt;p&gt; 			I had heard of Prism a while ago but never really investigated. When I did take a look at it 			about a month ago, in all honesty I felt overwhelmed. However, recently I had two interesting  			conversations and that prompted me to sit down and really get into Prism. I am glad I did as 			I have learned so much and it has shown me how much more I need to learn as well.  		&lt;/p&gt; 		&lt;p&gt; 			I suppose I am more of a code monkey rather than an architect or a designer. That will change from now 			on. There is no point in me banging out code when I am only aware of part of the system I am writing for. 			Going through the Prism docs touches on a lot of concepts that I was not familiar with in the first place. 			All in all, I know I can't get it all in one reading of the doc, but it's a start. I am much more comfortable 			with terms like Inversion of Control, Dependency Injection, Delegate Commands (well I got this from learning 			about Model-View-ViewModel), Event Aggregator, Modules, Bootstrapper, and some Design Patterns. Thus far,  			all I have done is the basic Hello World in Prism but I hope to do more in the near future. I would like to 			reference some additional resources that in my opinion, will supplement learning not just Prism, but 			design and architecture in general. 		&lt;/p&gt; 	&lt;/div&gt; 	&lt;div&gt; 		&lt;h4&gt;Prism Related&lt;/h4&gt; 		&lt;ul&gt; 			&lt;li&gt; 				&lt;a href="http://msdn.microsoft.com/en-us/library/dd458809.aspx"&gt;Composite Application Guidance&lt;/a&gt; (Prism) October 2009 			&lt;/li&gt; 			&lt;li&gt; 				Prism on &lt;a href="http://channel9.msdn.com/tags/Prism/"&gt;Channel 9&lt;/a&gt; 			&lt;/li&gt; 			&lt;li&gt; 				Channel 9 Screencast Series: Creating a modular application using Prism V2 &lt;br /&gt;   				&amp;nbsp;&amp;nbsp;&lt;a href="http://channel9.msdn.com/posts/akMSFT/Creating-a-modular-application-using-Prism-V2-Part-1-of-4--Creating-a-shell-and-modules/"&gt;Part 1/4&lt;/a&gt;: Creating a shell and modules&lt;br /&gt;  				&amp;nbsp;&amp;nbsp;&lt;a href="http://channel9.msdn.com/posts/akMSFT/Creating-a-modular-application-using-Prism-V2-Screencast-24--Visual-Composition/"&gt;Part 2/4&lt;/a&gt;: Visual Composition&lt;br /&gt;  				&amp;nbsp;&amp;nbsp;&lt;a href="http://channel9.msdn.com/posts/akMSFT/Creating-a-modular-application-using-Prism-V2-Screencast-34--Implementing-views-and-services/"&gt;Part 3/4&lt;/a&gt;: Implementing views and services&lt;br /&gt;  				&amp;nbsp;&amp;nbsp;&lt;a href="http://channel9.msdn.com/posts/akMSFT/Creating-a-modular-application-using-Prism-v2-Screencast-44--Decoupled-Communication/"&gt;Part 4/4&lt;/a&gt;: Decoupled Communication 			&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc337885.aspx"&gt;Tame Your Software Dependencies for More Flexible Apps&lt;/a&gt; by James Kovacs [MSDN Magazine March 2008]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc785479.aspx"&gt;Patterns For Building Composite Applications With WPF&lt;/a&gt; by Glenn Block [MSDN Magazine September 2008]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://www.dnrtv.com/default.aspx?showNum=124"&gt;Brian Noyes on Prism&lt;/a&gt; [dnrTV! Screencast 124]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://www.dnrtv.com/default.aspx?showNum=132"&gt;Brian Noyes on Prism Events and Commands&lt;/a&gt; [dnrTV! Screencast 132]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://www.dnrtv.com/default.aspx?showNum=126"&gt;James Kovacs' Roll-your-own IoC Container&lt;/a&gt; [dnrTV! Screencast 126]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=374"&gt;Glenn Block and Brian Noyes on Prism&lt;/a&gt; [.NETRocks Audiocast 374]&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="http://www.code-magazine.com/articleprint.aspx?quickid=0907051&amp;amp;printmode=true"&gt;Build Composite WPF and Silverlight Applications&lt;/a&gt; by Claudio Lassala [CODE Magazine July/August 2009]&lt;/li&gt; 		&lt;/ul&gt; 	&lt;/div&gt; 	 	&lt;div&gt; 		&lt;h4&gt;Supplemental Information&lt;/h4&gt; 		&lt;ul&gt; 			&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc785480.aspx"&gt;Understanding Routed Events and Commands In WPF&lt;/a&gt; by Brian Noyes [MSDN Magazine September 2008]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd419654.aspx"&gt;An Introduction To Domain-Driven Design&lt;/a&gt; by David Laribee [MSDN Magazine February]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx"&gt;WPF Apps With The Model-View-ViewModel Design Pattern&lt;/a&gt; by Josh Smith [MSDN Magazine February]&lt;/li&gt; 			&lt;li&gt;Jean Paul Boodhoo on Test Driven Development  			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=10"&gt;Part 1&lt;/a&gt; 			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=11"&gt;Part 2&lt;/a&gt; [dnrTV! Screencast 10 and 11]&lt;/li&gt; 			&lt;li&gt;Jean-Paul Boodhoo on Demystifying Design Patterns  			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=63"&gt;Part 1&lt;/a&gt; 			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=65"&gt;Part 2&lt;/a&gt; 			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=68"&gt;Part 3&lt;/a&gt; 			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=71"&gt;Part 4&lt;/a&gt; 			&lt;a href="http://www.dnrtv.com/default.aspx?showNum=92"&gt;Part 5&lt;/a&gt; Part 6 [dnrTV! Screencast 63,  			65, 68, 71, 92]&lt;/li&gt; 			&lt;li&gt;&lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=393"&gt;David Hayden on the Unity Framework&lt;/a&gt; [.NETRocks Audiocast 393]&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="Test%20Driven%20Development%20with%20Jean%20Paul%20Boodhoo"&gt;Test Driven Development with Jean Paul Boodhoo&lt;/a&gt; [.NETRocks Audiocast 168]&lt;/li&gt;			 			&lt;li&gt; 			&lt;a href="http://www.code-magazine.com/articleprint.aspx?quickid=0705071&amp;amp;printmode=true"&gt;Layered Architecture, Dependency Injection, and Dependency Inversion&lt;/a&gt; by Jean Paul Boodhoo [CODE Magazine May/June 2007]&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="http://www.code-magazine.com/articleprint.aspx?quickid=0903101&amp;amp;printmode=true"&gt;The Zen of Inversion of Control&lt;/a&gt; by Jon Stonecash [CODE Magazine March/April 2009]&lt;/li&gt; 		&lt;/ul&gt; 	&lt;/div&gt; 	&lt;div&gt; 		&lt;h4&gt;Some Books&lt;/h4&gt; 		&lt;ul&gt; 			&lt;li&gt;&lt;a href="http://www.codeplex.com/AppArchGuide"&gt;Application Architecture Guide 2.0&lt;/a&gt; The Book [Microsoft Patterns and Practices]&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/B000SEIBB8/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1257124931&amp;amp;sr=8-2"&gt;Design Patterns: Elements of Reusable Object-Oriented Software&lt;/a&gt;&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1257124987&amp;amp;sr=1-1"&gt;Domain-Driven Design: Tackling Complexity in the Heart of Software&lt;/a&gt;&lt;/li&gt; 			&lt;li&gt; 			&lt;a href="http://www.amazon.com/3-0-Design-Patterns-Judith-Bishop/dp/059652773X/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1257125044&amp;amp;sr=1-1"&gt;C# 3.0 Design Patterns&lt;/a&gt;&lt;/li&gt; 		&lt;/ul&gt; 	&lt;/div&gt; &lt;/div&gt;&lt;!-- END outer div --&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-613590729945772719?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/613590729945772719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=613590729945772719' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/613590729945772719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/613590729945772719'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2009/11/20091101-i-spent-week-in-prism.html' title='[2009.11.01] I spent a Week in PRISM'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-5100338610367840155</id><published>2009-10-12T12:07:00.003-04:00</published><updated>2009-10-12T12:14:28.960-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Expression'/><category scheme='http://www.blogger.com/atom/ns#' term='Blend'/><title type='text'>[2009.10.12] WPF: Change the color of the selected item in a ListBox control</title><content type='html'>&lt;div  style="font-family:tahoma;"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;p&gt;A question that may come up at some point in the life of a WPF developer is: "How to change the color of the selected item in a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; control?". Going with just the word "selected" you would imagine that there is some property with that name that lives in &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;. Close, but no dice. &lt;/p&gt;      &lt;p&gt;There is, however, an &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;IsSelected&lt;/span&gt; dependency property registered to the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; control. Recall that &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; implicitly wraps each of its items in a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;, which is a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ContentControl&lt;/span&gt;. &lt;/p&gt;      &lt;p&gt;There are three ways that I know of that you can accomplish what you want - the first two requires knowledge of the template that makes up the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;, whereas the last one, not so much. Let's look at the first two. Since the template is necessary, let's start by taking a look at the template for a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; in Listing 1. I have removed the parts that are not relevant to the problem at hand so you are just seeing a slimmed down version of the real thing.       &lt;br /&gt;&lt;strong&gt;Note: &lt;/strong&gt;I am using a tool called &lt;a href="http://www.sellsbrothers.com/tools/#ShowMeTheTemplate"&gt;Show Me The Template! Feel free to use whatever works. &lt;/a&gt;&lt;/p&gt;   &lt;/div&gt; &lt;!-- start listing 1 --&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;TargetType&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"ListBoxItem"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2:                      &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3:                      &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;s&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"clr-namespace:System;assembly=mscorlib"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4:                      &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;x&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Border&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;BorderThickness&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding Border.BorderThickness}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6:                 &lt;span style="color: rgb(255, 0, 0);"&gt;Padding&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding Control.Padding}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7:                 &lt;span style="color: rgb(255, 0, 0);"&gt;BorderBrush&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding Border.BorderBrush}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8:                 &lt;span style="color: rgb(255, 0, 0);"&gt;Background&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding Panel.Background}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9:                 &lt;span style="color: rgb(255, 0, 0);"&gt;Name&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Bd"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;SnapsToDevicePixels&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"True"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ContentPresenter&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Content&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding ContentControl.Content}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11:                               &lt;span style="color: rgb(255, 0, 0);"&gt;ContentTemplate&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding ContentControl.ContentTemplate}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12:                               &lt;span style="color: rgb(255, 0, 0);"&gt;ContentStringFormat&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding ContentControl.ContentStringFormat}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13:                               &lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlignment&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding Control.HorizontalContentAlignment}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14:                               &lt;span style="color: rgb(255, 0, 0);"&gt;VerticalAlignment&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding Control.VerticalContentAlignment}"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 15:                               &lt;span style="color: rgb(255, 0, 0);"&gt;SnapsToDevicePixels&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{TemplateBinding UIElement.SnapsToDevicePixels}"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 16:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Border&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 17:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 18:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Trigger&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Property&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Selector.IsSelected"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 19:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Setter&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;TargetName&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Bd"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 20:                     &lt;span style="color: rgb(255, 0, 0);"&gt;Property&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Panel.Background"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 21:                     &lt;span style="color: rgb(255, 0, 0);"&gt;Value&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 22:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Trigger&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 23:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 24: &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 1. Slimmed down control template for a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; &lt;/div&gt;  &lt;/div&gt;&lt;div&gt;&lt;p&gt;We are interested in &lt;strong&gt;Lines 18-21&lt;/strong&gt;. &lt;/p&gt;    &lt;p&gt;What we have in Line 18 is that when the &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;IsSelected&lt;/span&gt; dependency property is triggered, it sets the &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Value&lt;/span&gt; of the &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Background&lt;/span&gt; property of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Border&lt;/span&gt; (with &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-family:'Courier New',courier,monospace;" &gt;="Bd"&lt;/span&gt;) to some predefined system level resource called &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;HighLightBrushKey&lt;/span&gt;. Now we know that this refers to the ugly blue color we see when we select something from a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;. &lt;/p&gt;    &lt;p&gt;At this stage you have a handle as to the structure of the template, and what property you need to modify to change the color. Now let's look at the ways in which we can go about accomplishing our little task. &lt;/p&gt;  &lt;/div&gt;&lt;div&gt;&lt;h4&gt;[1] Override the &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;HighLightBrushKey&lt;/span&gt; resource&lt;/h4&gt;    &lt;p&gt;This is by far the most painless method as it can be done in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Resources&lt;/span&gt; section of your &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Window&lt;/span&gt; or &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Page&lt;/span&gt;. Listing 2 shows how this is done using a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;LinearGradientBrush&lt;/span&gt; and the result is in Fig. 1. Pay special attention to the &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;highlighted&lt;/span&gt; portion of the code in Line 7. &lt;/p&gt;  &lt;/div&gt;&lt;br /&gt;  &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;&lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;Class&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"WpfUnleashed01.Window1"&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2:         &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3:         &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;x&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4:         &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;gundam&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"clr-namespace:WpfUnleashed01"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5:         &lt;span style="color: rgb(255, 0, 0);"&gt;Title&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Changing ListBox color selection"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Height&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"100"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"300"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;LinearGradientBrush&lt;/span&gt; &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;x&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;Key&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{x:Static SystemColors.HighlightBrushKey}"&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8:                              &lt;span style="color: rgb(255, 0, 0);"&gt;StartPoint&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"0,0"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;EndPoint&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"0,1"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;GradientStop&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Offset&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"0"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Color&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"LightPink"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;GradientStop&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Offset&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"0.3"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Color&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Red"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;GradientStop&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Offset&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"0.7"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Color&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Red"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;GradientStop&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Offset&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"0.9"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Color&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"LightPink"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 15:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 16:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 17:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TextBlock&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Using a LinearGradientBrush"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 18:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TextBlock&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"to change the color of"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 19:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TextBlock&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"the ListBox selected item"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 20:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 21:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 22: &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;div   style="text-align: center; width: 460px; color: rgb(0, 0, 0);font-family:arial,helvetica,sans-serif;font-size:small;"&gt;Listing 2. Overriding a predefined resource &lt;/div&gt;  &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/StNUBAAAjOI/AAAAAAAAAow/AP2Osqv4bCs/s1600-h/%5B2009.10.12%5D.01.ListBox.01%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].01.ListBox.01" alt="[2009.10.12].01.ListBox.01" src="http://lh6.ggpht.com/_nJH2hOo32r8/StNUBUgZhTI/AAAAAAAAAo0/89qdRj5HOU0/%5B2009.10.12%5D.01.ListBox.01_thumb.png?imgmax=800" border="0" height="81" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 1. Using the override method &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;Basically that is all there is to it - a super quick, easy way to change the selection color! &lt;/p&gt;  &lt;/div&gt;&lt;div&gt;&lt;h4&gt;[2] Modifying the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ControlTemplate&lt;/span&gt; of &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;&lt;/h4&gt;    &lt;p&gt;This method goes a bit deeper as it actually tweaks the default template that is used to render the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;. The code is pretty simple to follow as shown in Listing 3. The result is shown in Fig. 3.&lt;br /&gt;  &lt;/p&gt;  &lt;/div&gt;  &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;&lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;x&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;Class&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"WpfUnleashed01.Window1"&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2:         &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3:         &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;x&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4:         &lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;:&lt;span style="color: rgb(255, 0, 0);"&gt;gundam&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"clr-namespace:WpfUnleashed01"&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5:         &lt;span style="color: rgb(255, 0, 0);"&gt;Title&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Template Editing"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Height&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"100"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"300"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7:         &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!--style will automatically apply to ListBoxItems--&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Style&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;TargetType&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{x:Type ListBoxItem}"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9:             &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!--modify the Template property--&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Setter&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Property&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Template"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11:                 &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12:                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;TargetType&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"{x:Type ListBoxItem}"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13:                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Border&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Name&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Bd"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Padding&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"2"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;SnapsToDevicePixels&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"True"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14:                             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ContentPresenter&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 15:                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Border&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 16:                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 17:                             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Trigger&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Property&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"IsSelected"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Value&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"True"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 18:                                 &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Setter&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;TargetName&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Bd"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Property&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Background"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Value&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Yellow"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 19:                             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Trigger&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 20:                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 21:                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 22:                 &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 23:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Setter&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 24:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Style&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 25:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window.Resources&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 26: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 27:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 28:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 29:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TextBlock&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Using a LinearGradientBrush"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 30:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TextBlock&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"to change the color of"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 31:             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TextBlock&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Text&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"the ListBox selected item"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 32:         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ListBox&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 33:     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 34: &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;    &lt;div face="arial,helvetica,sans-serif" size="small" style="text-align: center; width: 460px; color: rgb(0, 0, 0);"&gt;Listing 3. Just changing the &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Value&lt;/span&gt; property in Line 18 produces the desired results &lt;/div&gt;  &lt;/div&gt;&lt;br /&gt;&lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/StNUBjXM4PI/AAAAAAAAAo4/SJOdMfBJjGo/s1600-h/%5B2009.10.12%5D.02.ListBox.02%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].02.ListBox.02" alt="[2009.10.12].02.ListBox.02" src="http://lh6.ggpht.com/_nJH2hOo32r8/StNUByefA0I/AAAAAAAAAo8/FZLqZu_i_EE/%5B2009.10.12%5D.02.ListBox.02_thumb.png?imgmax=800" border="0" height="84" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 2. Editing the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ControlTemplate&lt;/span&gt; of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;While this method was a bit more involved, it nonetheless did what you wanted to do, plus since you were editing the structure of the control's template, you also have the freedome to do a lot more. &lt;/div&gt;&lt;div&gt;&lt;h4&gt;[3] Using Expression Blend&lt;/h4&gt;    &lt;p&gt;The last method I will look at is using Expression Blend to make the necessary changes to the template to get the desired result. This may appeal to those who live in Blend most of their time and aren't too keen on coding in XAML. &lt;/p&gt;    &lt;p&gt;After starting your new Blend project, select the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; control from the Asset Panel and put it where ever you want in your project. This is shown in Fig. 3. Once you are done making the tweaks you can delete the item. In addition, I have added two &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TextBlock&lt;/span&gt;s to the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; for testing purposes. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/StNUCEDuecI/AAAAAAAAApA/HUhqA3yvWwQ/s1600-h/%5B2009.10.12%5D.03.ListBox.in.blend.01%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].03.ListBox.in.blend.01" alt="[2009.10.12].03.ListBox.in.blend.01" src="http://lh5.ggpht.com/_nJH2hOo32r8/StNUCSrgjsI/AAAAAAAAApE/AvvwYv32sH0/%5B2009.10.12%5D.03.ListBox.in.blend.01_thumb.png?imgmax=800" border="0" height="224" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 3. Getting a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; from the Asset panel&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;With our &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; in place, the next step is to edit the template. However, &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; has several templates. If you right click on the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; either in the Objects and Timeline panel or on the object in the scene, you will see two menus giving you access to the templates you can modify as in Fig. 4. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/StNUCtZEF6I/AAAAAAAAApI/RhI5iOHKfuQ/s1600-h/%5B2009.10.12%5D.04.ListBox.in.blend.02%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].04.ListBox.in.blend.02" alt="[2009.10.12].04.ListBox.in.blend.02" src="http://lh3.ggpht.com/_nJH2hOo32r8/StNUC9k4GxI/AAAAAAAAApM/1mySytIFJFM/%5B2009.10.12%5D.04.ListBox.in.blend.02_thumb.png?imgmax=800" border="0" height="95" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 4. &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; template options&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;The first choice is &lt;strong&gt;Edit Template&lt;/strong&gt;, but we don't want this as this is the template for the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;. Recall from above that the property we are seeking lives in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt; control, which &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; uses to wrap items added to its collection. The second submenu, &lt;strong&gt;Edit Additional Templates&lt;/strong&gt; has what we are looking for, namely the &lt;strong&gt;Edit Generated Item Container (&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;ItemContainerStyle&lt;/span&gt;)&lt;/strong&gt;. Refer to Fig. 5. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/StNUDE193YI/AAAAAAAAApQ/Nqp_kIYu8-w/s1600-h/%5B2009.10.12%5D.05.ListBox.in.blend.03%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].05.ListBox.in.blend.03" alt="[2009.10.12].05.ListBox.in.blend.03" src="http://lh6.ggpht.com/_nJH2hOo32r8/StNUDVSl6LI/AAAAAAAAApU/ldRmRucB_Yk/%5B2009.10.12%5D.05.ListBox.in.blend.03_thumb.png?imgmax=800" border="0" height="53" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 5. Editing the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;'s &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ControlTemplate&lt;/span&gt; via a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Style&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;    &lt;p&gt;Actually, we are doing Step 2 in Blend! We are using a style to modify the underlying template to suit our needs. Either way, choose &lt;strong&gt;Edit a Copy...&lt;/strong&gt;, name it and choose whether to place it in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Resource&lt;/span&gt; collection of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Window&lt;/span&gt;, &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Application&lt;/span&gt; or added to a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ResourceDictionary&lt;/span&gt;. Feel free to choose any option, I will leave mine with the default settings as in Fig. 6. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh3.ggpht.com/_nJH2hOo32r8/StNUDnU1RHI/AAAAAAAAApY/UJrC1B2BiNQ/s1600-h/%5B2009.10.12%5D.06.ListBox.in.blend.04%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].06.ListBox.in.blend.04" alt="[2009.10.12].06.ListBox.in.blend.04" src="http://lh4.ggpht.com/_nJH2hOo32r8/StNUD6hZcBI/AAAAAAAAApc/18xss1-Q1q4/%5B2009.10.12%5D.06.ListBox.in.blend.04_thumb.png?imgmax=800" border="0" height="138" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 6. Adding a resource to your project in Blend&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;Now Blend switches to template editing mode as in Fig. 7.&lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/StNUExKPugI/AAAAAAAAApg/2OrYfv3jg6M/s1600-h/%5B2009.10.12%5D.07.ListBox.in.blend.05%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.10.12].07.ListBox.in.blend.05" alt="[2009.10.12].07.ListBox.in.blend.05" src="http://lh3.ggpht.com/_nJH2hOo32r8/StNUFD8HCYI/AAAAAAAAApk/1HHmknnId-M/%5B2009.10.12%5D.07.ListBox.in.blend.05_thumb.png?imgmax=800" border="0" height="132" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 7. Template mode&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;What we are interested in is the Trigger menu and the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;IsSelected = true&lt;/span&gt; property setting. If you click on that (the red box in Fig. 7), you will notice two things:&lt;br /&gt;    &lt;/p&gt;    &lt;ul&gt;&lt;li&gt;The main work area has a red border with the heading:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;IsSelected = True&lt;/span&gt; trigger recording is on &lt;/li&gt;      &lt;li&gt;The &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;IsSelected = true&lt;/span&gt; now had a red "recording light" next to itself which basically says that whatever changes we make to this property will wipe out its old value and "record" our new choice (you still have to Save your project of course!) &lt;/li&gt;    &lt;/ul&gt;    &lt;p&gt;Fig. 8 illustrates this. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/StNUFVgFMyI/AAAAAAAAApo/AmIjRMubulc/s1600-h/%5B2009.10.12%5D.08.ListBox.in.blend.06%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].08.ListBox.in.blend.06" alt="[2009.10.12].08.ListBox.in.blend.06" src="http://lh4.ggpht.com/_nJH2hOo32r8/StNUGdQPoQI/AAAAAAAAAps/qUIZOxzqwzE/%5B2009.10.12%5D.08.ListBox.in.blend.06_thumb.png?imgmax=800" border="0" height="137" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 8. Changing the property trigger&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;The &lt;strong&gt;Properties when active&lt;/strong&gt; heading is our focus, namely the second option:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Bd.Background = {x:Static SystemColors.HighlighBrushKey}&lt;/span&gt;. If you click this option while recording is on, the Properties tab shows the brush that is used to set the &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Background&lt;/span&gt; property of an element called &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Bd&lt;/span&gt; (it's actually a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Border&lt;/span&gt;). Refer to Fig. 9 to see what I am talking about. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/StNUGsuCfoI/AAAAAAAAApw/T0SHMoC_vCc/s1600-h/%5B2009.10.12%5D.09.ListBox.in.blend.07%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].09.ListBox.in.blend.07" alt="[2009.10.12].09.ListBox.in.blend.07" src="http://lh5.ggpht.com/_nJH2hOo32r8/StNUGzWSu8I/AAAAAAAAAp0/sI8iHm5rWgY/%5B2009.10.12%5D.09.ListBox.in.blend.07_thumb.png?imgmax=800" border="0" height="144" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 9. Default brush used&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;Now you can simply turn off that brush, as in Fig. 10 and select your own. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/StNUHE4UNgI/AAAAAAAAAp4/r3EaTl4QAXE/s1600-h/%5B2009.10.12%5D.10.ListBox.in.blend.08%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].10.ListBox.in.blend.08" alt="[2009.10.12].10.ListBox.in.blend.08" src="http://lh4.ggpht.com/_nJH2hOo32r8/StNUHYo7vgI/AAAAAAAAAp8/pje0zz3FVb0/%5B2009.10.12%5D.10.ListBox.in.blend.08_thumb.png?imgmax=800" border="0" height="154" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 10. Turn off default brush&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;You are free to now add whatever you want. For example, I will add a simple &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;RadialGradientBrush&lt;/span&gt; as my new &lt;span style="color: rgb(255, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Background&lt;/span&gt; property. See Fig. 11. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/StNUHtLnahI/AAAAAAAAAqA/6_zZ0rCjOsM/s1600-h/%5B2009.10.12%5D.11.ListBox.in.blend.09%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].11.ListBox.in.blend.09" alt="[2009.10.12].11.ListBox.in.blend.09" src="http://lh5.ggpht.com/_nJH2hOo32r8/StNUH_rOpDI/AAAAAAAAAqE/SXEWYFIvA98/%5B2009.10.12%5D.11.ListBox.in.blend.09_thumb.png?imgmax=800" border="0" height="120" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 11. Changing the default brush to a radial gradient&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;At this point you can click the "record light" button either in the main work area or under the Triggers tab to turn off recording. In addition, you can jump out of &lt;strong&gt;Template Editing Mode&lt;/strong&gt; as shown in Fig. 12. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh3.ggpht.com/_nJH2hOo32r8/StNUIEBvzRI/AAAAAAAAAqI/OKaoCVF9rvo/s1600-h/%5B2009.10.12%5D.12.ListBox.in.blend.10%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].12.ListBox.in.blend.10" alt="[2009.10.12].12.ListBox.in.blend.10" src="http://lh3.ggpht.com/_nJH2hOo32r8/StNUIT_KGOI/AAAAAAAAAqM/3kGFxSnMRCA/%5B2009.10.12%5D.12.ListBox.in.blend.10_thumb.png?imgmax=800" border="0" height="112" width="244" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 12. Back to normal mode&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;Build and run the application to see the results in Fig. 13. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/StNUIccg8fI/AAAAAAAAAqQ/BOciSz1ancg/s1600-h/%5B2009.10.12%5D.13.ListBox.in.blend.11%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].13.ListBox.in.blend.11" alt="[2009.10.12].13.ListBox.in.blend.11" src="http://lh6.ggpht.com/_nJH2hOo32r8/StNUIoU03LI/AAAAAAAAAqU/xS8TRNxZO08/%5B2009.10.12%5D.13.ListBox.in.blend.11_thumb.png?imgmax=800" border="0" height="204" width="204" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;span&gt;Fig. 13. Running to application - new selected color!&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;Now if you add another &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; to your window and you want to add that style for the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBoxItem&lt;/span&gt;, right click on the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt; and follow the highlights indicated in Fig. 14. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/StNUIxU7IjI/AAAAAAAAAqY/Ds44nJ8xNfw/s1600-h/%5B2009.10.12%5D.14.ListBox.in.blend.12%5B2%5D.png"&gt;&lt;img style="border: 0px none ;" title="[2009.10.12].14.ListBox.in.blend.12" alt="[2009.10.12].14.ListBox.in.blend.12" src="http://lh5.ggpht.com/_nJH2hOo32r8/StNUJFyxZ6I/AAAAAAAAAqc/I9Y5_liQ-_I/%5B2009.10.12%5D.14.ListBox.in.blend.12_thumb.png?imgmax=800" border="0" height="44" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 14. Adding the style to another &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ListBox&lt;/span&gt;&lt;/span&gt; &lt;/div&gt;    &lt;p&gt;Have fun, happy coding (or not). &lt;/p&gt;  &lt;/div&gt;&lt;!-- end method 3 --&gt;&lt;/div&gt;&lt;!-- END outer div --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-5100338610367840155?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/5100338610367840155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=5100338610367840155' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/5100338610367840155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/5100338610367840155'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2009/10/20091012-wpf-change-color-of-selected.html' title='[2009.10.12] WPF: Change the color of the selected item in a ListBox control'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nJH2hOo32r8/StNUBUgZhTI/AAAAAAAAAo0/89qdRj5HOU0/s72-c/%5B2009.10.12%5D.01.ListBox.01_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-6656230963068640694</id><published>2009-10-11T02:24:00.001-04:00</published><updated>2009-10-11T02:24:30.575-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='F#'/><title type='text'>[2009.10.11] JAOO 2009: An Introduction to F# by Don Syme</title><content type='html'>&lt;div style="font-family: tahoma"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;h4&gt;&lt;a href="http://jaoo.dk/aarhus-2009/presentation/An+Introduction+to+F%2523"&gt;JAOO 2009: An Introduction to F#&lt;/a&gt; by &lt;a href="http://blogs.msdn.com/dsyme/default.aspx"&gt;Don Syme&lt;/a&gt;&lt;/h4&gt;      &lt;p&gt;&lt;strong&gt;Abstract: &lt;/strong&gt;        &lt;br /&gt;F# is a succinct and expressive typed functional programming language for the .NET platform, and Microsoft will be supporting F# as a first class language in Visual Studio 2010. We'll take a look at what you need to know to start having fun with F#, and how to use it productively. We'll also look at some sample applications of F# and functional programming and cover aspects of parallel, reactive and asynchronous programming with F#. &lt;/p&gt;      &lt;h4&gt;&lt;a href="http://blogs.msdn.com/dsyme/archive/2009/10/10/f-tutorial-code-and-slides-jaoo-2009-edition.aspx"&gt;Get the slides, code, etc from Don's Blog&lt;/a&gt;. &lt;/h4&gt;   &lt;/div&gt; &lt;/div&gt; &lt;!-- END outer div --&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-6656230963068640694?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/6656230963068640694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=6656230963068640694' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/6656230963068640694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/6656230963068640694'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2009/10/20091011-jaoo-2009-introduction-to-f-by.html' title='[2009.10.11] JAOO 2009: An Introduction to F# by Don Syme'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-3545488034544651695</id><published>2009-10-01T21:14:00.002-04:00</published><updated>2009-10-01T21:16:27.950-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='F#'/><category scheme='http://www.blogger.com/atom/ns#' term='Haskell'/><title type='text'>[2009.10.01] Some Haskell features for F#</title><content type='html'>&lt;div style="font-family: tahoma;"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;p&gt;I learned a bit of both Haskell and F#. I love them both but I don't think I am going to get a job with either of them anytime soon! Either way, in my quest for knowledge, there were some features of Haskell I wished were in F#. Of course, I am sure the F# folks have their reasons why things are the way they are. Moving on... &lt;/p&gt;   &lt;/div&gt;    &lt;div&gt;&lt;!-- 1 --&gt;     &lt;h4&gt;[1] Function signature and definition&lt;/h4&gt;      &lt;p&gt;In Haskell, you can simply write down your function definition and follow that with your implementation as shown in Line 1 &lt;/p&gt;      &lt;div&gt;&lt;!-- start code  --&gt;       &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;         &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="background: rgb(255, 255, 102) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"&gt;fibonacci :: &lt;span style="color: rgb(0, 0, 255);"&gt;Int&lt;/span&gt; -&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Int&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;        &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2: fibonacci 0 = 0&lt;/pre&gt;        &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  3: fibonacci 1 = 1&lt;/pre&gt;        &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  4: fibonacci n = fibonacci(n-1) + fibonacci(n-2)&lt;/pre&gt;      &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;In F# however, you cannot add the function definition at the start of the function implementation. Instead, you need to add it to a separate &lt;strong&gt;F# Signature File&lt;/strong&gt;. As such the same definition in F# is:&lt;br /&gt;       &lt;/p&gt;    &lt;div&gt;&lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;&lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  1: &lt;span style="color:blue;"&gt;let rec&lt;/span&gt; fibonacci = &lt;span style="color:blue;"&gt;function&lt;/span&gt;&lt;/pre&gt;        &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt;  2:     | 0 &lt;span style="color:blue;"&gt;-&amp;gt;&lt;/span&gt; 0&lt;/pre&gt;        &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt;  3:     | 1 &lt;span style="color:blue;"&gt;-&amp;gt;&lt;/span&gt; 1&lt;/pre&gt;        &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt;  4:     | n &lt;span style="color:blue;"&gt;-&amp;gt;&lt;/span&gt; fibonacci(n-1) + fibonacci(n-2)&lt;/pre&gt;      &lt;/div&gt;    &lt;/div&gt;&lt;!-- end code --&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;[2] Haskell is more explicit about side effects&lt;/h4&gt;    &lt;p&gt;If you want to deal with Input/Output (IO) in Haskell, you have to be explicit about it. For instance, the definition of the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;putStrLn&lt;/span&gt; function is given as: &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;String -&amp;gt; IO()&lt;/span&gt; This clearly states that this function has side effects and it is identified from the get go by the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;IO&lt;/span&gt; parameter. However, in F# you can write a function that has side effects but the function signature may not tell you that. &lt;/p&gt;  &lt;/div&gt;&lt;div&gt;&lt;h4&gt;[3] Functions as equations&lt;/h4&gt;    &lt;p&gt;Looking back at the two &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;fibonacci&lt;/span&gt; functions defined both in Haskell and F#, I can say I prefer the Haskell way of doing things. While the F# way is very close, I like the fact that in Haskell I can set up function conditions as a set of equations. You cannot use the same function name more than once in F# as in Haskell. &lt;/p&gt;  &lt;/div&gt;  &lt;p&gt;This was just a short post based on some of my observations. With that said, it's time to get back into the F# game. &lt;/p&gt;&lt;/div&gt;&lt;!-- END outer div --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-3545488034544651695?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/3545488034544651695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=3545488034544651695' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/3545488034544651695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/3545488034544651695'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2009/10/20091001-some-haskell-features-for-f.html' title='[2009.10.01] Some Haskell features for F#'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-3688869612054265765</id><published>2009-09-21T22:02:00.003-04:00</published><updated>2010-12-03T05:14:10.651-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Expression'/><category scheme='http://www.blogger.com/atom/ns#' term='XAML'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Blend'/><title type='text'>[2009.09.21] The Periodic Table in WPF using MVVM</title><content type='html'>&lt;div style="font-family: tahoma;"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;p&gt;When the idea of doing this project came to me, at first I thought I would do it the same way as I did my previous WPF Writing one. I am doing this to simply to put into practice some of the concepts I have learnt previously. But using the same methods would not really prove much - at least to me. Since then I have learned much more and as such I wanted to use newer/updated tools, technologies and concepts to build this application. &lt;/p&gt;      &lt;h3 style="background: none repeat scroll 0% 0% silver; -moz-background-inline-policy: continuous;"&gt;&lt;a href="http://www.mediafire.com/file/dzbbn9i93q13vt3/PeriodicTable.zip"&gt;Download the Code!&lt;/a&gt;&lt;/h3&gt;      &lt;p&gt;Technologies and Concepts used in this project: &lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;Visual Studio 2008 SP1 + .NET Framework 3.5 SP1 &lt;/li&gt;        &lt;li&gt;Microsoft Expression Blend 3 + Sketchflow &lt;/li&gt;        &lt;li&gt;Model-View-ViewModel (MVVM) &lt;/li&gt;        &lt;li&gt;Actions, Behaviors and Triggers &lt;/li&gt;        &lt;li&gt;Visual State Manager &lt;/li&gt;        &lt;li&gt;Data binding &lt;/li&gt;        &lt;li&gt;User Controls &lt;/li&gt;        &lt;li&gt;Styles &lt;/li&gt;        &lt;li&gt;Templates &lt;/li&gt;     &lt;/ul&gt;      &lt;h3&gt;The Prototype&lt;/h3&gt;      &lt;p&gt;Before an application is written, it may be helpful to have a decent, working prototype to sort of pitch/sell the idea of the project. Expression Blend 3 SketchFlow is the tool for the job. It will let you do rapid prototyping and provide a means to provide feedback on the initial prototype. My design will not be very complicated as this particular application will not have a whole lot of navigational needs. Basically the main window will show each element, a mouse over will bring up a summary for the element and clicking the control representing the element will bring up a details pane. Again, not a ton of interaction. &lt;/p&gt;      &lt;p&gt;First, let's take a look at what the main UI may look like with a little bit of interaction in Fig. 1. Basically each element will have an attached &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;GoToStateAction&lt;/span&gt; which will vary the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Opacity&lt;/span&gt; of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;SummaryUserControl&lt;/span&gt;. The states will react to the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;MouseEnter&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;MouseLeave&lt;/span&gt; events of the control. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwIAQdcLI/AAAAAAAAAng/EBM2wUu4tig/s1600-h/%5B2009.09.21%5D.01.Sketchflow.main.ui%5B2%5D.gif"&gt;&lt;img title="[2009.09.21].01.Sketchflow.main.ui" alt="[2009.09.21].01.Sketchflow.main.ui" src="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwIq67WGI/AAAAAAAAAnk/yPPWsT5tFMc/%5B2009.09.21%5D.01.Sketchflow.main.ui_thumb.gif?imgmax=800" height="108" width="240" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;span&gt;Fig. 1. SketchFlow of the Main UI&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;p&gt;If the user wants detailed information on the particular element, then clicking the control that represents the element will navigate to a Details window as in Fig. 2. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwJ0Pq51I/AAAAAAAAAno/Z9OwnahgOMQ/s1600-h/%5B2009.09.21%5D.02.Sketchflow.details.ui%5B2%5D.gif"&gt;&lt;img title="[2009.09.21].02.Sketchflow.details.ui" alt="[2009.09.21].02.Sketchflow.details.ui" src="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwKRT8KHI/AAAAAAAAAns/NXTP5dnJFQA/%5B2009.09.21%5D.02.Sketchflow.details.ui_thumb.gif?imgmax=800" height="163" width="240" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;span&gt;Fig. 2. SketchFlow of the Details UI&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;p&gt;Fig. 3 is the SketchFlow map of the overall project. Notice that the MainUI screen has the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;SummaryUserControl&lt;/span&gt; Component linked to it and the DetailsUI has the Details Component linked to itself. The MainUI screen is also linked to the DetailsUI and the DetailsUI is linked back to the MainUI. As such you can use the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;NavigateForwardAction&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;NavigateBackAction&lt;/span&gt; to move between the screens. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwLP5zmfI/AAAAAAAAAnw/wPPdULcaR5Y/s1600-h/%5B2009.09.21%5D.03.Sketchflow.map%5B2%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].03.Sketchflow.map" alt="[2009.09.21].03.Sketchflow.map" src="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwLdO0pOI/AAAAAAAAAn0/4o1FFB5FP50/%5B2009.09.21%5D.03.Sketchflow.map_thumb.png?imgmax=800" border="0" height="97" width="244" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;span&gt;Fig. 3. SketchFlow Map of the project&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;&lt;/div&gt;    &lt;div&gt;     &lt;h3&gt;The Design and Implementation&lt;/h3&gt;      &lt;p&gt;Fig. 4 is the Class Diagram of the overall application. Based on that, I will talk about each subsection as necessary. Fig. 5 is the hierarchy of the project. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/SrgwLyYVYUI/AAAAAAAAAn4/RYDkw9wOfbM/s1600-h/%5B2009.09.21%5D.04.PeriodicTable.ClassDiagram.01%5B2%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].04.PeriodicTable.ClassDiagram.01" alt="[2009.09.21].04.PeriodicTable.ClassDiagram.01" src="http://lh3.ggpht.com/_nJH2hOo32r8/SrgwMuCI-aI/AAAAAAAAAn8/1ezjfH20oyY/%5B2009.09.21%5D.04.PeriodicTable.ClassDiagram.01_thumb.png?imgmax=800" border="0" height="244" width="222" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;span&gt;Fig. 4. Class Diagram&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;   &lt;br /&gt;&lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwM9Zm-fI/AAAAAAAAAoA/2MCuSBdKznc/s1600-h/%5B2009.09.21%5D.05.Project.hierarchy%5B2%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].05.Project.hierarchy" alt="[2009.09.21].05.Project.hierarchy" src="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwNYJei6I/AAAAAAAAAoE/aHx3kPZpymw/%5B2009.09.21%5D.05.Project.hierarchy_thumb.png?imgmax=800" border="0" height="244" width="135" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 5. Project Hierarchy&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;p&gt;Given that my prototype passed and I have all the feedback necessary, then I would want to design next. This is where I would want to put some patterns and industry practices into play. I will use the &lt;strong&gt;Model-View-ViewModel&lt;/strong&gt; pattern here, which I feel is appropriate for an application of this scale. Also, I want to use it to better acquaint myself with the pattern. &lt;/p&gt;      &lt;h4&gt;Model&lt;/h4&gt;      &lt;p&gt;The raw data would be an XML file that I have made up using the properties for the particular element. Since I have not used a lot of LINQ or XML processing in .NET, instead of using attributes and nested nodes, I have opted to use one level of nesting for all the nodes. Fig. 6 shows this. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwNvqV6WI/AAAAAAAAAoI/C77x3h8FOsg/s1600-h/%5B2009.09.21%5D.06.model.01.xml.file%5B2%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].06.model.01.xml.file" alt="[2009.09.21].06.model.01.xml.file" src="http://lh3.ggpht.com/_nJH2hOo32r8/SrgwOEQe-tI/AAAAAAAAAoM/w3GGeW1pJ5U/%5B2009.09.21%5D.06.model.01.xml.file_thumb.png?imgmax=800" border="0" height="145" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 6. XML Data File&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;p&gt;The MVVM pattern completely separates the data from the rest of the application, so in order to expose the XML data, I have created a public class, &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;ElementModel.cs&lt;/span&gt; whose sole purpose is to expose the data (nodes) of the XML data file as a set of public properties which can then be manipulated and data bound to. All this class does is declare a set of properties which mirror the data from the XML file. It supplies a single constructor that takes &lt;strong&gt;all&lt;/strong&gt; these parameters in to create an instance of the class. In addition, there is a helper class called &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;ElementModelFileLoader.cs&lt;/span&gt; which provides a single method that returns a &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;List&lt;/span&gt; of &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModel&lt;/span&gt; by using LINQ to load, parse and create the list. The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;List&lt;span style="color:black;"&gt;&amp;lt;&lt;/span&gt;ElementModel&lt;span style="color:black;"&gt;&amp;gt;&lt;/span&gt; &lt;/span&gt;can then be referenced by the ViewModel sections to be interacted with. &lt;/p&gt;      &lt;h4&gt;View&lt;/h4&gt;      &lt;p&gt;The MVVM kit will automatically create a &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;MainView.xaml&lt;/span&gt; for a MVVM application. I will keep that view and add user controls and additional views as necessary. So the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainView&lt;/span&gt; will contain several ElementUserControl which will make up the periodic table. In addition, I have a second window called DetailsView.xaml which is loaded and displayed if the user clicks on an &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementUserControl&lt;/span&gt;. This window holds a &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;DetailsUserControl.xam&lt;/span&gt;l. Both of these user controls use Data Binding to populate the necessary &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TextBlock&lt;/span&gt; fields that make them up. &lt;/p&gt;      &lt;p&gt;Since I am on the topic, I have used Actions and Behaviors, some new features of Blend 3, as well as the Visual State Manager, to quickly add interactivity to my user controls. An Action is just a piece of code that runs after being triggered. For instance, Blend has a &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;GoToStateAction&lt;/span&gt; which as its name implies, transitions the element it is attached to go to a specified state as defined by the VSM. For example, I have defined some states that will make the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Border&lt;/span&gt; surrounding the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementUserControl&lt;/span&gt; changes its &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Opacity&lt;/span&gt; property by listening for &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MouseEnter&lt;/span&gt; and &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MouseLeave&lt;/span&gt; events. See Fig. 7. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwO7F4E1I/AAAAAAAAAoQ/Z4A0K8h2WXg/s1600-h/%5B2009.09.21%5D.07.actions.in.blend3%5B2%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].07.actions.in.blend3" alt="[2009.09.21].07.actions.in.blend3" src="http://lh3.ggpht.com/_nJH2hOo32r8/SrgwPUr9W5I/AAAAAAAAAoU/QVKkzDg5axA/%5B2009.09.21%5D.07.actions.in.blend3_thumb.png?imgmax=800" border="0" height="142" width="244" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;span&gt;Fig. 7. Using Actions in Blend 3&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;p&gt;I have an &lt;a href="http://sdasrath.blogspot.com/2009/09/20090914-wpf-actions-and-behaviors.html"&gt;earlier blog post&lt;/a&gt; that has more information on Actions and Behaviors. &lt;/p&gt;      &lt;p&gt;According to the MVVM pattern, a View will have a reference to its corresponding ViewModel, which it can set to be its data context ( &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;myView.DataContext = myViewModelInstance&lt;/span&gt; ). In this way, bindings defined in the View, which references properties exposed by the ViewModel will be resolved. I will go into more detail when I discuss the ViewModels. Fig. 8 shows a representation of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainView&lt;/span&gt; and Fig. 9 that of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt;. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt; &lt;a href="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwPkQRXTI/AAAAAAAAAoY/QcAG-Xg9Xgc/s1600-h/%5B2009.09.21%5D.08.mainview%5B5%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].08.mainview" alt="[2009.09.21].08.mainview" src="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwQaR60cI/AAAAAAAAAoc/xF8ENgvpNEY/%5B2009.09.21%5D.08.mainview_thumb%5B1%5D.png?imgmax=800" border="0" height="92" width="244" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 8. The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainView&lt;/span&gt; view of the application&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;   &lt;br /&gt;&lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/SrgwQwRVJbI/AAAAAAAAAog/QSy3tJc6Wl0/s1600-h/%5B2009.09.21%5D.09.detailsview%5B2%5D.png"&gt;&lt;img style="border: 0px none;" title="[2009.09.21].09.detailsview" alt="[2009.09.21].09.detailsview" src="http://lh4.ggpht.com/_nJH2hOo32r8/SrgwRWTW0RI/AAAAAAAAAok/KUxUbZRiQW4/%5B2009.09.21%5D.09.detailsview_thumb.png?imgmax=800" border="0" height="158" width="244" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;span&gt;Fig. 9. The &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt; view of the application&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;h4&gt;ViewModel&lt;/h4&gt;      &lt;p&gt;Ideally, each of the Views listed above would have their own corresponding ViewModel file, which would be pure C# as shown in Fig. 5 above. Actually, I did not need a separate ViewModel for the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt;, but I added one one to bind to commands that is relevant to the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt; only. However, as of this writing, it is a redundant class as its functionality was not what I expected. I hope to fix it in the future. &lt;/p&gt;      &lt;p&gt;Since most of the action happens in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainViewModel&lt;/span&gt;, I will talk about that. Since this is what the View is bound to, it is the ViewModel that exposes properties and commands for the view to bind to. In this case, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainViewModel&lt;/span&gt; wraps each &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;List&lt;span style="color:black;"&gt;&amp;lt;&lt;/span&gt;ElementModel&lt;span style="color:black;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; into an &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ObservableCollection&lt;span style="color:black;"&gt;&amp;lt;&lt;/span&gt;ElementModelViewModel&lt;span style="color:black;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;. This may seem a bit confusion but the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModelViewModel&lt;/span&gt; is actually the ViewModel which represents the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModel&lt;/span&gt;. If you recall, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModel&lt;/span&gt; was the class that exposes the data in the XML file. However, in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModelViewModel&lt;/span&gt; you can choose exactly what properties you want to expose to your Views. For example, &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModel&lt;/span&gt; could expose 10 properties, but out of those 10, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementModelViewModel&lt;/span&gt; class chooses only exposes 5 to its View. Since the View cannot "see" the model, then all it knows about is the 5 properties it is allowed to bind to. &lt;/p&gt;      &lt;p&gt;In addition to custom object properties, the ViewModel also exposes &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Commands&lt;/span&gt; that the View can bind to. So in summary, the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainViewModel&lt;/span&gt; class exposes the &lt;strong&gt;properties&lt;/strong&gt; of the Model as a collection and &lt;strong&gt;commands&lt;/strong&gt;. &lt;/p&gt;      &lt;p&gt;Since the code has lots of comments you can easily understand what is happening. A good deal of plumbing magic takes place in the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;OnStartup()&lt;/span&gt; event handler of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;App&lt;/span&gt; code behind file - &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;App.xaml.cs&lt;/span&gt; file. This is shown in Listing 1. &lt;/p&gt; &lt;!-- start listing 1 --&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;       &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Collections.ObjectModel;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; PeriodicTable.ViewModels;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; PeriodicTable.Views;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5: &lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6: &lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; PeriodicTable&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7: {&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// Interaction logic for App.xaml&lt;/span&gt;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11:     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; partial &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; App : Application&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12:     {&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13:         MainView view;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14:         MainViewModel mainViewModel;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 15:         DetailsView detailsView;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 16:         DetailsViewViewModel detailsViewModel;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 17: &lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 18:         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; App()&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 19:         {&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 20:             view = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; MainView();&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 21:             mainViewModel = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; MainViewModel();&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 22: &lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 23:             detailsView = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DetailsView();&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 24:             detailsViewModel = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DetailsViewViewModel();&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 25: &lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 26:         }&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 27:         &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; OnStartup(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, StartupEventArgs e)&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 28:         {&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 29:             &lt;span style="color: rgb(0, 128, 0);"&gt;// Call the Load method in the MainViewModel call&lt;/span&gt;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 30:             &lt;span style="color: rgb(0, 128, 0);"&gt;// This finds the XML file, loads the data, create a CLR object&lt;/span&gt;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 31:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  to represent the XML data, create a collection of these &lt;/span&gt;&lt;/pre&gt;      &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 32:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  objects and create a public property to expose this collection&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 33:             mainViewModel.LoadElementsFromFile(@"&lt;span style="color: rgb(139, 0, 0);"&gt;Models\periodicTable.xml&lt;/span&gt;");&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 34: &lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 35:             ObservableCollection&amp;lt;ElementModelViewModel&amp;gt; col = mainViewModel.ElementCollection;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 36: &lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 37:             &lt;span style="color: rgb(0, 128, 0);"&gt;// Since my user controls for the elements are not in a container&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 38:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  that knows how to bind each element as an item in the container&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 39:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  I have to manually iterate and set each control's data context property&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 40:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  (ex: ListBox - if you set the ItemsSource to the property exposing&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 41:             &lt;span style="color: rgb(0, 128, 0);"&gt;//       the ObservableCollection, then each ListBoxItem is bound to&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 42:             &lt;span style="color: rgb(0, 128, 0);"&gt;//       one item in the collection)&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 43:             &lt;span style="color: rgb(0, 0, 255);"&gt;for&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; i = 0; i &amp;lt; col.Count; i++)&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 44:             {&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 45:                 &lt;span style="color: rgb(0, 128, 0);"&gt;// use data binding to populate each user control&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 46:                 ElementUserControl euc = (ElementUserControl)view.elementsGrid.Children[i];&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 47:                 &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (euc.Name == col[i].ElementName)&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 48:                 {&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 49:                     euc.DataContext = col[i];&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 50:                     euc.symbolText.Text = col[i].Symbol;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 51:                     euc.atomicNumberText.Text = col[i].AtomicNumber;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 52: &lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 53:                     &lt;span style="color: rgb(0, 128, 0);"&gt;// respond to these events to do some bindings&lt;/span&gt;&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 54:                     euc.MouseEnter += &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; System.Windows.Input.MouseEventHandler(euc_MouseEnter);&lt;/pre&gt;      &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 55:                     euc.MouseLeftButtonDown += &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; System.Windows.Input.MouseButtonEventHandler(euc_MouseLeftButtonDown);&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 56:                 }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 57:             }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 58: &lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 59:             &lt;span style="color: rgb(0, 128, 0);"&gt;// set a higer level datacontext to get acccess to the Commands&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 60:             &lt;span style="color: rgb(0, 128, 0);"&gt;// defined in the ViewModel&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 61:             view.DataContext = mainViewModel;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 62: &lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 63:             view.Show(); &lt;span style="color: rgb(0, 128, 0);"&gt;// show the main window&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 64:         }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 65: &lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 66:         &lt;span style="color: rgb(0, 128, 0);"&gt;// Handler for the MouseLeftButtonDown event which will show the DetailsView window&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 67:         &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; euc_MouseLeftButtonDown(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, System.Windows.Input.MouseButtonEventArgs e)&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 68:         {&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 69:             &lt;span style="color: rgb(0, 128, 0);"&gt;//detailsView.LayoutRoot.DataContext = (sender as ElementUserControl).DataContext;&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 70:             detailsView.Owner = view;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 71:             &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (detailsView == &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 72:             {&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 73:                 detailsView = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DetailsView();&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 74:                 detailsView.Show();&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 75:             }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 76:             &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 77:             {&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 78:                 detailsView.Show();&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 79:             }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 80:         }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 81: &lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 82:         &lt;span style="color: rgb(0, 128, 0);"&gt;// Handler for the MouseEnter event which set the data context of each&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 83:         &lt;span style="color: rgb(0, 128, 0);"&gt;//  both the Summary and Detail UserControls&lt;/span&gt;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 84:         &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; euc_MouseEnter(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, System.Windows.Input.MouseEventArgs e)&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 85:         {&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 86:             view.summaryUC.DataContext = (sender &lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt; ElementUserControl).DataContext;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 87:             detailsView.LayoutRoot.DataContext = (sender &lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt; ElementUserControl).DataContext;&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 88:         }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 89:     }&lt;/pre&gt;      &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 90: }&lt;/pre&gt;&lt;br /&gt;   &lt;div style="text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; color: rgb(0, 0, 0); font-size: small;"&gt;Listing 1: App code behind &lt;/div&gt;    &lt;/div&gt;    &lt;p&gt;In the constructor of the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;App&lt;/span&gt; class, instances of both the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainView&lt;/span&gt; and the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt; views are created and instantiated. Within the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;OnStartup()&lt;/span&gt; handler, the XML file is loaded, the collection of data is created and each &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;ElementUserControl&lt;/span&gt; in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;MainView&lt;/span&gt; has some of its compositional control values bound to properties of the objects in the collection of data items (Lines 43-51). The code is pretty much self explanatory. &lt;/p&gt;    &lt;p&gt;Fig. 10 shows the overall operation of the application. &lt;/p&gt;    &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwRl4b6ZI/AAAAAAAAAoo/64K6QfOdbiA/s1600-h/%5B2009.09.21%5D.10.overall.app%5B2%5D.gif"&gt;&lt;img title="[2009.09.21].10.overall.app" alt="[2009.09.21].10.overall.app" src="http://lh6.ggpht.com/_nJH2hOo32r8/SrgwTbCcwxI/AAAAAAAAAos/pVHr329r2QY/%5B2009.09.21%5D.10.overall.app_thumb.gif?imgmax=800" height="190" width="240" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;Fig. 10. The app in action&lt;/span&gt; &lt;/div&gt;&lt;!-- end image div--&gt;&lt;/div&gt;&lt;div&gt;&lt;h5&gt;Current unresolved problems&lt;/h5&gt;    &lt;p&gt;The first problem I ran into was having a command execute when a certain event fires. I got around this problem using the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;CommandBehavior&lt;/span&gt; from &lt;a href="http://gallery.expression.microsoft.com/en-us/WPFBehaviors1"&gt;Tor Langlo&lt;/a&gt;. The problem after was that I wanted a &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;CloseCommand&lt;/span&gt; that the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt; can bind to, which will cause the details window to close. Even though the command works when I tested it out in the main window, it does not work here. &lt;/p&gt;    &lt;p&gt;The second problem was even though the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;CloseCommand&lt;/span&gt; did not work, I resolved to use an event in the &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;DetailsView&lt;/span&gt; code behind (yes, I know) to close the window. However, once the window was closed, I could not reopen it. I found a workaround by responding to the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Closing&lt;/span&gt; event and injecting a &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Hide()&lt;/span&gt; method on the application dispatcher queue. Basically, instead of closing the details window, I merely hide it until it is requested to be shown again. I am not satisfied with this but it will do for now. &lt;/p&gt;  &lt;/div&gt;&lt;div&gt;&lt;p&gt;Finally, this project was done with the idea that it can be extended. The fact is, I do not have any desire to create a complete XML file to represent periodic table elements. Thus far all I have are two elements. The infrastructure is there is anyone wants to add to the XML file. An idea to remedy this would be to add a window that will allow a user to add to the XML file. Maybe in the future I will add this. &lt;/p&gt;  &lt;/div&gt;  &lt;h3 style="background: none repeat scroll 0% 0% silver; -moz-background-inline-policy: continuous;"&gt;&lt;a href="http://www.mediafire.com/file/zmjyyk0nojr/PeriodicTable.zip"&gt;Download the Code!&lt;/a&gt;&lt;/h3&gt;&lt;/div&gt;&lt;!-- END outer div --&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5204554931543429996-3688869612054265765?l=sdasrath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdasrath.blogspot.com/feeds/3688869612054265765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5204554931543429996&amp;postID=3688869612054265765' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/3688869612054265765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5204554931543429996/posts/default/3688869612054265765'/><link rel='alternate' type='text/html' href='http://sdasrath.blogspot.com/2009/09/20090921-periodic-table-in-wpf-using.html' title='[2009.09.21] The Periodic Table in WPF using MVVM'/><author><name>Sparky Dasrath</name><uri>http://www.blogger.com/profile/18228818667993081374</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_nJH2hOo32r8/SjFRt4oN6LI/AAAAAAAAAg8/AZ7X8Z6pufc/S220/me3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nJH2hOo32r8/SrgwIq67WGI/AAAAAAAAAnk/yPPWsT5tFMc/s72-c/%5B2009.09.21%5D.01.Sketchflow.main.ui_thumb.gif?imgmax=800' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5204554931543429996.post-955854798619217812</id><published>2009-09-14T02:06:00.007-04:00</published><updated>2010-12-03T05:26:19.688-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Expression'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Behavior'/><category scheme='http://www.blogger.com/atom/ns#' term='Blend'/><title type='text'>[2009.09.14] WPF Actions and Behaviors: A closer look</title><content type='html'>&lt;div style="font-family: tahoma;"&gt;&lt;!-- START outer div--&gt;   &lt;div&gt;     &lt;p&gt;There are two assemblies that house the classes necessary for extending interactivity in WPF. They are: &lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;System.Windows.Interactivity.dll&lt;/span&gt; &lt;/li&gt;        &lt;li&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Microsoft.Expression.Interactions.dll&lt;/span&gt; &lt;/li&gt;     &lt;/ul&gt;      &lt;p&gt;I am using Windows Server 2008 Enterprise and for my setup, these assemblies are found in:  &lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;C:\Program Files (x86)\Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries&lt;/span&gt;. In the Libraries folder, you will find two other folders: WPF and Silverlight and each has two assemblies listed above to be used for the particular project type. I mentioned these files now because you need to do an "Add Reference" to them in order to create your own behaviors, actions or triggers. &lt;/p&gt;      &lt;p&gt;In the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;System.Windows.Interactivity.dll&lt;/span&gt;, you will find a set of classes which you will inherit from depending on what you are trying to do. Here are some of the classes you can inherit from if you want to create: &lt;/p&gt;      &lt;ol&gt;       &lt;li&gt;&lt;strong&gt;Actions + Behavior: &lt;/strong&gt;(with an associated trigger)     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TriggerAction&lt;/span&gt;,     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TriggerAction&lt;span style="color:black;"&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/span&gt;,     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TargetedTriggerAction&lt;/span&gt;,     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TargetedTriggerAction&lt;span style="color:black;"&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;/li&gt;        &lt;li&gt;&lt;strong&gt;Behavior: &lt;/strong&gt;(without an associated trigger)     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Behavior&lt;/span&gt;,     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Behavior&lt;span style="color:black;"&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;/li&gt;        &lt;li&gt;&lt;strong&gt;Triggers:&lt;/strong&gt;     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TriggerBase&lt;/span&gt;,     &lt;br /&gt;&lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TriggerBase&lt;span style="color:black;"&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;/li&gt;     &lt;/ol&gt;      &lt;p&gt;All of these classes share a common property in that they all inherit from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Animatable&lt;/span&gt;. As such, they exhibit a similar behavioral pattern as related to each other. &lt;/p&gt;      &lt;p&gt;The above list is a bit confusing when you first look at it but basically you can create a Behavior by inheriting from the exact same classes as you would use when creating an Action. The things that really separates them (and sometimes doesn't) boils down to which of the virtual methods defined in the base class you override and implement. &lt;/p&gt;      &lt;p&gt;To create just an Action, you derive from all the classes listed in 1 above &lt;strong&gt;but&lt;/strong&gt; you need to only override the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Invoke()&lt;/span&gt; method. Here is where you write code to do what you want when the Action is invoked. &lt;/p&gt;      &lt;p&gt;To create a Behavior that uses Triggers, you can derive from classes both in 1 and 2 but instead you override the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;OnAttached()&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;OnDetaching()&lt;/span&gt; methods. However, depending on what your behavior entails, you may choose to override &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Invoke()&lt;/span&gt; as well. For a Behavior without any Triggers, derive from classes in 2 and override the methods mentioned above. Of course with this approach, once you attach the behavior, it will do do what the code written tells it to do without need for triggers. Note that you can also use Commands with Behaviors. &lt;/p&gt;   &lt;/div&gt;    &lt;div&gt;     &lt;p&gt;Blend 3 and Visual Studio 2008 SP1 comes with templates to get you started in creating actions, behaviors and triggers as in Fig. 1 and 2. &lt;/p&gt; &lt;!-- start image div--&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/Sq3dXxnwr4I/AAAAAAAAAnI/sO1cMYj6koI/s1600-h/%5B2009.09.13%5D.01.Blend.new.item%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.09.13].01.Blend.new.item" alt="[2009.09.13].01.Blend.new.item" src="http://lh5.ggpht.com/_nJH2hOo32r8/Sq3dYFhH6pI/AAAAAAAAAnM/UHc5vYQBobg/%5B2009.09.13%5D.01.Blend.new.item_thumb.png?imgmax=800" border="0" height="244" width="225" /&gt;&lt;/a&gt;   &lt;br /&gt;&lt;span&gt;Fig. 1. Blend 3 interactivity templates&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;&lt;!-- start image div--&gt;&lt;br /&gt;&lt;div style="border: 1px solid rgb(192, 192, 192); text-align: center; width: 460px; font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;a href="http://lh5.ggpht.com/_nJH2hOo32r8/Sq3dYUougAI/AAAAAAAAAnQ/a2Jy8e-AQeI/s1600-h/%5B2009.09.13%5D.02.VS.new.item%5B2%5D.png"&gt;&lt;img style="border-width: 0px;" title="[2009.09.13].02.VS.new.item" alt="[2009.09.13].02.VS.new.item" src="http://lh4.ggpht.com/_nJH2hOo32r8/Sq3dYqfoFgI/AAAAAAAAAnU/AjO4Vnxp10A/%5B2009.09.13%5D.02.VS.new.item_thumb.png?imgmax=800" border="0" height="156" width="244" /&gt;&lt;/a&gt;   &lt;br /&gt;&lt;span&gt;Fig. 2. Visual Studio interactivity templates&lt;/span&gt; &lt;/div&gt; &lt;!-- end image div--&gt;      &lt;p&gt;Each time you add one of these items to your project, a skeleton implementation is created. For example, if you are creating a new Behavior, your class will already derive from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;Behavior&lt;span style="color:black;"&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/span&gt;, and &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;OnAttached()&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;OnDetaching()&lt;/span&gt; methods will be overridden. In addition, each comes commented to point you in the right direction as shown in Listing 1. &lt;/p&gt; &lt;!--start listing 1 --&gt;      &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;       &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Data;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Documents;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Input;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Media;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Media.Imaging;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Shapes;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Interactivity;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13: &lt;span style="color: rgb(0, 128, 0);"&gt;//using Microsoft.Expression.Interactivity.Core;&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 15: &lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; ActionBehaviorBlogDemo01&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 16: {&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 17:   &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; Behavior2 : Behavior&amp;lt;DependencyObject&amp;gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 18:   {&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 19:     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Behavior2()&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 20:     {&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 21:       &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code required on object creation below this point.&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 22: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 23:       &lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 24:       &lt;span style="color: rgb(0, 128, 0);"&gt;// The line of code below sets up the relationship between the command and the function&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 25:       &lt;span style="color: rgb(0, 128, 0);"&gt;// to call. Uncomment the below line and add a reference to Microsoft.Expression.Interactions&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 26:       &lt;span style="color: rgb(0, 128, 0);"&gt;// if you choose to use the commented out version of MyFunction and MyCommand instead of&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 27:       &lt;span style="color: rgb(0, 128, 0);"&gt;// creating your own implementation.&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 28:       &lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 29:       &lt;span style="color: rgb(0, 128, 0);"&gt;// The documentation will provide you with an example of a simple command implementation&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 30:       &lt;span style="color: rgb(0, 128, 0);"&gt;// you can use instead of using ActionCommand and referencing the Interactions assembly.&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 31:       &lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 32:       &lt;span style="color: rgb(0, 128, 0);"&gt;//this.MyCommand = new ActionCommand(this.MyFunction);&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 33:     }&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 34: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 35:     &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; OnAttached()&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 36:     {&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 37:       &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.OnAttached();&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 38: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 39:       &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code that you would want run when the Behavior is attached to an object.&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 40:     }&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 41: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 42:     &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; OnDetaching()&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 43:     {&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 44:       &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.OnDetaching();&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 45: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 46:       &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code that you would want run when the Behavior is removed from an object.&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 47:     }&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 48: &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 49:     &lt;span style="color: rgb(0, 128, 0);"&gt;/*&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 50:     &lt;span style="color: rgb(0, 128, 0);"&gt;public ICommand MyCommand&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 51:     &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 52:       &lt;span style="color: rgb(0, 128, 0);"&gt;get;&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 53:       &lt;span style="color: rgb(0, 128, 0);"&gt;private set;&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 54:     &lt;span style="color: rgb(0, 128, 0);"&gt;}&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 55:      &lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 56:     &lt;span style="color: rgb(0, 128, 0);"&gt;private void MyFunction()&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 57:     &lt;span style="color: rgb(0, 128, 0);"&gt;{&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 58:       &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code that defines what the behavior will do when invoked.&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 59:     &lt;span style="color: rgb(0, 128, 0);"&gt;}&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 60:     &lt;span style="color: rgb(0, 128, 0);"&gt;/*&lt;/span&gt;&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 61:   }&lt;/pre&gt;     &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 62: }&lt;/pre&gt;&lt;br /&gt;&lt;div face="arial,helvetica,sans-serif" size="small" style="text-align: center; width: 460px; color: rgb(0, 0, 0);"&gt;Listing 1: Generated template to implement a Behavior &lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;!-- end listing 1 --&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;Examples of Actions and Behaviors&lt;/h3&gt;  &lt;p&gt;In all the samples, I am basically running the same animation, which changes the &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Opacity&lt;/span&gt; of the targeted or associated element. The main areas to look at is the base classes being derived from in each case as well as the comments in each class. &lt;/p&gt;  &lt;h4&gt;Example 1: Action which derives from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TriggerAction&lt;/span&gt;&lt;br /&gt;&lt;/h4&gt;  &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;&lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Interactivity;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6: &lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; ActionBehaviorBlogDemo02&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7: {&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// Class showing a simple action that can be invoked by a trigger&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12:     &lt;span style="color: rgb(0, 128, 0);"&gt;// Change the type parameter to be a FrameworkElement to access&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13:     &lt;span style="color: rgb(0, 128, 0);"&gt;//  the AssociatedObject's Opacity property&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14:     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; OpacityAction : TriggerAction&amp;lt;FrameworkElement&amp;gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 15:     {&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 16:         &lt;span style="color: rgb(0, 128, 0);"&gt;// variables to hold Storyboard and&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 17:         &lt;span style="color: rgb(0, 128, 0);"&gt;//  DoubleAnimation objects&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 18:         Storyboard myStoryboard = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Storyboard();&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 19:         DoubleAnimation myDoubleAnimation = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DoubleAnimation();&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 20:  &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 21:         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OpacityAction(){ }&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 22: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 23:         &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Invoke(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; o)&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 24:         {&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 25:             &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code that defines what the Action &lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 26:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  will do when triggered/invoked.&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 27:             &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Animate();&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 28:         }&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 29: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 30:         &lt;span style="color: rgb(0, 128, 0);"&gt;// method to be called by Invoke()&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 31:         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Animate()&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 32:         {&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 33:             &lt;span style="color: rgb(0, 128, 0);"&gt;// set up the animation properties &lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 34:             myDoubleAnimation.To = 0.2;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 35:             myDoubleAnimation.Duration = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Duration(TimeSpan.FromSeconds(1));&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 36:             myDoubleAnimation.AutoReverse = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 37:             myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 38: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 39:             &lt;span style="color: rgb(0, 128, 0);"&gt;// the target of the animation is the AssociatedObject&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 40:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  i.e the object the Action is attached to&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 41:             Storyboard.SetTarget(myDoubleAnimation, AssociatedObject);&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 42:             &lt;span style="color: rgb(0, 128, 0);"&gt;// animate the Opacity property&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 43:             Storyboard.SetTargetProperty(myDoubleAnimation,&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 44:                 &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; PropertyPath(FrameworkElement.OpacityProperty));&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 45:             myStoryboard.Children.Add(myDoubleAnimation);&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 46:             myStoryboard.Begin();&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 47:         }&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 48:     }&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 49: }&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: center; width: 460px; color: rgb(0, 0, 0); font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Listing 2: A simple Action &lt;/div&gt;  &lt;/div&gt;  &lt;h4&gt;Example 2: Action which derives from &lt;span style="color: rgb(44, 146, 175);font-family:'Courier New',courier,monospace;" &gt;TargetedTriggerAction&lt;/span&gt;&lt;br /&gt;&lt;/h4&gt;  &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;&lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  2: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  3: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Interactivity;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  4: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  5: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  6: &lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; ActionBehaviorBlogDemo02&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  7: {&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  8: &lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt;  9:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 10:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// Class used to set the target of the action other to the element it is attached to&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 11:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 12:     &lt;span style="color: rgb(0, 128, 0);"&gt;// If you want your Action to target elements other than its parent, extend your class&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 13:     &lt;span style="color: rgb(0, 128, 0);"&gt;// from TargetedTriggerAction instead of from TriggerAction&lt;/span&gt;&lt;/pre&gt;    &lt;pre   style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,'Courier New',courier,monospace;font-size:11px;"&gt; 14:     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; OpacityTargetedTriggerAction : TargetedTriggerAction&amp;lt;FrameworkElement&amp;gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 15:     {&lt;/pre&gt;    &lt;pre style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"&gt; 16:         &lt;span style="color: rgb(0, 128, 0);"&gt;// variables to hold Storyboard and&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 17:         &lt;span style="color: rgb(0, 128, 0);"&gt;//  DoubleAnimation objects&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 18:         Storyboard myStoryboard = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Storyboard();&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 19:         DoubleAnimation myDoubleAnimation = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DoubleAnimation();&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 20:         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OpacityTargetedTriggerAction()&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 21:         {&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 22:             &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code required on object creation below this point.&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 23:         }&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 24: &lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 25:         &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Invoke(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; o)&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 26:         {&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 27:             &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (Target == &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 28:             {&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 29:                 &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 30:             }&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 31: &lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 32:             &lt;span style="color: rgb(0, 128, 0);"&gt;// Insert code that defines what the Action &lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 33:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  will do when triggered/invoked.&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 34:             &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Animate();&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 35:         }&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 36: &lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 37:         &lt;span style="color: rgb(0, 128, 0);"&gt;// method to be called by Invoke()&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 38:         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Animate()&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 39:         {&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 40:             &lt;span style="color: rgb(0, 128, 0);"&gt;// set up the animation properties &lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 41:             myDoubleAnimation.To = 0.2;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 42:             myDoubleAnimation.Duration = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Duration(TimeSpan.FromSeconds(1));&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 43:             myDoubleAnimation.AutoReverse = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 44:             myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 45: &lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 46:             &lt;span style="color: rgb(0, 128, 0);"&gt;// The action is meant to be executed on the Target&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 47:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  element, which can be &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 48:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  or another element. By using the Target property here,&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 49:             &lt;span style="color: rgb(0, 128, 0);"&gt;//  both cases are covered.&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 50:             Storyboard.SetTarget(myDoubleAnimation, &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.Target);&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 51:             &lt;span style="color: rgb(0, 128, 0);"&gt;// animate the Opacity property&lt;/span&gt;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 52:             Storyboard.SetTargetProperty(myDoubleAnimation,&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 53:                 &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; PropertyPath(FrameworkElement.OpacityProperty));&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 54:             myStoryboard.Children.Add(myDoubleAnimation);&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 55:             myStoryboard.Begin();&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 56:         }&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 57:     }&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 58: }&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: center; width: 460px; color: rgb(0, 0, 0); font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Listing 3: An Action that can execute on the attached object or on another &lt;span style="color: rgb(0, 0, 0);font-family:'Courier New',courier,monospace;" &gt;Target&lt;/span&gt; &lt;/div&gt;  &lt;/div&gt;  &lt;h4&gt;Example 3: A simple Behavior&lt;br /&gt;&lt;/h4&gt;  &lt;div style="border: 1px solid rgb(192, 192, 192); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px; width: 460px;"&gt;&lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  1: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  2: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  3: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Interactivity;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  4: &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Windows.Media.Animation;&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  5: &lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  6: &lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; ActionBehaviorBlogDemo02&lt;/pre&gt;    &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  7: {&lt;/pre&gt;   &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  8:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt;  9:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// Basic independent behavior&lt;/span&gt;&lt;/pre&gt;   &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 10:     &lt;span style="color: rgb(128, 128, 128);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;   &lt;pre face="consolas,'Courier New',courier,monospace" size="11px" style="margin: 0em; background-color: rgb(251, 251, 251); width: 100%;"&gt; 11:     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; OpacityTriggerlessBehavior : Behavior&amp;lt;FrameworkElem
