<?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-5416778419136716668</id><updated>2011-11-27T15:39:40.758-08:00</updated><category term='wcf'/><category term='aspnet'/><category term='tangent'/><category term='frontiers'/><category term='user experience'/><category term='xaml'/><category term='finance'/><category term='javascript'/><category term='web'/><category term='silverlight'/><category term='patterns'/><category term='books'/><category term='security'/><category term='programming'/><category term='soa'/><category term='vuplan'/><category term='template'/><category term='concurrency'/><category term='windowsphone'/><category term='css'/><category term='wpf'/><category term='html'/><category term='windows'/><category term='performance'/><category term='tv'/><category term='touch'/><category term='hardware'/><category term='investing'/><title type='text'>LUKE PUPLETT</title><subtitle type='html'>My information super high horse.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>64</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-571218108143356770</id><published>2011-10-02T03:43:00.001-07:00</published><updated>2011-10-02T03:44:43.804-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='hardware'/><title type='text'>Solved: black border around screen with HDMI</title><content type='html'>&lt;p&gt;&lt;strong&gt;After purchasing 2 Benq HD2420HD for £125 each (!) from Amazon, I got a nasty black border around the image on the HMDI-connected panel.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To remove the nasty black border around the screen when a panel is connected via HDMI, set the Overscan to 0%, the menu option for ATI cards can be found here:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-NP3uiomc6bg/TohAVI0AMnI/AAAAAAAAAHg/jWpcnnTEJGw/s1600-h/image%25255B3%25255D.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="image" border="0" alt="image" src="http://lh6.ggpht.com/-NrOL2AX24dM/TohAXGitUNI/AAAAAAAAAHk/iy5ueqHG134/image_thumb%25255B1%25255D.png?imgmax=800" width="628" height="625" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-hLcDqznq9Nk/TohAYbBr4WI/AAAAAAAAAHo/4kiGZN_qKlQ/s1600-h/image%25255B8%25255D.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="image" border="0" alt="image" src="http://lh6.ggpht.com/-6ZzjwhnLN_w/TohAZwK6k7I/AAAAAAAAAHs/AIlLzsv-WW8/image_thumb%25255B4%25255D.png?imgmax=800" width="630" height="617" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-571218108143356770?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/571218108143356770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2011/10/solved-black-border-around-screen-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/571218108143356770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/571218108143356770'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2011/10/solved-black-border-around-screen-with.html' title='Solved: black border around screen with HDMI'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-NrOL2AX24dM/TohAXGitUNI/AAAAAAAAAHk/iy5ueqHG134/s72-c/image_thumb%25255B1%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7677764938999866266</id><published>2011-09-25T04:40:00.001-07:00</published><updated>2011-09-28T01:11:51.306-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Combining Anonymous Types with Dynamic</title><content type='html'>&lt;strong&gt;This short blog post shows the outcome of a quick experiment. I am researching a way to back a WPF View with a ViewModel whose properties are not known until runtime.&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;It’s been a long time since I last blogged. I built a house, I’ve had a baby, well, Cassie did the hard work, and also worked on a very large Silverlight project for a large investment bank (a foreign exchange trading platform) and then moved again to a start-up in the West End of London.&lt;br /&gt;&lt;br /&gt;The former job was all hush-hush and even though our small team had the pleasure of a couple of exclusive hours with Silverlight evangelist Mike Taulty, we weren’t able to tell him what we were working on. So blogging was out of the question, which is a real shame for me and the community as a whole, in my opinion (although understandable).&lt;br /&gt;&lt;h5&gt;The Interesting Bit&lt;/h5&gt;Anyway, while playing this afternoon, I discovered that anonymous types can escape the confines of the scope they’re declared in by returning them as dynamic!&lt;br /&gt;Check this out:&lt;br /&gt;&lt;div class="wlWriterEditableSmartContent" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:30e80d6f-d0c1-40f2-884b-ca97be0e833c" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre style="background-color: white; height: 641px; overflow: auto; width: 634px;"&gt;&lt;div&gt;&lt;span style="color: teal;"&gt; 1&lt;/span&gt; &lt;span style="color: black;"&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;&lt;span style="color: black;"&gt; Main(&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;[] args)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 2&lt;/span&gt; &lt;span style="color: black;"&gt;        {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 3&lt;/span&gt; &lt;span style="color: black;"&gt;            var rows &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; ReadDynamicRows();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 4&lt;/span&gt; &lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 5&lt;/span&gt; &lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt;&lt;span style="color: black;"&gt; (var row &lt;/span&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt;&lt;span style="color: black;"&gt; rows)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 6&lt;/span&gt; &lt;span style="color: black;"&gt;                Console.WriteLine(row.Id);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 7&lt;/span&gt; &lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 8&lt;/span&gt; &lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;object&lt;/span&gt;&lt;span style="color: black;"&gt; o &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; rows[&lt;/span&gt;&lt;span style="color: purple;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt; 9&lt;/span&gt; &lt;span style="color: black;"&gt;            var properties &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; o.GetType().GetProperties();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;10&lt;/span&gt; &lt;span style="color: black;"&gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;11&lt;/span&gt; &lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;12&lt;/span&gt; &lt;span style="color: black;"&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt;&lt;span style="color: black;"&gt; List&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;dynamic&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; ReadDynamicRows()&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;13&lt;/span&gt; &lt;span style="color: black;"&gt;        {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;14&lt;/span&gt; &lt;span style="color: black;"&gt;            dynamic row;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;15&lt;/span&gt; &lt;span style="color: black;"&gt;            List&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;dynamic&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt; rows &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt; List&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: black;"&gt;dynamic&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: black;"&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;16&lt;/span&gt; &lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt;&lt;span style="color: black;"&gt; (var reader &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;17&lt;/span&gt; &lt;span style="color: black;"&gt;                DataHelper.ExecuteSqlStatementReader(&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;18&lt;/span&gt; &lt;span style="color: black;"&gt;                    DataHelper.BuildConnectionString(), &lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;19&lt;/span&gt; &lt;span style="color: black;"&gt;                    &lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: maroon;"&gt;SELECT TOP 1000 * FROM SomeTable&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: black;"&gt;))&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;20&lt;/span&gt; &lt;span style="color: black;"&gt;            {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;21&lt;/span&gt; &lt;span style="color: black;"&gt;                &lt;/span&gt;&lt;span style="color: blue;"&gt;while&lt;/span&gt;&lt;span style="color: black;"&gt; (reader.Read())&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;22&lt;/span&gt; &lt;span style="color: black;"&gt;                {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;23&lt;/span&gt; &lt;span style="color: black;"&gt;                    row &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;24&lt;/span&gt; &lt;span style="color: black;"&gt;                    {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;25&lt;/span&gt; &lt;span style="color: black;"&gt;                        Id &lt;/span&gt;&lt;span style="color: black;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; reader.GetString(&lt;/span&gt;&lt;span style="color: purple;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;26&lt;/span&gt; &lt;span style="color: black;"&gt;                    };&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;27&lt;/span&gt; &lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;28&lt;/span&gt; &lt;span style="color: black;"&gt;                    rows.Add(row);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;29&lt;/span&gt; &lt;span style="color: black;"&gt;                }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;30&lt;/span&gt; &lt;span style="color: black;"&gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;31&lt;/span&gt; &lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;32&lt;/span&gt; &lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt;&lt;span style="color: black;"&gt; rows;             &lt;br /&gt;&lt;/span&gt;&lt;span style="color: teal;"&gt;33&lt;/span&gt; &lt;span style="color: black;"&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;What’s really interesting to me is that the properties can be reflected upon. In my experiments with the dynamic type, this isn’t true and so databinding won’t work.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I don’t believe its that simple to stick them in an ObservableCollection bound to a DataGrid because the mechanics of it uses &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.icustomtypedescriptor.aspx"&gt;ICustomTypeDescriptor&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;More to come... (have a train to catch)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7677764938999866266?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7677764938999866266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2011/09/combining-anonymous-types-with-dynamic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7677764938999866266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7677764938999866266'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2011/09/combining-anonymous-types-with-dynamic.html' title='Combining Anonymous Types with Dynamic'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-4747214059083999694</id><published>2011-01-05T07:17:00.001-08:00</published><updated>2011-01-05T07:17:47.977-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Note to self: Reading extended file properties</title><content type='html'>&lt;p&gt;&lt;strong&gt;To read the extended file property metadata from a file, such as a the exposure of a photo or the duration of some media file, then follow these simple steps.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Download and reference the Windows API Code Pack, no link here since it changes name and version, but it easily found in Bing.&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:9c648241-4628-4f29-9516-0e6046f35c4d" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 435px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Usings&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.IO;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; Microsoft.WindowsAPICodePack.Shell;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; Microsoft.WindowsAPICodePack.Shell.PropertySystem;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Method&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; mediaPath &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;@&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;c:\Users\Public\Recorded TV\Shark Tale_BBC ONE_2010_12_31_14_08_00.wtv&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;var file &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; FileInfo(mediaPath);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; The formatId and propertyId values can be taken from MSDN:&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #008000; text-decoration: underline;"&gt;http://msdn.microsoft.com/en-us/library/bb787399&lt;/span&gt;&lt;span style="color: #008000;"&gt;(v=VS.85).aspx&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;PropertyKey pk &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyKey(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;64440490-4C8B-11D1-8B70-080036B11A03&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;3&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;var p &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; ShellFile.FromFilePath(file.FullName).Properties.GetProperty(pk);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (p &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Concat(p.CanonicalName, &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;: &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, p.ValueAsObject));&lt;br /&gt;&lt;br /&gt;    UInt64 d &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; (UInt64)p.ValueAsObject;&lt;br /&gt;    var duration &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; TimeSpan.FromTicks((&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;long&lt;/span&gt;&lt;span style="color: #000000;"&gt;)d);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-4747214059083999694?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/4747214059083999694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2011/01/note-to-self-reading-extended-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4747214059083999694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4747214059083999694'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2011/01/note-to-self-reading-extended-file.html' title='Note to self: Reading extended file properties'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6646035789545239136</id><published>2010-12-17T14:08:00.001-08:00</published><updated>2010-12-17T14:08:11.741-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><title type='text'>To PowerShell or Not</title><content type='html'>&lt;p&gt;&lt;strong&gt;To pull down, sort out and import the guide data for vuPlan.tv I thought it would be a good excuse to use PowerShell. I’ve been wanting to use this for ages, to get up-to-speed with what the future of scripting on MS Windows looks like.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;I hated every moment of it.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This simple script took more than a whole day to write.&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:824ad451-181f-433a-8239-9603098b0a54" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 435px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #008000;"&gt;#&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt; Looks for the latest downloaded .zip file and extracts its contents.&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$random&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; new&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;object &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;typename System.Random&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;C:\DATA&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$sourceFolder&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;\EPG&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$extractRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;\EPG\TEMP-&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$random&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Next(&lt;/span&gt;&lt;span style="color: #000000;"&gt;100&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRepository&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;\EPG\HEAP&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$unzipToolPath&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;\unzip.exe&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$importerToolPath&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;C:\Users\Public\Documents\~Main\Vuplan\Evoq.Vuplan.Data.Epg.Importer\Evoq.Vuplan.Data.Epg.Importer\bin\Release\import.exe&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;clear&lt;br /&gt;&lt;br /&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;location &lt;/span&gt;&lt;span style="color: #800080;"&gt;$sourceFolder&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;$latestFiles = get-childitem | where { $_.Name -like &amp;quot;*TV*&amp;quot; -and $_.LastWriteTime.Date -eq [DateTime]::Now.Date  }&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$files&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; get&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;childitem &lt;/span&gt;&lt;span style="color: #000000;"&gt;|&lt;/span&gt;&lt;span style="color: #000000;"&gt; where { &lt;/span&gt;&lt;span style="color: #800080;"&gt;$_&lt;/span&gt;&lt;span style="color: #000000;"&gt;.PSIsContainer &lt;/span&gt;&lt;span style="color: #008080;"&gt;-eq&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;$false&lt;/span&gt;&lt;span style="color: #000000;"&gt; }&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$latestFiles&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$files&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;|&lt;/span&gt;&lt;span style="color: #000000;"&gt; sort &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;property &lt;/span&gt;&lt;span style="color: #000000;"&gt;@&lt;/span&gt;&lt;span style="color: #000000;"&gt;{Expression&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;{ &lt;/span&gt;&lt;span style="color: #800080;"&gt;$_&lt;/span&gt;&lt;span style="color: #000000;"&gt;.LastWriteTime }; Ascending&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;$false&lt;/span&gt;&lt;span style="color: #000000;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$latestZip&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$latestFiles&lt;/span&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;]&lt;br /&gt;echo &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Extracting &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$latestZip&lt;/span&gt;&lt;span style="color: #000000;"&gt;.FullName &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt; to &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$extractRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;md &lt;/span&gt;&lt;span style="color: #800080;"&gt;$extractRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt; This little chunk of code unzips using Windows shell but problems with the feckin .zip file mean&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt; that some files extract twice and invoke a UI prompt for overwrite-replace.&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;$shell = new-object -com shell.application&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;$zipFile = $shell.namespace($latestZip.FullName)&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;$extractTo = $shell.namespace($extractRoot)&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;$extractTo.Copyhere($zipFile.Items())&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;foreach($item in $extractTo.Items) {&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;    $item&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span style="color: #008000;"&gt;}&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$processArgs&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;-o &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$latestZip&lt;/span&gt;&lt;span style="color: #000000;"&gt;.FullName &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt; -d &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$extractRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; new&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;object System.Diagnostics.ProcessStartInfo(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$unzipToolPath&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;$processArgs&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;.UseShellExecute &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;$false&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$unzipProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; new&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;object System.Diagnostics.&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;Process&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$unzipProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.StartInfo &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;echo &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Starting process.&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$unzipProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Start()&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #800080;"&gt;$unzipProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.HasExited)&lt;br /&gt;{&lt;br /&gt;    echo &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Waiting for process to complete...&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    [System.Threading.Thread]&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;Sleep(&lt;/span&gt;&lt;span style="color: #000000;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$sourceDirectoryInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; new&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;object System.IO.DirectoryInfo(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$extractRoot&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;foreach&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;in&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$sourceDirectoryInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;.GetFiles())&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #800080;"&gt;$destinationPath&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; [String]&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;Concat(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$dataRepository&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;\&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Name)&lt;br /&gt;        &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; ([System.IO.File]&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;Exists(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$destinationPath&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #008080;"&gt;-ne&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;$true&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Copying &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt; to the heap...&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;br /&gt;        [System.IO.File]&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;Copy(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;.FullName, &lt;/span&gt;&lt;span style="color: #800080;"&gt;$destinationPath&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Extension &lt;/span&gt;&lt;span style="color: #008080;"&gt;-eq&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;.xml&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$processArgs&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;.FullName&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; new&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;object System.Diagnostics.ProcessStartInfo(&lt;/span&gt;&lt;span style="color: #800080;"&gt;$importerToolPath&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;$processArgs&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;.UseShellExecute &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;$false&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$importProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; new&lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt;object System.Diagnostics.&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;Process&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$importProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.StartInfo &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$startInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        echo &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Starting import.&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #800080;"&gt;$importProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Start()&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #800080;"&gt;$importProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.HasExited)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;[&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$item&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;]&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt; Waiting for import to complete... &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; ([DateTime]&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;Now &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800080;"&gt;$importProcess&lt;/span&gt;&lt;span style="color: #000000;"&gt;.StartTime)&lt;br /&gt;            [System.Threading.Thread]&lt;/span&gt;&lt;span style="color: #000000;"&gt;::&lt;/span&gt;&lt;span style="color: #000000;"&gt;Sleep(&lt;/span&gt;&lt;span style="color: #000000;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #800080;"&gt;$sourceDirectoryInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Delete(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;$true&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;It was such a disappointment. I’m still disappointed as I type this. Being a scripting environment for the .NET Framework, I thought it’d be so cool. The power of the .NET Framework and the freedom of scripting.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;But the Integrated Scripting Environment (ISE) is just some crappy cobbled-together tool written in not much more time than it took me to write my script here. It even uses the atrocious code editor from the Expression suite and not the awesome editor that Noah Richards and his team made for Visual Studio 2010.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;But worst of all, it has no IntelliSense. Can you imagine?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Apparently there’s PowerGUI that is a non-Microsoft ISE that does have autocomplete (which is an absolute must when you’ve all of the .NET Framework at your disposal and there’s no compiler to warn as you go), but I read something about a guy having a problem with a script which was down to the PowerGUI editor getting confused over some combination of slashes and dots, which put me right off.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So I punched my code into the MS ISE, almost single fingering the keys to ensure it was all correct, like I was back in the 1980s with my Sharp MZ-700.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And slowly my will to live drained from me.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I even read some dude praising it because all he needed was Notepad and Google to be a master of his universe. Not out of my pocket does an engineer work with such inefficiency. Would you take the cab if you saw that the driver was &lt;em&gt;peddling&lt;/em&gt; the car through a hole in the floor?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Next time, I will do what I usually do and write a full blown console application in a tenth of the time.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you’re a .NET developer, Hell, if you’re a sys admin (as I was for years), I’d just use Visual Studio all the way. Skip those cmdlets.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Get properly organised by writing and adding to an assembly of reusable components and classes to help you do your admin tasks. Get the whole department adding to a super cool library of administrative joy.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I came into programming from a sys admin background. I worked for a very large organisation with tens of thousands of computers. I saw the same code across so many scripts, it was a terrible duplication of effort.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So I cultivated a library of fine-grained admin tools in a COM component that was deployed to the PC estate and called from the scripts, a core set of reusable functionality. Then later I integrated it with a Microsoft Excel add-in. That’s right, sys admins could build out their scripts from a report in Excel, drag and drop, cut and paste. Done.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Anyway, I’m going off on a tangent. The benefits of PowerShell from my noob viewpoint are, simple visual remotability and a focus for vendors to create simple APIs (by way of custom cmdlets).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;These things are important for the daily activities of a busy sys admin performing live commands, sure, but if its a automated or long scripted process you need to write, its not ideal.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you’re already a programmer, then just write a proper applet in the superior tools you know and love and share it with your team. And if you’re not a programmer, skip scripting and learn C#. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Coding in Visual Studio will blow your mind and make you a hero.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Luke&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6646035789545239136?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6646035789545239136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/12/to-powershell-or-not.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6646035789545239136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6646035789545239136'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/12/to-powershell-or-not.html' title='To PowerShell or Not'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-8182962907526318412</id><published>2010-12-09T13:48:00.001-08:00</published><updated>2010-12-09T13:48:35.341-08:00</updated><title type='text'>The World’s Best MessageBox Control (it maybe just a bog standard message box control to you but I like it)</title><content type='html'>&lt;p&gt;&lt;strong&gt;Here it is in action, recorded on a Flip Mino HD, which really doesn’t like filming anything close-by or with fine detail. But you get the picture.&lt;/strong&gt;&lt;/p&gt; &lt;iframe height="300" src="http://player.vimeo.com/video/17646966" frameborder="0" width="400"&gt;&lt;/iframe&gt;  &lt;p&gt;&lt;a href="http://vimeo.com/17646966"&gt;SimpleMessageBox for Windows Phone 7&lt;/a&gt; from &lt;a href="http://vimeo.com/user4951144"&gt;Luke Puplett&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The message box is a pretty straight forward affair, following the parts and states model. What’s possibly interesting is that the buttons are added as KeyValue&amp;lt;string, ICommand&amp;gt; pairs and rendered in the default template using a WrapPanel.&lt;/p&gt;  &lt;p&gt;This means its dependant on two external libraries; Laurent Bugnion’s excellent &lt;a href="http://mvvmlight.codeplex.com/"&gt;MVVM Light Toolkit&lt;/a&gt; and also the &lt;a href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit for Windows Phone&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;But the cool thing is that its entirely MVVM-able and the WrapPanel means that you can chuck as many buttons as you like on the page and they’ll look fabulous (darling).&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:c563361e-1f71-49ef-a673-bd49550ed451" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 333px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;namespace&lt;/span&gt;&lt;span style="color: #000000;"&gt; Evoq.Vuplan.Mobile.Phone.Controls&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Collections.ObjectModel;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Windows;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Windows.Controls;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Collections.Generic;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Windows.Input;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; GalaSoft.MvvmLight.Command;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Step 1a) Using this custom control in a XAML file that exists in the current project.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Add this XmlNamespace attribute to the root element of the markup file where it is &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; to be used:&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;     xmlns:MyNamespace=&amp;quot;clr-namespace:AnimationExperiments&amp;quot;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Step 1b) Using this custom control in a XAML file that exists in a different project.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Add this XmlNamespace attribute to the root element of the markup file where it is &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; to be used:&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;     xmlns:MyNamespace=&amp;quot;clr-namespace:AnimationExperiments;assembly=AnimationExperiments&amp;quot;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; You will also need to add a project reference from the project where the XAML file lives&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; to this project and Rebuild to avoid compilation errors:&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;     Right click on the target project in the Solution Explorer and&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;     &amp;quot;Add Reference&amp;quot;-&amp;gt;&amp;quot;Projects&amp;quot;-&amp;gt;[Browse to and select this project]&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Step 2)&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Go ahead and use your control in the XAML file.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;     &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;MyNamespace:WindowGrip/&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;    &lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    [TemplatePart(Type &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(TextBlock), Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox.TitlePartName)]&lt;br /&gt;    [TemplatePart(Type &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(TextBlock), Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox.MessagePartName)]&lt;br /&gt;    [TemplatePart(Type &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(ItemsControl), Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox.ButtonItemsPartName)]&lt;br /&gt;    [TemplateVisualState(GroupName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;VisibilityStates&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox.CollapsedStateName)] &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Default&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    [TemplateVisualState(GroupName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;VisibilityStates&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, Name &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox.VisibleStateName)]&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox : Control&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Fields&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; _currentState &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;stateSetInOnApplyTemplate&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Constants&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; TitlePartName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;TitlePart&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; MessagePartName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;MessagePart&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; ButtonItemsPartName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;ButtonItemsPart&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; CollapsedStateName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Collapsed&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; VisibleStateName &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Visible&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Dependency Property Backers&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;readonly&lt;/span&gt;&lt;span style="color: #000000;"&gt; DependencyProperty IsCollapsedProperty &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            DependencyProperty.Register(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;IsCollapsed&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;bool&lt;/span&gt;&lt;span style="color: #000000;"&gt;), &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(SimpleMessageBox),&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyMetadata(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyChangedCallback(HandleCollapsedChanged)));&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;readonly&lt;/span&gt;&lt;span style="color: #000000;"&gt; DependencyProperty TitleProperty &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            DependencyProperty.Register(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Title&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;), &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(SimpleMessageBox),&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyMetadata(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Alert&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;));&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;readonly&lt;/span&gt;&lt;span style="color: #000000;"&gt; DependencyProperty MessageProperty &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            DependencyProperty.Register(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Message&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;), &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(SimpleMessageBox),&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyMetadata(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;You need to set a message to display, even if it is an empty string.&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;));&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;readonly&lt;/span&gt;&lt;span style="color: #000000;"&gt; DependencyProperty ButtonsProperty &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            DependencyProperty.Register(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Buttons&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;), &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;typeof&lt;/span&gt;&lt;span style="color: #000000;"&gt;(SimpleMessageBox),&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyMetadata(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;()));&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Constructors&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox()&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; DefaultStyleKeyProperty.OverrideMetadata(typeof(StatefulImage), new FrameworkPropertyMetadata(typeof(StatefulImage)));            &lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; SimpleMessageBox()&lt;br /&gt;            : &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;base&lt;/span&gt;&lt;span style="color: #000000;"&gt;()&lt;br /&gt;        {&lt;br /&gt;            DefaultStyleKey &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.GetType();&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Buttons &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;();&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (DesignerHelper.GetIsInDesignMode())&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.Buttons.Add(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;test&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; RelayCommand(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Action(() &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; { }))));&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Properties&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Gets or sets a value that indicates whether or not the message box is collapsed.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;bool&lt;/span&gt;&lt;span style="color: #000000;"&gt; IsCollapsed&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt; { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;bool&lt;/span&gt;&lt;span style="color: #000000;"&gt;)GetValue(IsCollapsedProperty); }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt; { SetValue(IsCollapsedProperty, value); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Gets or sets the title of the message box.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; Title&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt; { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;)GetValue(TitleProperty); }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt; { SetValue(TitleProperty, value); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Gets or sets the message in the message box.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt; { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;)GetValue(MessageProperty); }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt; { SetValue(MessageProperty, value); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Gets or sets a collection of the buttons on the message box.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Buttons&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt; { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; (ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;)GetValue(ButtonsProperty); }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt; { SetValue(ButtonsProperty, value); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Methods&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; HandleCollapsedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)&lt;br /&gt;        {&lt;br /&gt;            var control &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; (SimpleMessageBox)sender;            &lt;br /&gt;&lt;br /&gt;            control.UpdateStates(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Reads properties and fires off the state changer using VSM.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;param name=&amp;quot;useTransitions&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;Whether to trigger animations between the states.&lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; UpdateStates(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;bool&lt;/span&gt;&lt;span style="color: #000000;"&gt; useTransitions)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; state &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.IsCollapsed &lt;/span&gt;&lt;span style="color: #000000;"&gt;?&lt;/span&gt;&lt;span style="color: #000000;"&gt; CollapsedStateName : VisibleStateName;&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (_currentState &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; state)&lt;br /&gt;            {&lt;br /&gt;                _currentState &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; state;&lt;br /&gt;                VisualStateManager.GoToState(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;, state, useTransitions);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; page_BackKeyPress(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;object&lt;/span&gt;&lt;span style="color: #000000;"&gt; sender, System.ComponentModel.CancelEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            e.Cancel &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.IsCollapsed;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.IsCollapsed &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Control Overrides&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;override&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; OnApplyTemplate()&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;base&lt;/span&gt;&lt;span style="color: #000000;"&gt;.OnApplyTemplate();&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.UpdateStates(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;                        &lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                FrameworkElement p &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #000000;"&gt;(p &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;is&lt;/span&gt;&lt;span style="color: #000000;"&gt; PhoneApplicationPage))&lt;br /&gt;                    p &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; p.Parent &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;as&lt;/span&gt;&lt;span style="color: #000000;"&gt; FrameworkElement;&lt;br /&gt;&lt;br /&gt;                var page &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; (PhoneApplicationPage)p;&lt;br /&gt;                page.BackKeyPress &lt;/span&gt;&lt;span style="color: #000000;"&gt;+=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; EventHandler&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;System.ComponentModel.CancelEventArgs&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(page_BackKeyPress);&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;catch&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            { }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;This should be all that’s needed in the Themes\generic.xaml to set its default skin.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:21aa809e-ac48-4d55-9a64-4002dc8a5285" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 292px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ResourceDictionary&lt;br /&gt;    xmlns&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;br /&gt;    xmlns:x&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;br /&gt;    xmlns:windows&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;clr-namespace:System.Windows;assembly=System.Windows&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    xmlns:local&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;clr-namespace:YourControlNamespace;assembly=YourControlsAssembly&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    xmlns:toolkit&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    xmlns:i&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    xmlns:cmd&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    xmlns:unsupported&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;clr-namespace:Microsoft.Phone.Controls.Unsupported&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color: #000000;"&gt; Resource dictionary entries should be defined here. &lt;/span&gt;&lt;span style="color: #000000;"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Style TargetType&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;local:SimpleMessageBox&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter Property&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Background&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Value&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{StaticResource PhoneChromeBrush}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter Property&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;BorderBrush&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Value&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Transparent&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter Property&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;BorderThickness&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Value&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;0&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter Property&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Padding&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Value&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;0&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter Property&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Template&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ControlTemplate TargetType&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;local:SimpleMessageBox&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Canvas&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualStateManager.VisualStateGroups&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualStateGroup x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;VisibilityStates&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualStateGroup.Transitions&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualTransition GeneratedDuration&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;0:0:0.3&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualTransition.GeneratedEasingFunction&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;BackEase EasingMode&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;EaseOut&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualTransition.GeneratedEasingFunction&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualTransition&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualStateGroup.Transitions&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualState x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Collapsed&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;DoubleAnimation Duration&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;0&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; To&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;-90&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;(UIElement.Projection).(PlaneProjection.RotationX)&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Storyboard.TargetName&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;MessageBoard&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualState&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualState x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Visible&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualStateGroup&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;VisualStateManager.VisualStateGroups&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Grid x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;MessageBoard&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Background&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{TemplateBinding Background}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Width&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{TemplateBinding Width}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Grid.Projection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;PlaneProjection&lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Grid.Projection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;StackPanel Margin&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;15&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;TextBlock x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;TitlePart&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; FontSize&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{StaticResource PhoneFontSizeLarge}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; FontFamily&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{StaticResource PhoneFontFamilyNormal}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;br /&gt;                                    Text&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{TemplateBinding Title}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Wrap&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Margin&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;0,0,0,5&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;TextBlock x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;MessagePart&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; FontSize&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{StaticResource PhoneFontSizeMedium}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; FontFamily&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{StaticResource PhoneFontFamilyLight}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;br /&gt;                                    Text&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{TemplateBinding Message}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Wrap&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Margin&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;0,0,0,16&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsControl x:Name&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;ButtonItemsPart&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; ItemsSource&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{TemplateBinding Buttons}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Margin&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;-15,0&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsControl.ItemsPanel&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsPanelTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;toolkit:WrapPanel Orientation&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Horizontal&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Left&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsPanelTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsControl.ItemsPanel&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;Button MinWidth&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;238&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;TextBlock Text&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding Key}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;i:EventTrigger EventName&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Click&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;cmd:EventToCommand Command&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding Value}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;i:EventTrigger&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Button&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;ItemsControl&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Grid&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Canvas&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Setter&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;Style&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #000000;"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And there are two snippets here that demonstrate the control, but are otherwise not required.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ec83d88e-61a5-4be2-9ade-da79ab397792" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 338px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; In Page ViewModel ctor or some method.&lt;br /&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Tests the control by constantly transitioning.&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.MessageBox &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; MessageBoxViewModel()&lt;br /&gt;  {&lt;br /&gt;      Title &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Test run-time data&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;      Message &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;This message text is inserted in the constructor of the view model.&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;      ControlVisibility &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; Visibility.Visible,&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;  var exit &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; RelayCommand( () &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; { _t.Change(&lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;); } );&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.MessageBox.ButtonCommandPairs.Add(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, System.Windows.Input.ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;run&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;));&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.MessageBox.ButtonCommandPairs.Add(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, System.Windows.Input.ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;time&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;, exit));&lt;br /&gt;&lt;br /&gt;  _t &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Threading.Timer(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Threading.TimerCallback((state) &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      {&lt;br /&gt;          _log.Debug(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Timer&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.MessageBox.IsCollapsed)&lt;br /&gt;              Deployment.Current.Dispatcher.BeginInvoke( () &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.MessageBox.IsCollapsed &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;              Deployment.Current.Dispatcher.BeginInvoke(() &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.MessageBox.IsCollapsed &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;&lt;br /&gt;      }), &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800080;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;      &lt;br /&gt;    &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; In ViewModel somewhere:&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; MessageBoxViewModel MessageBox { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;; }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is the view model for the message box and is usually exposed as a property of the page’s view model (note above the this.MessageBox property being set).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:b636586e-7d5a-42b2-9307-2b847b6d8282" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 338px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;namespace&lt;/span&gt;&lt;span style="color: #000000;"&gt; Evoq.Vuplan.Mobile.Phone.ViewModels&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Collections.Generic;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Collections.ObjectModel;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.ComponentModel;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Windows;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; System.Windows.Input;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; MessageBoxViewModel : INotifyPropertyChanged&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Fields&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Events and OnMethods&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;event&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyChangedEventHandler PropertyChanged;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; NotifyPropertyChanged(String propertyName)&lt;br /&gt;        {&lt;br /&gt;            PropertyChangedEventHandler handler &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyChanged;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; handler)&lt;br /&gt;            {&lt;br /&gt;                handler(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; PropertyChangedEventArgs(propertyName));&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Constructors&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; MessageBoxViewModel()&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.ButtonCommandPairs &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#region&lt;/span&gt;&lt;span style="color: #000000;"&gt; Properties&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; _title;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Sample ViewModel property; this property is used in the view to display its value using a Binding.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; Title&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; _title;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (value &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _title)&lt;br /&gt;                {&lt;br /&gt;                    _title &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; value;&lt;br /&gt;                    NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Title&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; _message;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Sample ViewModel property; this property is used in the view to display its value using a Binding.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; _message;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (value &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _message)&lt;br /&gt;                {&lt;br /&gt;                    _message &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; value;&lt;br /&gt;                    NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;Message&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;bool&lt;/span&gt;&lt;span style="color: #000000;"&gt; _isCollapsed;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Sample ViewModel property; this property is used in the view to display its value using a Binding.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;bool&lt;/span&gt;&lt;span style="color: #000000;"&gt; IsCollapsed&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; _isCollapsed;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (value &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _isCollapsed)&lt;br /&gt;                {&lt;br /&gt;                    _isCollapsed &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; value;&lt;br /&gt;                    NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;IsCollapsed&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; Visibility _controlVisibility;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; Sample ViewModel property; this property is used in the view to display its value using a Binding.&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #808080;"&gt;///&lt;/span&gt;&lt;span style="color: #008000;"&gt; &lt;/span&gt;&lt;span style="color: #808080;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;span style="color: #808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; Visibility ControlVisibility&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; _controlVisibility;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (value &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _controlVisibility)&lt;br /&gt;                {&lt;br /&gt;                    _controlVisibility &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; value;&lt;br /&gt;                    NotifyPropertyChanged(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;ControlVisibility&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; ObservableCollection&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;KeyValuePair&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;string&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ICommand&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; ButtonCommandPairs { &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;get&lt;/span&gt;&lt;span style="color: #000000;"&gt;; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;private&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;set&lt;/span&gt;&lt;span style="color: #000000;"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;#endregion&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This lump of XAML shows how to declare the control on a page. The thing which is important here is to use TwoWay binding because the SimpleMessageBox control itself can change the IsCollapsed property internally when handling the back button key.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:48a4d4c3-c9af-4a36-bee7-a021f42b962e" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 623px; height: 118px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;controllib:SimpleMessageBox DataContext&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding MessageBox}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;br /&gt;      Title&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding Title}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; Message&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding Message}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      Buttons&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding ButtonCommandPairs}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      Width&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding ElementName=LayoutRoot, Path=ActualWidth}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      IsCollapsed&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;{Binding IsCollapsed, Mode=TwoWay}&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Merry Christmas!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-8182962907526318412?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/8182962907526318412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/12/worlds-best-messagebox-control-it-maybe.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8182962907526318412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8182962907526318412'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/12/worlds-best-messagebox-control-it-maybe.html' title='The World’s Best MessageBox Control (it maybe just a bog standard message box control to you but I like it)'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-2863334396384831919</id><published>2010-11-21T04:55:00.001-08:00</published><updated>2010-11-21T04:55:35.741-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Helpful docs when hardening an IIS web server</title><content type='html'>&lt;p&gt;While clearing up some crap on my desktop I came across a note listing some documents I’d used when preparing my web server for co-location and exposure to the harshness of the public internet.&lt;/p&gt;  &lt;p&gt;How To: Harden the TCP/IP Stack   &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff648853.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff648853.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;TCP Receive Window Size and Window Scaling   &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms819736.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms819736.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;How To: Protect Forms Authentication in ASP.NET 2.0   &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff648341.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff648341.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;How To: Perform a Security Deployment Review for ASP.NET 2.0   &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff647403.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff647403.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;How To: Use IPSec for Filtering Ports and Authentication   &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff648481.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff648481.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;How To: Use IISLockdown.exe   &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff650415.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff650415.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-2863334396384831919?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/2863334396384831919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/11/helpful-docs-when-hardening-iis-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2863334396384831919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2863334396384831919'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/11/helpful-docs-when-hardening-iis-web.html' title='Helpful docs when hardening an IIS web server'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-5109064422585126717</id><published>2010-11-15T08:01:00.001-08:00</published><updated>2010-11-15T08:01:34.462-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windowsphone'/><category scheme='http://www.blogger.com/atom/ns#' term='silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Detecting Windows Phone Screen Size</title><content type='html'>&lt;p&gt;Eventually, and probably not long from now, the Windows Phone will have a form factor that isn’t 480 x 800 so here’s how to detect the screen size:&lt;/p&gt;  &lt;pre&gt;protected PhoneViewModel()&lt;br /&gt;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; this.ScreenWidth = System.Windows.Application.Current.Host.Content.ActualWidth;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; this.ScreenHeight = System.Windows.Application.Current.Host.Content.ActualHeight;&lt;br /&gt;}&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-5109064422585126717?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/5109064422585126717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/11/detecting-windows-phone-screen-size.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5109064422585126717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5109064422585126717'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/11/detecting-windows-phone-screen-size.html' title='Detecting Windows Phone Screen Size'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-1972824926357579177</id><published>2010-11-05T09:32:00.001-07:00</published><updated>2010-11-05T09:32:32.746-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><title type='text'>The (dis)appearance of ‘Spaghetti Code’ in ASPX views</title><content type='html'>&lt;p&gt;&lt;strong&gt;Offended by the proliferation of vulgar &lt;/strong&gt;&lt;font style="background-color: #ffff00"&gt;&amp;lt;%&lt;/font&gt;&lt;font style="background-color: #ffff00"&gt;&lt;/font&gt;&lt;strong&gt;&lt;font style="style"&gt; throughout my view mark-up, and with no luck/patience getting Razor working, I decided that the poor man’s version would be to tone-down those ugly little marks. The result was quite amazing.&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_nweCidX3nlI/TNQxnAkDWrI/AAAAAAAAAF4/Lg3UIv9UZ1Q/s1600-h/Capture%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Capture" border="0" alt="Capture" src="http://lh6.ggpht.com/_nweCidX3nlI/TNQxnxUyOVI/AAAAAAAAAF8/JFA92A7aD5s/Capture_thumb%5B1%5D.png?imgmax=800" width="565" height="336" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;The tags denoting server-side code no longer wrestle for attention and send my eyes spinning. I almost didn’t post this but I’d wager that most people out there would blame the hard readability on the way ASP.NET MVC works and not the poor choice of colour in the default settings.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-1972824926357579177?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/1972824926357579177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/11/disappearance-of-spaghetti-code-in-aspx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1972824926357579177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1972824926357579177'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/11/disappearance-of-spaghetti-code-in-aspx.html' title='The (dis)appearance of ‘Spaghetti Code’ in ASPX views'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nweCidX3nlI/TNQxnxUyOVI/AAAAAAAAAF8/JFA92A7aD5s/s72-c/Capture_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7650603477771414246</id><published>2010-10-31T16:49:00.001-07:00</published><updated>2010-10-31T16:49:40.792-07:00</updated><title type='text'>My Gestural ScrollViewer in vuPlan.tv Client</title><content type='html'>&lt;iframe height="1220" src="http://player.vimeo.com/video/15782239" frameborder="0" width="636"&gt;&lt;/iframe&gt;  &lt;p&gt;&lt;a href="http://vimeo.com/15782239"&gt;vuPlan.tv Client Gestural UI - WPF&lt;/a&gt; from &lt;a href="http://vimeo.com/user4951144"&gt;Luke Puplett&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Pretty huge, I know, I know. I don’t even think Vimeo scales it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7650603477771414246?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7650603477771414246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/10/my-gestural-scrollviewer-in-vuplantv.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7650603477771414246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7650603477771414246'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/10/my-gestural-scrollviewer-in-vuplantv.html' title='My Gestural ScrollViewer in vuPlan.tv Client'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-2193506242155456441</id><published>2010-10-28T05:04:00.001-07:00</published><updated>2010-10-28T05:07:30.364-07:00</updated><title type='text'>Windows Phone 7, Windows 8 and Not-Desking</title><content type='html'>&lt;p&gt;&lt;strong&gt;Smug. That’s how early iPhone users felt they up went home, or into work, with their shiny world-in-a-box gadgets. And this is how I feel as the new owner of a Samsung Omnia Windows Phone 7 device.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;My first impression is that it is at least twice as good to look at and hold than I expected, and superior in feel than the aforementioned revolutionary. Or maybe its the novelty of change.&lt;/p&gt;  &lt;p&gt;I won’t bore you and myself with a guide around it but I wanted to write about the thoughts it provoked within a few moments of using this new phone from Ford. I mean, Microsoft.&lt;/p&gt;  &lt;p&gt;It makes you wonder what Windows desktop could be if it were rebuilt from the ground-up with selected hardware partners. Their desktop OS hasn’t changed much since I was a Windows support guy for them in 1997. Actually, the file system goes back to 1993.&lt;/p&gt;  &lt;p&gt;Then there’s the registry from Windows 3.1. Oh and don’t forget the whole network OS; slow roaming profiles, domains, NetBIOS and the rest. Maybe it’s just me but I’ve become quite contemptuous of Redmond’s laziness when I logon in the morning.&lt;/p&gt;  &lt;p&gt;I started my career on the frontline for Microsoft just after passing my driving test, but while I’m going grey and groaning when I ease down into my chair, Windows is still the bloody same. &lt;/p&gt;  &lt;p&gt;Worryingly, I’ve invented a theory on why the Windows we’ve always known may just be the only Windows we ever get. Here’s why.&lt;/p&gt;  &lt;p&gt;The ball around Microsoft’s ankle is its success. It has a generation of compatibility to nurse. With all it’s customers riding on its back, it must turn slowly to ensure a comfy ride. Their turning circle is perhaps wider than the twisty-changey road of technology. What to do?&lt;/p&gt;  &lt;p&gt;One strategy would be to build Windows 10 with no legacy support, a .NET Framework CLR and Microsoft’s own apps, then allow people to migrate in their own time, which is effectively how Windows 95 became NT 4.0 became Windows XP.&lt;/p&gt;  &lt;p&gt;This would be costly in the sense that they’d be supporting two Windows lines but keeping everyone happy. The Ford Galaxy and the Ford Focus RS.&lt;/p&gt;  &lt;p&gt;Or I wonder if the desktop will actually be left to fester as the world of devices takes over and desktop computing becomes a niche in a liberated new world where workers don’t just hot-desk, but not-desk.&lt;/p&gt;  &lt;p&gt;To make the Focus RS, is it worth the significant financial investment, upheaval and disruption to their massive customer base at a time when their future is so uncertain? Uncertain because of the interesting situation they’ve woken up to find themselves in.&lt;/p&gt;  &lt;p&gt;Technological innovation has the biggest impact on human behavioural trends, and while Microsoft were scrimping on their mobile platform, also just an old codebase with a coat of paint, their ability to control and pre-empt future trends was also lost.&lt;/p&gt;  &lt;p&gt;Windows may have won out in the desktop era but they’re arguably just starting out, behind not one but two other companies, in the next era of computing.&lt;/p&gt;  &lt;p&gt;So Microsoft is in the unfamiliar position of having to take an, albeit very experienced, guess on how people will go about their lives and business in the coming couple of decades.&lt;/p&gt;  &lt;p&gt;Interesting times.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-2193506242155456441?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/2193506242155456441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/10/windows-phone-7-windows-8-and-not.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2193506242155456441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2193506242155456441'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/10/windows-phone-7-windows-8-and-not.html' title='Windows Phone 7, Windows 8 and Not-Desking'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-3460299997891153428</id><published>2010-10-12T03:29:00.001-07:00</published><updated>2010-10-12T03:40:12.006-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Note to Self: Covariance and Contravariance in a Nutshell</title><content type='html'>&lt;p&gt;On Channel9, the academic interviews are very stimulating but they tend to confuse a simple concept in theoretical mumbo-jumbo.&lt;/p&gt;  &lt;p&gt;Covariance is the ability to upcast a collection of types to a collection of more primitive classes.&lt;/p&gt;  &lt;p&gt;Sorry about the small font, some crappy CSS somewhere.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;IEnumerable&amp;lt;Truck&amp;gt;&lt;truck&gt; trucks = TruckRepository.Trucks.Where(t =&amp;gt; t.Color == Red);&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;IEnumerable&amp;lt;Vehicle&amp;gt; &lt;vehicle&gt;vehicles = trucks as IEnumerable&amp;lt;Vehicle&amp;gt;&lt;vehicle&gt;;&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;But it only works with IEnumerable&amp;lt;T&amp;gt; because the collection is read-only. If it didn’t have this constraint, then we’d be able to do this to a List and then add a Car, and that’d be bad because its still really a collection of Truck.&lt;/p&gt;  &lt;p&gt;Contravariance is obviously the opposite, when things go in (and so less to do with collections), the type can be cast to be more specific (say, Action&amp;lt;Vehicle&amp;gt; to Action&amp;lt;Truck&amp;gt; and it will happily accept a Truck because its a vehicle.&lt;/p&gt;  &lt;p&gt;Func&amp;lt;T, TResult&amp;gt; is more interesting because its got generic T in and TResult out types. This means that the T is contravariant on the way in and the TResult is covariant as it comes out.&lt;/p&gt;  &lt;p&gt;Variance doesn’t come automatically.&lt;/p&gt;  &lt;p&gt;Should you wish to allow covariance, the T must be marked with the out keyword; &lt;strong&gt;out T&lt;/strong&gt;. And obviously &lt;strong&gt;in T &lt;/strong&gt;defines and contravariant generic type param. You can’t put out T on an interface method because it method params are implicitly inbound.&lt;/p&gt;  &lt;p&gt;Co out. Contra in.&lt;/p&gt;  &lt;p&gt;Microsoft have added out and in to a whole bunch of interfaces and delegates which is why it appears to come automatically with .NET 4.0.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd799517.aspx"&gt;http://msdn.microsoft.com/en-us/library/dd799517.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Restrictions (from MSDN):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;In the .NET Framework version 4, variant type parameters are restricted to generic interface and generic delegate types.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;A generic interface or generic delegate type can have both covariant and contravariant type parameters.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Variance applies only to reference types; if you specify a value type for a variant type parameter, that type parameter is invariant for the resulting constructed type.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Variance does not apply to delegate combination. That is, given two delegates of types Action&amp;lt;Derived&amp;gt; andAction&amp;lt;Base&amp;gt; (Action(Of Derived) and Action(Of Base) in Visual Basic), you cannot combine the second delegate with the first although the result would be type safe. Variance allows the second delegate to be assigned to a variable of typeAction&amp;lt;Derived&amp;gt;, but delegates can combine only if their types match exactly.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-3460299997891153428?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/3460299997891153428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/10/note-to-self-covariance-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3460299997891153428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3460299997891153428'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/10/note-to-self-covariance-and.html' title='Note to Self: Covariance and Contravariance in a Nutshell'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-676921166172924705</id><published>2010-10-09T06:04:00.001-07:00</published><updated>2010-10-09T06:04:15.836-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrency'/><title type='text'>Task Parallel Library Cheat Sheet</title><content type='html'>&lt;p&gt;While I’d followed Mr Toub and his gang while they were making the TPL, I’ve since slept and forgotten it all. So I can always consider a concurrent approach to my classes, I thought I’d make a very simple overview ‘cheat sheet’ and stick it to the wall.&lt;/p&gt;  &lt;p&gt;Get it &lt;a href="http://cid-db71be93ce07377a.office.live.com/self.aspx/.Public/TPL%20Cheat%20Sheet%20v1.pdf"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-676921166172924705?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/676921166172924705/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/10/task-parallel-library-cheat-sheet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/676921166172924705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/676921166172924705'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/10/task-parallel-library-cheat-sheet.html' title='Task Parallel Library Cheat Sheet'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-2009849208038968579</id><published>2010-10-07T06:49:00.001-07:00</published><updated>2010-10-07T06:49:27.677-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='vuplan'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Recent Changes to vuPlan.tv Client</title><content type='html'>&lt;p&gt;Since writing vuPlan.tv I’ve been using a placeholder company name ‘S26’ which I had to refactor to reflect my final company name Evoq Limited. The new codebase is built with new filenames and namespaces.&lt;/p&gt;  &lt;p&gt;Also, the Windows 7 implementation of the Media Center API, at the COM interop level, has a memory leak. The new client works around the problem by creating an API shim inside a new AppDomain which gets recycled at intervals.&lt;/p&gt;  &lt;p&gt;Finally, after seeing Mike Taulty’s session at UK Tech Days and his showing-off of new Metro-esque Windows 7 WPF applications Zune and MetroTwit, I reverted the vuPlan.tv client back into its Metro pyjamas. Previously I’d not done enough work on the shadow which is why it never really rocked my world; this version is much better I think.&lt;/p&gt; &lt;a title="vuPlan.tv Funkier Metro Look by lukepuplett, on Flickr" href="http://www.flickr.com/photos/22787790@N06/5059942058/"&gt;&lt;img alt="vuPlan.tv Funkier Metro Look" src="http://farm5.static.flickr.com/4103/5059942058_3406dce174.jpg" width="246" height="500" /&gt;&lt;/a&gt;   &lt;p&gt;Testing is on-going as it work on the web application/site. And that reminds me, I must update the images on the site.&lt;/p&gt;  &lt;p&gt;Luke&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-2009849208038968579?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/2009849208038968579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/10/recent-changes-to-vuplantv-client.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2009849208038968579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2009849208038968579'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/10/recent-changes-to-vuplantv-client.html' title='Recent Changes to vuPlan.tv Client'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm5.static.flickr.com/4103/5059942058_3406dce174_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-4396424198333501437</id><published>2010-09-24T03:27:00.001-07:00</published><updated>2010-09-24T03:27:45.671-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Refactoring a Company Name Change</title><content type='html'>&lt;p&gt;&lt;strong&gt;When I began writing my app, my company name was a legacy to my IT consulting business, which was bought ‘off the peg’ as a semi-preformed company in 2001. Today my needs have changed and so close to release I needed to refactor over 80,000 lines of C# and all the XML stuff in-between with my new company name.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Today, my company name will be more visible and so I renamed the business to Evoq Limited. I had the foresight to use a codename, S26, as the root of my namespaces just in case refactoring would be an impossible job later; I wouldn’t have to look at the old company name forever.&lt;/p&gt;  &lt;h4&gt;As the Crow Flies&lt;/h4&gt;  &lt;p&gt;My theory was that all files are text files and so taking the direct route of doing a massive find and replace could work, as long as I covered all bases. It turns out that covering bases meant remembering to rename folders and files, too.&lt;/p&gt;  &lt;p&gt;Here’s how I did it:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;I first made sure all project code, i.e. all project folders, sat under a single folder on my local disk, Documents\Code for example. &lt;/li&gt;    &lt;li&gt;In DOS I created a list of all folders: dir /ad/s/b | find /i “S26.Vuplan” &amp;gt; folders.txt &lt;/li&gt;    &lt;li&gt;I then opened this in Excel and created a rename script. Instead of writing a batch file, I’ve often found hundreds of repeating similar commands are easier to put together in Excel. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_nweCidX3nlI/TJx9FutT0sI/AAAAAAAAAFo/BomtQXj1uf0/s1600-h/Excel%20Script%20Build%20-%20Folders%5B10%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Excel Script Build - Folders" border="0" alt="Excel Script Build - Folders" src="http://lh5.ggpht.com/_nweCidX3nlI/TJx9GY-veEI/AAAAAAAAAFs/DYooBvEFWI0/Excel%20Script%20Build%20-%20Folders_thumb%5B6%5D.png?imgmax=800" width="633" height="144" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.flickr.com/photos/22787790@N06/5019533413/in/photostream/"&gt;Version on Flickr&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Essentially, the Excel sheet looks for the position of the old text, S26.Vuplan, within the path.&lt;/li&gt;    &lt;li&gt;It then has another column which tries to find the position of a \ backslash after the position of the old text.&lt;/li&gt;    &lt;li&gt;This basically tells you whether the row represents the top level folder – we can skip this but there’ll be a lot of wasted renames of subfolders from and to the same name.&lt;/li&gt;    &lt;li&gt;It then uses the SUBSTITUTE cell function to replace the old text with the new.&lt;/li&gt;    &lt;li&gt;Then I use MID and the string position to extract just the folder name – this is because the DOS rename command wants a full folder path as argument 1 and just the renamed folder name as argument 2.&lt;/li&gt;    &lt;li&gt;Finally, I build the DOS command by concatenating strings in the final column.&lt;/li&gt;    &lt;li&gt;I then copy and paste the selected commands/cells into DOS which has the effect of submitting each cell value as a new DOS command.&lt;/li&gt;    &lt;li&gt;After doing the folders, create a list of all the files that need renaming in a similar wat to above, Dir /s/a/b | find /i “S26.Vuplan” &amp;gt; files.txt&lt;/li&gt;    &lt;li&gt;The above is repeated, except for finding top level folders.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/TJx9HXQdwoI/AAAAAAAAAFw/nuWtAHoiS0E/s1600-h/Excel%20Script%20Build%20-%20Files%5B5%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Excel Script Build - Files" border="0" alt="Excel Script Build - Files" src="http://lh4.ggpht.com/_nweCidX3nlI/TJx9IPfPztI/AAAAAAAAAF0/Y1J8Yd5II0g/Excel%20Script%20Build%20-%20Files_thumb%5B3%5D.png?imgmax=800" width="635" height="134" /&gt;&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;&lt;a href="http://www.flickr.com/photos/22787790@N06/5020140370/in/photostream/"&gt;Version on Flickr&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Copy and past the command cells into DOS as before.&lt;/li&gt;    &lt;li&gt;Now enter each project folder and delete the bin and obj directories. This is to stop compilation errors due to using cached compiled assemblies with old stuff in them.&lt;/li&gt;    &lt;li&gt;Open Visual Studio but don’t open a project.&lt;/li&gt;    &lt;li&gt;Perform a Replace in Files on the code folder tree (do not choose to keep modded files open, else VS grinds to a halt under the impact of 100s of open files).&lt;/li&gt;    &lt;li&gt;My rename did &amp;gt;13,000 replacements (S26.Vuplan &amp;gt; Evoq.Vuplan).&lt;/li&gt;    &lt;li&gt;Now open your projects in reverse build order and makes sure they compile.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I experienced only minor problems, mostly because I didn’t delete the bin and obj folders until I realised what was happening. Once I sorted that, my ASP and WCF solutions all compiled right away! I was quite amazed.&lt;/p&gt;  &lt;p&gt;(remember to make a backup or nine)&lt;/p&gt;  &lt;p&gt;Luke&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-4396424198333501437?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/4396424198333501437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/09/refactoring-company-name-change.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4396424198333501437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4396424198333501437'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/09/refactoring-company-name-change.html' title='Refactoring a Company Name Change'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_nweCidX3nlI/TJx9GY-veEI/AAAAAAAAAFs/DYooBvEFWI0/s72-c/Excel%20Script%20Build%20-%20Folders_thumb%5B6%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7459841647315725905</id><published>2010-09-05T13:55:00.001-07:00</published><updated>2010-09-05T14:09:53.059-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>ASP.NET MVC Robust HyperLinks</title><content type='html'>&lt;p&gt;&lt;strong&gt;Motivated by ActionLink failing to produce proper MVC-style / / / links and, although RouteLink does work, I think route names and possibly all route logic should be kept out of the view, I decided to bake my own link maker, and make the links in the controller and put them in the model. Here’s how I did that.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I have a BaseSiteNameController in which helper methods go. To this, I added the following method:&lt;/p&gt;  &lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;string&lt;/span&gt; BuildLink(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; RequestContext requestContext,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; routeName,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; action,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; controller,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;object&lt;/span&gt; routeValues)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; UrlHelper u = &lt;span style="color: blue"&gt;new&lt;/span&gt; UrlHelper(requestContext);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var rvd = &lt;span style="color: blue"&gt;new&lt;/span&gt; RouteValueDictionary(routeValues);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; rvd.Add(&lt;span style="color: maroon"&gt;&amp;quot;controller&amp;quot;&lt;/span&gt;, controller);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; rvd.Add(&lt;span style="color: maroon"&gt;&amp;quot;action&amp;quot;&lt;/span&gt;, action);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var httpContext = System.Web.HttpContext.Current;     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; UrlHelper.GenerateUrl(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; routeName, &lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;null&lt;/span&gt;,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; httpContext.Request.Url.Scheme,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; httpContext.Request.Url.DnsSafeHost,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;null&lt;/span&gt;, rvd, u.RouteCollection,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; requestContext, &lt;span style="color: maroon"&gt;true&lt;/span&gt;);     &lt;br /&gt;}&lt;/div&gt;  &lt;p&gt;Note that I specify controller and action in the RouteValueDictionary even though GenerateUrl has parameters for controller and action. When these are used, it kicks out old-skool URLs – I think these params were designed to be used when a route name is not supplied. The GenerateUrl method smells like it wasn’t designed for general direct use.&lt;/p&gt;  &lt;p&gt;GenerateUrl is the thing that does the magic; it looks up the route and works out how the URL should be structured.&lt;/p&gt;  &lt;p&gt;It’s a static method because I also want to be able to call it from my models. Some of my models have sub-models and some of those have links. I figured that a View is for layout, and links kind of straddle both sides but the logic required to make them, tips them into the non-view side, in my opinion.&lt;/p&gt;  &lt;p&gt;My models aren’t always created and prepared by my controllers. Some of my models contain a small amount of logic to populate themselves, so I want them to be able to call this method* when they populate their links (e.g. FavouriteBooksModel.AddBookLink)&lt;/p&gt;  &lt;p&gt;Note also that the method takes a RequestContext. I now have to have this context available in my models, so I pass it down using a CustomerWebProfile class that I already use to flow important data into my models, such as TimeZone data. Each model has a CustomerWebProfile property (inherited via a base model).&lt;/p&gt;  &lt;p&gt;*Except that my models don’t directly call BuildLink because I wrap these calls helper methods.&lt;/p&gt;  &lt;p&gt;Under each action method, I add a method to build a link to the method. I do this because I can prevent the caller from having to know the action name, and so I can refactor it easily.&lt;/p&gt;  &lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;string&lt;/span&gt; BuildLinkToCustomerAccount(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; System.Web.Routing.RequestContext requestContext, &lt;span style="color: blue"&gt;string&lt;/span&gt; customerId)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; BuildLink(requestContext, &lt;span style="color: maroon"&gt;&amp;quot;Default&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;CustomerAccount&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;Account&amp;quot;&lt;/span&gt;,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;new&lt;/span&gt; { data = customerId });     &lt;br /&gt;}&lt;/div&gt;  &lt;p&gt;Now my models use these helper methods to make their links (code in model).&lt;/p&gt;  &lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;string&lt;/span&gt; CustomerAccountLink     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; Controllers.PlannerController.BuildLinkToRecordOneTime(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.WebProfile.RequestContext, &lt;span style="color: blue"&gt;this&lt;/span&gt;.TransmissionKeys);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;}&lt;/div&gt;  &lt;p&gt;If I change my controllers or actions, I can change the helper method, and renames can be done without worrying about strings in aspx pages!&lt;/p&gt;  &lt;p&gt;My views now make links in the normal way, like this:&lt;/p&gt;  &lt;pre&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;a &lt;span style="color: red"&gt;href&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;%:&lt;/span&gt; Model.CustomerAccountLink %&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;%:&lt;/span&gt; Html.GetLocalString(&amp;quot;&lt;span style="color: blue"&gt;Your Account&lt;/span&gt;&amp;quot;) %&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;a&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And if I change the model, my page won’t compile and I can sort them out before runtime.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7459841647315725905?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7459841647315725905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/09/aspnet-mvc-robust-hyperlinks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7459841647315725905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7459841647315725905'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/09/aspnet-mvc-robust-hyperlinks.html' title='ASP.NET MVC Robust HyperLinks'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-5196001070866385928</id><published>2010-08-30T15:43:00.001-07:00</published><updated>2010-08-30T15:43:10.274-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Finding a MemoryLeak in 30 sec [WinDbg]</title><content type='html'>&lt;p&gt;&lt;strong&gt;Supplementary to my last post on WinDbg, here’s how I found a memory leak (600Mb working set for a background app anyone?) in under a minute.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The only instructions are: create a dump of your process using Task Manager, then drag and drop it into WinDbg. Load SOS and then issue the commands in bold in the following screen dump.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_nweCidX3nlI/THwz-mCHZGI/AAAAAAAAAFg/-n2P-lFvTnA/s1600-h/WinDbg%5B5%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="WinDbg" border="0" alt="WinDbg" src="http://lh4.ggpht.com/_nweCidX3nlI/THwz_U5qUII/AAAAAAAAAFk/gB59xO8byZc/WinDbg_thumb%5B3%5D.jpg?imgmax=800" width="631" height="874" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So, –dumpheap stat gives all objects and the memory they’re hogging. Strings and Ints are always the most so ignore them and focus on the next largest ‘real’ object.&lt;/p&gt;  &lt;p&gt;For me, a generic Dictionary is hoarding over 100Mb. I then use !dumpheap –mt {address} to dump out the method table for this dodgy type.&lt;/p&gt;  &lt;p&gt;This spits out addresses for each object. Then I just pick a random one and use !gcroot to see which object is holding the reference open.&lt;/p&gt;  &lt;p&gt;The entire chain of references is shown, and RecorderScheduler is right at the bottom. I look at this in my code and find I have a Dictionary of “bad items” which is holding references to the Microsoft Windows Media Center API, which has a memory leak – i.e. my code is fine but the MS API is apparently not designed to have objects held open for days.&lt;/p&gt;  &lt;p&gt;Luke&lt;/p&gt;  &lt;p&gt;P.S. Another thing I noticed was how easy it is to see the value of a string, and thus how bad it is to store passwords in plaintext.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-5196001070866385928?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/5196001070866385928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/08/finding-memoryleak-in-30-sec-windbg.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5196001070866385928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5196001070866385928'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/08/finding-memoryleak-in-30-sec-windbg.html' title='Finding a MemoryLeak in 30 sec [WinDbg]'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_nweCidX3nlI/THwz_U5qUII/AAAAAAAAAFk/gB59xO8byZc/s72-c/WinDbg_thumb%5B3%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-2774907345133845405</id><published>2010-08-19T11:50:00.001-07:00</published><updated>2010-08-19T11:50:05.359-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>ASP.NET MVC 2 RedirectToSignin</title><content type='html'>&lt;p&gt;&lt;strong&gt;If, for whatever reason, you cannot use the [Authorize] attribute on an action method, or as in my case, you have an unusual architecture, then this helpful method directs a visitor back to the sign-in or login screen and then re-runs the original action. It’s designed to work exactly as the AuthorizeAttribute works, but with the difference that you can do your own IsAuthorised logic within the method.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;An application I’m working on has a WCF service which is where customers are logged-in. The MVC application simply packages up the web front end and ships all requests, CRUD ops, everything into service calls and then paints the results out via ASP.NET/HTML.&lt;/p&gt;  &lt;p&gt;When a customer logs in to my MVC 2 app, it’s really just calling Login on the WCF Authentication Service – the MVC app doesn’t keep track of sessions and is truly stateless. The MVC app does, however, use forms authentication and so the cookie can say “yep, customer is signed-in” while the WCF service says, “Uh uh. This customer’s session expired.”&lt;/p&gt;  &lt;p&gt;This means that my action methods with [Authorize] run, but then fail. I wrote this method to redirect the customer to the sign-in box, and then continue to execute the original action, using the returnUrl.&lt;/p&gt;  &lt;p&gt;Code:&lt;/p&gt;  &lt;div style="font-family: courier new"&gt;   &lt;br /&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt; ActionResult RedirectToSignin(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; returnAction,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; returnController,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;object&lt;/span&gt; returnRouteValues,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; RequestContext requestContext)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; UrlHelper u = &lt;span style="color: blue"&gt;new&lt;/span&gt; UrlHelper(requestContext);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; returnUrl = UrlHelper.GenerateUrl(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;null&lt;/span&gt;, returnAction, returnController, &lt;span style="color: blue"&gt;new&lt;/span&gt; RouteValueDictionary(returnRouteValues),     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; u.RouteCollection, requestContext, &lt;span style="color: maroon"&gt;true&lt;/span&gt;);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; baseAddress = String.Format(&lt;span style="color: maroon"&gt;&amp;quot;{0}://{1}&amp;quot;&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; HttpContext.Request.Url.Scheme, HttpContext.Request.Url.Authority);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; Redirect(String.Format(&lt;span style="color: maroon"&gt;&amp;quot;{0}/Customer/Signin?returnUrl={1}&amp;quot;&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; baseAddress, returnUrl));     &lt;br /&gt;}&lt;/div&gt;  &lt;p&gt;Now within my action method, if I get a null or a fault from my service, I &lt;em&gt;return &lt;/em&gt;RedirectToSignin(xyz) instead of returning an error. After sign-in, the action is called again and all is good in the hood.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-2774907345133845405?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/2774907345133845405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/08/aspnet-mvc-2-redirecttosignin.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2774907345133845405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2774907345133845405'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/08/aspnet-mvc-2-redirecttosignin.html' title='ASP.NET MVC 2 RedirectToSignin'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-9082588135371488188</id><published>2010-08-17T06:46:00.001-07:00</published><updated>2010-08-17T06:46:34.637-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>The Shame of CSS (or HTML)</title><content type='html'>&lt;p&gt;&lt;strong&gt;Is the web built on the heroic patience of thousands of creative geniuses, or by a bunch of morons? This is what I'm left wondering after a second go at HTML and CSS.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As a programmer working in programming languages, I'm used to being a dictator of determinism.&lt;/p&gt;  &lt;p&gt;That is to say that, what I instruct the computer to do, happens exactly as I dictate. I run the whole show. This affords me as much power as it does responsibility. If I get those instructions wrong, my programme will not compile. If my code runs, it is computationally perfect even if there are logical bugs. My world is mathematically beautiful.&lt;/p&gt;  &lt;p&gt;Due to a problem with my web designer deciding to ignore me, I thought I could knock up a very simple two-column, header, content, footer type web-page in no time. I was wrong and the memories of why I hired a web dude in the first place, came flooding back.&lt;/p&gt;  &lt;p&gt;For years now I've been reading the UK’s most popular web designer/developer rag .NET Magazine (nothing to do with &lt;em&gt;that&lt;/em&gt; .NET, the irony being that the editor almost completely eschews .NET), and not once has the magazine cared to tell me that HTML is utter garbage.&lt;/p&gt;  &lt;p&gt;Born out of SGML and XML, HTML differs in that its tags don't need to be closed. From its inception, HTML immediately repudiated it's first opportunity to work properly.&lt;/p&gt;  &lt;p&gt;Although, to be honest, I'm not entirely sure whether it's not CSS that's to blame, since I don't know where HTML ends and CSS begins.&lt;/p&gt;  &lt;p&gt;If CSS does the layout then CSS is to blame. I would take back my previous comment about HTML but like a couple of naughty children, they're both at fault even if the other one did it.&lt;/p&gt;  &lt;p&gt;In retrospect, I see now that there were some clunking great CSS warning clues:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;After 15 years of mainstream web content creation, no one has made a decent WYSIWYG designer.&lt;/li&gt;    &lt;li&gt;CSS is often referred to as being &amp;quot;hand crafted&amp;quot; (in the way that chiselling wood is semi-random).&lt;/li&gt;    &lt;li&gt;&amp;quot;Hacks&amp;quot; are the everyday vernacular of a web designer.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The simplest tasks are nigh on impossible. Like centering. Particularly centering some content in relation to some other thing to the side of it.&lt;/p&gt;  &lt;p&gt;Moving something without nudging something else somewhere else you didn't want it or bringing some other thing along for the ride.&lt;/p&gt;  &lt;p&gt;Grids. You used to be able to use Tables which worked really nicely but Health &amp;amp; Safety came along and told everyone that they must use a combination of DIVs and strong painkillers.&lt;/p&gt;  &lt;p&gt;And fonts are out.&lt;/p&gt;  &lt;p&gt;Please stare in amazement at this very simple attempt to put a logo in the corner of a page with a band of grey going along to top.&lt;/p&gt; &lt;a href="http://lh6.ggpht.com/_nweCidX3nlI/TGqSrhyVyQI/AAAAAAAAAFA/3pQ3ypm8s9M/s1600-h/Designer%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Designer" border="0" alt="Designer" src="http://lh6.ggpht.com/_nweCidX3nlI/TGqSsi-Z_bI/AAAAAAAAAFE/XVpTHcGM-nk/Designer_thumb%5B1%5D.jpg?imgmax=800" width="621" height="413" /&gt;&lt;/a&gt;   &lt;p&gt;Looks alright doesn't it? I mean, the logo doesn’t have it’s alpha background but that’ll be alright in the real browser.&lt;/p&gt;  &lt;p&gt;Here’s how to make this amazing page. You'd think to just put a logo image in the corner and make it a link. You can’t just make something a link, of course, so instead the HTML and CSS instructions say: stick a hyperlink in the corner and then set its background picture so it looks like a logo but have no link text and then fuck around a bit to make the link the same size as the background image and then add some margin. Also use someone else's 960 Grid System thing to shortcut the almost impossible process of aligning stuff.&lt;/p&gt;  &lt;p&gt;As you go about &amp;quot;crafting&amp;quot; the page, the designer will show you what you want to see because it doesn't like it when you're mad, but really all your hard work looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/TGqSsz_5CFI/AAAAAAAAAFI/bUgVXggnUJk/s1600-h/IE8%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IE8" border="0" alt="IE8" src="http://lh4.ggpht.com/_nweCidX3nlI/TGqStZNwbyI/AAAAAAAAAFM/O7sVjvaqxEY/IE8_thumb%5B1%5D.jpg?imgmax=800" width="457" height="306" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Quite how Internet Explorer 8.0 - the same people that wrote the designer and Microsoft's best attempt to make a working web browser - manages to screw this one up so spectacularly is a mystery. Overlapping images? WTF?!&lt;/p&gt;  &lt;p&gt;Okay, Firefox is the web developer's favourite PC browser, let's see what it looks like properly rendered.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_nweCidX3nlI/TGqSt1ssM6I/AAAAAAAAAFQ/JX4FtAFXF3M/s1600-h/Firefox%5B3%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Firefox" border="0" alt="Firefox" src="http://lh3.ggpht.com/_nweCidX3nlI/TGqSuUCTfUI/AAAAAAAAAFU/ubfGId9DlKQ/Firefox_thumb%5B1%5D.jpg?imgmax=800" width="432" height="339" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Yeah, erm. Almost. Firefox very nearly nailed this complex grey box and logo. Good attempt, gold star for effort. I have no idea how adding margin to my logo-cum-hyperlink managed to add a margin to the DIV that is the hyperlink's parent's parent but it's the equivalent to me doing a vasectomy on my granddad before my dad was born.&lt;/p&gt;  &lt;p&gt;Of course stuff in the mark-up is never born. Not unless you're using a different language: XAML. I am used to XAML. I like XAML. Extensible Application Markup Language was written by the people that gave us the world's worst browser, however, XAML works perfectly.&lt;/p&gt;  &lt;p&gt;In XAML, each tag is actually an instance of an object in memory. Each thing is created (born) when the XAML is processed, and things inside things, really do become the children of their parents. The system is tied to the underlying programming language which is compiled and so must be perfect.&lt;/p&gt;  &lt;p&gt;I can create XAML elements in code, and I can create code elements in XAML. It’s a mark-up language for creating object graphs.&lt;/p&gt;  &lt;p&gt;The XAML designer is perfect, stuff can be moved on the page without it writing the movements to the wrong place, and it shows reality.&lt;/p&gt;  &lt;p&gt;By comparison, designing in HTML and CSS is like writing upside down with your wrong hand while blindfolded with only 4 lying bastards to assist you.&lt;/p&gt;  &lt;p&gt;HTML 5 and CSS 3 aren't going to help much. They offer only a few extra commands to allow such extravagances as round corners and Flashless video.&lt;/p&gt;  &lt;p&gt;To truly take the web into the future, the whole system needs to be bulldozed. As HTML 5 and CSS 3 have taken years and years to get this far (nowhere) then a new great system will never be the product of the committee. It would have to be a disruptive innovation from a team of just a few.&lt;/p&gt;  &lt;p&gt;N.B. If there are unusual breaks throughout this document, it's because Windows Live Writer and Blogger can't decide how to format the HTML. Or maybe its the CSS.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-9082588135371488188?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/9082588135371488188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/08/shame-of-css-or-html.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/9082588135371488188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/9082588135371488188'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/08/shame-of-css-or-html.html' title='The Shame of CSS (or HTML)'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nweCidX3nlI/TGqSsi-Z_bI/AAAAAAAAAFE/XVpTHcGM-nk/s72-c/Designer_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-3117804640107267414</id><published>2010-08-11T07:47:00.001-07:00</published><updated>2010-08-11T07:47:33.411-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Email to Phil Haack on MVC Routing</title><content type='html'>&lt;p&gt;Hi Phil &lt;/p&gt;  &lt;p&gt;Congratulations on MVC, I can say that it's the first major MS framework I've enjoyed in a while, due to its simplicity. &lt;/p&gt;  &lt;p&gt;Can I suggest a non-matching style routing system for MVC 4? &lt;/p&gt;  &lt;p&gt;The route-matching logic is prone to problems, see link, and although there may be an answer, I don't care; as a 'user' of your technology, I want to go home happy and make progress on my project. I just want it to work. &lt;/p&gt;  &lt;p&gt;My idea is to have an attribute on each and every action method that sets the route, optional default values for the params and IsDefaultAction for the controller. &lt;/p&gt;  &lt;p&gt;A full list of all controllers and routes can then be made and the need to 'match' is eliminated. &lt;/p&gt;  &lt;p&gt;The only problem might be that attributes are fussy about using constants, so maybe this would suffice if the attrib won't take an anonymous type: &lt;/p&gt;  &lt;p&gt;[Route(Format = &amp;quot;{controller}/{id}/{action}&amp;quot;)]   &lt;br /&gt;[DefaultAction]    &lt;br /&gt;[DefaultParamValue(Param = &amp;quot;id&amp;quot;, Value = &amp;quot;&amp;quot;)]    &lt;br /&gt;public ActionResult ... (string id) { ... } &lt;/p&gt;  &lt;p&gt;And for, controller-less and action-less URLs: &lt;/p&gt;  &lt;p&gt;[Route(Format = &amp;quot;{year}/{month}/{day}&amp;quot;)]   &lt;br /&gt;public ActionResult ... (int year, int month) { ... } &lt;/p&gt;  &lt;p&gt;Which would throw because the day parameter is missing, making route misconfiguration easier to discover. The Controller and Action method to call is inferred from what the attribute decorates. If you wanted to allow it, the controller no longer needs to be named XyzController. &lt;/p&gt;  &lt;p&gt;Furthermore, if someone defines two controller-less and action-less routes, both with 3 params, then this can be caught and thrown when the route table is built instead of only being discoverable when a request comes in. &lt;/p&gt;  &lt;p&gt;For example, if I also add to a different method: &lt;/p&gt;  &lt;p&gt;[Route(Format = &amp;quot;{country}/{case}/{agent}&amp;quot;)] &lt;/p&gt;  &lt;p&gt;Then it should detect that this conflicts with the one above. There's no controller name or action name in the URL to assist routing and both take 3 params. &lt;/p&gt;  &lt;p&gt;I'm sure I've missed out some key things that the current system permits, but as I said, I don't want it to be smart and enigmatic. I want it to work, or clearly direct me to the problem when I mess up. &lt;/p&gt;  &lt;p&gt;Thanks for listening. &lt;/p&gt;  &lt;p&gt;Luke&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-3117804640107267414?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/3117804640107267414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/08/email-to-phil-haack-on-mvc-routing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3117804640107267414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3117804640107267414'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/08/email-to-phil-haack-on-mvc-routing.html' title='Email to Phil Haack on MVC Routing'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-432236976252646008</id><published>2010-07-29T11:11:00.001-07:00</published><updated>2010-07-29T11:11:57.829-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Note to Self: Using WinDbg to See Memory Usage</title><content type='html'>&lt;p&gt;&lt;strong&gt;How to list the memory being used in a .NET application, by type. This can be useful in finding memory usage problems (not always leaks in the strict sense). It's really pretty awful going back to commands and seeing pages of shitty numbers without comma digit grouping, but Microsoft seem not to care to produce a visual debugger.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Download the SDK for the version of Windows and the .NET Framework you have and install it.&lt;/p&gt;&lt;p&gt;Run your app.&lt;/p&gt;&lt;p&gt;Run WinDbg from the Start menu (search for WinDbg).&lt;/p&gt;&lt;p&gt;Start Task Manager and right-click the process and create a dump file. You can also attach to the process from WinDbg.&lt;/p&gt;&lt;p&gt;Drag and drop the .dmp file into the WinDbg shell.&lt;/p&gt;&lt;p&gt;Load the SOS.dll helper thingy using either one of the following commands in WinDbg. The first one instructs the debugger to load the DLL from the same folder as the mscorwks DLL was loaded from. The second is specific, check which version of the Framework your app runs under (I assume 4.0 for my app and forgot I hadn't upgraded it from 3.5).&lt;/p&gt; &lt;pre&gt;&lt;br /&gt;   .loadby sos mscorwks&lt;br /&gt;  .load c:\Windows\Microsoft.NET\Framework\v4.0.30319\SOS.dll&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Successful commands don't always give any feedback - no news is good news.&lt;/p&gt;&lt;p&gt;All going well, you should now be able to issue some commands to WinDbg and start analysing the app. Enter the following command:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;   !dumpheap –stat&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If you get &lt;strong&gt;&amp;quot;Failed to find runtime DLL&amp;quot; (clr.dll), 0x80004005&lt;/strong&gt; then it can be because the wrong SOS.dll was loaded, run the command .unload on its own and it should unload it and you can try loading the right version again.&lt;/p&gt;&lt;p&gt;Otherwise a whole heap of stuff will spew out. Heap. See what I did there? Ordered by total bytes consumed, column 3, the biggest hoarder of memory should be last in the list. System.String usually.&lt;/p&gt;&lt;p&gt;Here are a bunch of links useful to this subject.&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx"&gt;Windows SDK Home&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/b/tess/archive/2005/11/25/dumpheap-stat-explained-debugging-net-leaks.aspx"&gt;!dumpheap -stat explained&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/b/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx"&gt;Memory Leak Hunting&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.theserverside.net/tt/blogs/showblog.tss?id=TrackingMemoryLeaks"&gt;Tracking Memory Leaks - Rico Mariani&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd882521.aspx"&gt;Memory Usage Auditing for .NET Applications&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-gb/magazine/cc163528.aspx"&gt;Investigating Memory Issues&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://geekswithblogs.net/.NETonMyMind/archive/2006/03/14/72262.aspx"&gt;WinDbg Cheat Sheet&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-432236976252646008?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/432236976252646008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/07/note-to-self-using-windbg-to-see-memory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/432236976252646008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/432236976252646008'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/07/note-to-self-using-windbg-to-see-memory.html' title='Note to Self: Using WinDbg to See Memory Usage'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-882081038255490509</id><published>2010-07-23T14:08:00.001-07:00</published><updated>2010-07-23T14:10:35.602-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><category scheme='http://www.blogger.com/atom/ns#' term='soa'/><title type='text'>Note to Self: Don't Let WCF (SvcUtil) Reuse All Libraries</title><content type='html'>&lt;p&gt;&lt;strong&gt;Another short post to remind myself for when I inevitably forget some of the nuances of my nemesis, WCF. This one regards the error below:&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;Warning 1 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: &lt;strong&gt;List of referenced types contains more than one type with data contract name 'Recorder' in namespace 'http://schemas.vuplan.tv/2008/11/vuserv/entities/core/user'. Need to exclude all but one of the following types. &lt;/strong&gt;Only matching types can be valid references: &amp;quot;S26.Vuplan.Core.User.ClientRecorder, S26.Vuplan.Client.MediaCenter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot; (not matching) &amp;quot;S26.Vuplan.Core.User.Recorder, S26.Vuplan.Core, Version=1.0.2.0, Culture=neutral, PublicKeyToken=80726da9f797f65e&amp;quot; (matching) XPath to Error Source: //wsdl:definitions[@targetNamespace='http://schemas.vuplan.tv/2008/11/vuserv/user']/wsdl:portType[@name='IUserService']etc. yeah yeah.&lt;/blockquote&gt;  &lt;p&gt;I don't know why the WCF team didn't add a proper UI to this. To see and configure the mappings between a service and your client app, as well as a more wizardy interface and perhaps a more verbose &amp;quot;here's what I'm doing now&amp;quot; style feedback system would save hours.&lt;/p&gt;  &lt;p&gt;I have a core library in which a Recorder object lives. This core library is used on server and client and defines many entities and other pan-application helpers and types. The problem comes when I define a derived type of Recorder for the client to use, which has more client specific logic in it. I want to new up a ClientRecorder and then pass the thing back up to the cloud, so I add its Recorder DataContract, and that's when it all falls apart.&lt;/p&gt;  &lt;p&gt;The SvcUtil has been instructed to reuse types in all referenced assemblies, so when it tries to map a Recorder contract to one of my types, it can't tell if I want to use the one in the core lib or the new client one.&lt;/p&gt;  &lt;p&gt;I could rem out the DataContract line and reimport, this'd work, but the fix is to make sure that I don't try and reuse types in my client assembly.&lt;/p&gt;  &lt;p&gt;The config page for the Service Reference doesn't allow excludes, so I have to tick almost all assemblies except the ones I definately know don't contain serializable classes. See pic:&lt;/p&gt; &lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/TEoFR1QduII/AAAAAAAAAE4/ojxMfdVgj-Q/s1600-h/Service%20Reference%20Reuse%5B4%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="Service Reference Reuse" border="0" alt="Service Reference Reuse" src="http://lh3.ggpht.com/_nweCidX3nlI/TEoFSeBjkWI/AAAAAAAAAE8/mgvqek-hLCc/Service%20Reference%20Reuse_thumb%5B2%5D.jpg?imgmax=800" width="482" height="448" /&gt;&lt;/a&gt;   &lt;p&gt;By doing it this way, I should be able to hit Update at any point in the future and not suddenly be thrown out by the error and the massive knock on effect it has to compilation.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-882081038255490509?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/882081038255490509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/07/note-to-self-don-let-wcf-svcutil-reuse.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/882081038255490509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/882081038255490509'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/07/note-to-self-don-let-wcf-svcutil-reuse.html' title='Note to Self: Don&amp;#39;t Let WCF (SvcUtil) Reuse All Libraries'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_nweCidX3nlI/TEoFSeBjkWI/AAAAAAAAAE8/mgvqek-hLCc/s72-c/Service%20Reference%20Reuse_thumb%5B2%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7241128667710122661</id><published>2010-07-22T14:18:00.001-07:00</published><updated>2010-07-22T14:27:55.863-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Adding a UserAgent to WCF Clients</title><content type='html'>&lt;p&gt;&lt;strong&gt;A quick post to show how to add a UserAgent to a WCF call so that it can be inspected on the server side, perhaps to see which versions of clients are calling your service.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;And completely free of charge, I'm including some extraneous code I use to show how service method calls can be made without having to jump through hoops every time.&lt;/p&gt;&lt;h4&gt;The code&lt;/h4&gt;&lt;code&gt;&lt;div style="font-family: courier new"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; T CallServiceMethod&amp;lt;T&amp;gt;(Func&amp;lt;T&amp;gt; methodCall, &lt;span style="color: blue"&gt;bool&lt;/span&gt; canExpectNull) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; T response; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;using&lt;/span&gt; (OperationContextScope scope = &lt;span style="color: blue"&gt;new&lt;/span&gt; OperationContextScope(&lt;span style="color: blue"&gt;this&lt;/span&gt;.ServiceClientChannel)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; HttpRequestMessageProperty p = &lt;span style="color: blue"&gt;new&lt;/span&gt; HttpRequestMessageProperty();&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p.Headers.Add(System.Net.HttpRequestHeader.Cookie, &lt;span style="color: blue"&gt;this&lt;/span&gt;.AuthenticationCookie);&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p.Headers.Add(System.Net.HttpRequestHeader.UserAgent, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(ServiceHelper).Assembly.FullName);&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, p); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.IncrementCallsInProgress(); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;try&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; response = methodCall.Invoke(); &lt;br /&gt;&lt;/div&gt;&lt;/code&gt;&lt;h4&gt;The blurb&lt;/h4&gt;&lt;p&gt;I'm sorry about the broken lines - I so nearly picked a full width Blogger template, too. The method above essentially wraps a delegate invocation in some calls into WCF's OperationContext which adds the headers. It's interesting to look at the OperationContext in the debugger, much as you probably did with the HttpContext when first looking at an ASP.NET app - its sort of the equivalent but in reverse.&lt;/p&gt;&lt;p&gt;The method's ending isn't shown, I'm lazy like that, but it just catches errors, the finally block decrements the calls-in-progress counter and there's some logging.&lt;/p&gt;&lt;p&gt;On the server, I use the HttpContext.Current.Request.UserAgent string to log which client versions my customers are running. Useful.&lt;/p&gt; &lt;p&gt;Notice that I'm also adding a cookie which I store in the class that this method is part of. I'm using the built-in AuthenticationService which uses Forms Authentication and thus, cookies. This is not required in Silverlight as the IE stakc stores and reapplies appends any cookies received, automatically.&lt;/p&gt; &lt;p&gt;To use this method, I instantiate my service client proxy and then call ServiceHelper.CallServiceMethod&lt;ReturnType&gt;( () =&gt; { return proxy.SomeMethod(xyz); });&lt;/p&gt; &lt;p&gt;The proxy call is thus invoked within the context changes above.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7241128667710122661?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7241128667710122661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/07/adding-useragent-to-wcf-clients.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7241128667710122661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7241128667710122661'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/07/adding-useragent-to-wcf-clients.html' title='Adding a UserAgent to WCF Clients'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6866005746789612369</id><published>2010-07-19T13:59:00.001-07:00</published><updated>2010-07-19T14:04:01.189-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Setting-Up WCF Over SSL on IIS 7.x</title><content type='html'>&lt;p&gt;&lt;strong&gt;This is a short post is about the steps I had to take to switch an existing test WCF service over to a secure staging version that more closely mimics how it’ll be in the production environment. I hope to include some things they didn’t tell you in the instruction manual, mainly concerning the use of test certificates.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;It’s stuff like this – configuring a secure web service – that makes me dislike WCF and IIS quite a lot. I liked Web Services, and Remoting, I even found raw sockets surprisingly easy but WCF is hard work. It’s the sort of thing that needs its own UI, management tools, and server, but to do this would arguably constrain its power.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Add a self-signed certificate to the server by opening IIS Manager, highlighting your server name in the left pane and locating Server Certificates on the right and choosing Create Self-Signed Certificate then following the instructions.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Add a new binding to your site for HTTPS and note that there’s no option for the host name.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;WCF cannot handle multiple bindings to the same scheme, as IIS and ASP.NET sites can, so if your WCF service is hosted downstream of your main site, such as from a virtual directory underneath your root domain and site, then add the following to your web.config which will filter the bindings so WCF sees just two:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;serviceHostingEnvironment&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;baseAddressPrefixFilters&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;add&lt;/span&gt; &lt;span style="color: red"&gt;prefix&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;http://wwwdev.dom.co.uk&lt;/span&gt;&amp;quot; /&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;add&lt;/span&gt; &lt;span style="color: red"&gt;prefix&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;https://wwwdev.dom.co.uk&lt;/span&gt;&amp;quot; /&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;baseAddressPrefixFilters&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;serviceHostingEnvironment&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;   &lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;And now the bit that seems never to be explained and doesn’t seem to merit a proper UI in IIS, binding the certificate to the host header. Run this at a command prompt (one line):&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;appcmd set site /site.name:&lt;span style="color: maroon"&gt;&amp;quot;Main Site&amp;quot;&lt;/span&gt; /+bindings.[protocol=&lt;span style="color: maroon"&gt;'https'&lt;/span&gt;,bindingInformation=&lt;span style="color: maroon"&gt;'*:443:wwwdev.dom.co.uk'&lt;/span&gt;]&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Do not remove the original HTTPS binding. When I did, I got this error:&lt;/p&gt;&lt;p&gt;An error occurred while making the HTTP request to &lt;a href="https://wwwdev.dom.co.uk/xml/AuthenticationService.svc"&gt;https://wwwdev.dom.co.uk/xml/AuthenticationService.svc&lt;/a&gt;. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Now, if you’re using the built-in AuthenticationService, in your web.config or web.staging.config, make the following change/addition:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;system.web.extensions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;scripting&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;webServices&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: blue"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;authenticationService&lt;/span&gt; &lt;span style="color: red"&gt;enabled&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;requireSSL&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;quot;/&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;  &lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Still in this document, find the binding element for the service and set it to use Transport security – the bottom lump of mine looks like this:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;binding&lt;/span&gt; &lt;span style="color: red"&gt;name&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;ssl&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;security&lt;/span&gt; &lt;span style="color: red"&gt;mode&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Transport&lt;/span&gt;&amp;quot; /&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;binding&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;basicHttpBinding&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;/&lt;span style="color: maroon"&gt;bindings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Close and save all that and then make the same change on the client. Personally, I don’t use config files for public ‘out there’ apps so the change is made within a service client factory using the following code:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (withSsl)&lt;br /&gt;    basicBinding.Security.Mode = BasicHttpSecurityMode.Transport;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Add the following non-WCF specific code at some point in your app which essentially just accepts any certificates as valid even if they’re downright dodgy (so make sure not to let it leak into production).&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;#if&lt;/span&gt; DEBUG || STAGING&lt;br /&gt;    System.Net.ServicePointManager.ServerCertificateValidationCallback = (se, cert, chain, sslError) =&amp;gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt;&amp;#160;&lt;span style="color: maroon"&gt;true&lt;/span&gt;; };&lt;br /&gt;    _log.Warn(&lt;span style="color: maroon"&gt;&amp;quot;A pre-release option has been set: server certificates are no longer being checked for validity by this client app.&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;span style="color: blue"&gt;#endif&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;You do not need to add code that modifies the Authentication settings for the ServiceCertificate on the ClientCredentials object of a service client (ServiceBase&amp;lt;T&amp;gt;).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Now test your service. You may want to use a tool like Fiddler to inspect the HTTP traffic.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6866005746789612369?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6866005746789612369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/07/setting-up-wcf-over-ssl-on-iis-7x.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6866005746789612369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6866005746789612369'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/07/setting-up-wcf-over-ssl-on-iis-7x.html' title='Setting-Up WCF Over SSL on IIS 7.x'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-4252094056793143862</id><published>2010-07-12T05:03:00.001-07:00</published><updated>2010-07-12T05:03:35.039-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='finance'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><category scheme='http://www.blogger.com/atom/ns#' term='investing'/><title type='text'>On Investing</title><content type='html'>&lt;p&gt;&lt;strong&gt;A friend recently told me he’d started spread-betting and had a misguided perception that I know a thing or too about it, might even be good at it. I thought the truth would make for an interesting off-topic blog post, so here’s what I know.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The recent crash cleared out all my winnings and then some. I eventually liquidated everything last month and was, over 10 years of trading/investing, about £3k down, probably all the trading fees! &lt;/p&gt;  &lt;p&gt;I learned a number of lessons. &lt;/p&gt;  &lt;p&gt;Back in 2004, I opened an account with IG Index so that I could expose myself to gold. There were no ETFs then so spread-betting was the only way to go. I opened a position with £700 in the account at £50/tick opening at $450/oz. A man called from IG Index doing a survey, and asked why I chose gold. I told him that inflation was rife. The CPI was about 1.5% so he audibly laughed! So I knew I was right. &lt;/p&gt;  &lt;p&gt;Contrarian investing goes along the thinking that there are no people left to sell/buy a position so it cannot go lower/higher, this is best when something becomes accepted as a law, a constant that will never change, such as to suggest the opposite invokes derision. &lt;/p&gt;  &lt;p&gt;But my reasons for taking this view was that in 2004, copper and lead prices were double the previous year, sugar, too, and yet nothing was more expensive in the shops and nothing said in the press. Prices were flying up, in stealth mode. At some point it'd hit consumers in the shape of massive inflation. &lt;/p&gt;  &lt;p&gt;I once predicted the net result of this in an email to a trainee credit derivs trader at the bank, saying:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_nweCidX3nlI/TDsEkb2MU9I/AAAAAAAAAEw/vv5eZwj1jeA/s1600-h/Prediction%20of%20Inflation%20and%20Crash%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Prediction of Inflation and Crash" border="0" alt="Prediction of Inflation and Crash" src="http://lh6.ggpht.com/_nweCidX3nlI/TDsEk1lLJeI/AAAAAAAAAE0/R_i054TrbKQ/Prediction%20of%20Inflation%20and%20Crash_thumb%5B1%5D.jpg?imgmax=800" width="596" height="46" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;(If I’d known something about the RMBS market and CDOs, maybe I could have predicted the bigger collapse)&lt;/p&gt;  &lt;p&gt;Today gold is at $1,200-ish but I didn't make £37,500. The reason is that I tried to trade the position so that I bought back in at low points. The obvious logic is that, even though you're a bull, why hold the position during weakness when a) your money can be used elsewhere b) you can get by more later, lower? &lt;/p&gt;  &lt;p&gt;The problem is that when you're onto a good thing, you often don't know how right you are. You sell and make a profit and the price weakens but you don't buy, it's going lower. It goes higher. But it'll go lower and you'll get back in. You don't want to buy back in and then it goes lower and you lose and then you'll be doubly annoyed because you *knew* it was going lower but were weak willed. It goes higher. It goes higher. You never buy back in. Months later when you’ve forgiven yourself and your mind has cleared, you buy back in, but you missed it. &lt;/p&gt;  &lt;p&gt;This isn't actually the main lesson. I bought back in after they released an ETF, Gold Bullion Securities (GBS.L). I held this at the same time as a load of shares. My thinking was that with a financial apocalypse ensuing, gold will go through the roof and hedge any losses elsewhere. &lt;/p&gt;  &lt;p&gt;What actually happened was that gold did nothing. I remember watching gold during the deepest darkest days of the meltdown and it actually did nothing. The financial system of the entire planet about to implode and gold did nothing. &lt;/p&gt;  &lt;p&gt;Then I had to sell my position because the ETF was backed by a subsidiary of SG, then by an Australian company and underwritten by AIG, who were going bust. &lt;/p&gt;  &lt;p&gt;And later it came out that China was buying dollars by the hundred-billion-load during the crash. This kept gold up. They were secretly buying from the Fed to manipulate the currency because China’s wealth in denominated in USD and they could not afford for that to sink. &lt;/p&gt;  &lt;p&gt;The lesson is two-fold. With AIG, it showed that the whole system is linked. You can’t escape it. As Warren Buffet once said, it’s like insuring the Titanic via a company based on the Titanic. &lt;/p&gt;  &lt;p&gt;The second part shows that even when you know stuff, you don’t know stuff. I didn’t know that much bigger powers would manipulate the market to prevent my perfect plan from working out. &lt;/p&gt;  &lt;p&gt;The next main lesson was discovering the ramifications of something you know from day one: that share prices are quite literally nothing, zero, to do with the company or its performance. Share prices are in the minds of the participants. &lt;/p&gt;  &lt;p&gt;“The market can stay irrational, longer than you can stay solvent.” &lt;/p&gt;  &lt;p&gt;Because there is no link between a share price and the reality of a company’s financial health, it means that a perfectly profitable company with a good outlook can have a share price of nothing, and can go bust because of it. Share prices, company’s fates, the stock exchange and the world’s wealth are driven solely by mass human hysteria. The system is ridiculous. &lt;/p&gt;  &lt;p&gt;If enough people think that everything is going to pot, then everything will go to pot. This is why exchanges have daily limits and cut offs. It’s to stop everyone from running to starboard. &lt;/p&gt;  &lt;p&gt;For me, this meant that, as in the case of a gold mining company I invested in, I was able to draw up a financial model of their company, ins, outs, raw materials prices, and predict their profits to within a few hundred thousand pounds, I was unable to translate this incredible knowledge into gain, because the market does NOT care for reality. The market is perception, and perception is usually masses of stupid humans doing stupid things. &lt;/p&gt;  &lt;p&gt;Investing/trading takes up a lot of time. My biggest profits came from the stuff I never touched. General ‘ideas’, such as China’s growth, Brazilian industry, natural resources; my funds did quite well though all of this, up 25%, and I spent an hour a week researching, if that. If I’d put all my money in funds, I’d be much, much better off. &lt;/p&gt;  &lt;p&gt;I bought and held a general idea, let someone else manage it, and sold years later. These days, I’d put my money into someone I can trust, have 100% control over, and enjoy the process – myself, my business or my home. For savings and pensions, I’d use trusts, but revise it every 6 months. &lt;/p&gt;  &lt;p&gt;The problem with most people and pensions that end up worthless, is that they buy and hold something good in 1969 and never take an interest thereafter and it dies while the world changes. Buy and hold, but keep control and tweak it according to world issues. &lt;/p&gt;  &lt;p&gt;And there you have it ;) – lots of time wasted, lots and lots of stress, much reduced focus on my core skills as a programmer and all for nothing. Or maybe all for a life lesson… &lt;/p&gt;  &lt;p&gt;…at least I learned all this now and not when I am 60. &lt;/p&gt;  &lt;p&gt;Luke &lt;/p&gt;  &lt;p&gt;P.S. Check out Robbie The Trader (nakedtrader) online. While I’d try and make thousands per position, Robbie makes many, many meagre profits. &lt;a href="http://www.nakedtrader.co.uk/trades.htm"&gt;http://www.nakedtrader.co.uk/trades.htm&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;He used to run a café and has amassed &amp;gt;£750k from an ave. £200 profit per trade. It’s funny because the rare times I have played a fruit machine I took whatever was there and went away a winner, but I couldn’t apply it to shares, as Robbie does.&lt;/p&gt;  &lt;p&gt;This is how I won the Warrants trading competition, it wasn’t real money and with so few people in the game, in profit, I knew that all I had to do was make a small profit in ALL weeks because most people would suffer at least one week of immense losses.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-4252094056793143862?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/4252094056793143862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/07/on-investing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4252094056793143862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4252094056793143862'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/07/on-investing.html' title='On Investing'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nweCidX3nlI/TDsEk1lLJeI/AAAAAAAAAE0/R_i054TrbKQ/s72-c/Prediction%20of%20Inflation%20and%20Crash_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-5385019257682151022</id><published>2010-06-18T09:16:00.001-07:00</published><updated>2010-06-18T09:21:27.556-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>How to: Send Email from a Microsoft Server Application</title><content type='html'>&lt;p&gt;&lt;strong&gt;If you have a server application, web site or even a job or task running  on a Windows server, you may need to send out emails. For me, it was an ASP.NET  MVC 2 application; I needed to send an email to people who stuck their address in  the interested parties register on the coming soon page on &lt;a href="http://www.vuplan.tv" title="Links to vuPlan.tv home page."&gt;vuPlan.tv&lt;/a&gt;  to confirm it was a genuine request. But you could have a build server that you  want to email out a report from or some other thing. This guide is more about the  server side setup than the SMTP client you send, although I will give examples in  .NET and DOS, via Blat.exe.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To make things easy, I’ll bullet the whole process.&lt;/p&gt; &lt;ul&gt; 	&lt;li&gt; 	&lt;p&gt;First, ensure that you cannot use an existing Exchange Server or MTA in your  	organisation. It makes life so much easier when someone else deals with these  	things because, as the person coding or scripting, you should only care about  	getting the job done.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;After you’ve failed to convince the jobsworth in IT security, install your  	own one. In Windows Server 2008 (Web Edition, also) open &lt;strong&gt;Server Manager&lt;/strong&gt;  	&amp;gt; Features node &amp;gt; Right-click &amp;gt; Add Feature &amp;gt; locate &lt;strong&gt;SMTP Server&lt;/strong&gt;  	and install the requisite IIS 6 components as well as &lt;strong&gt;Telnet Client&lt;/strong&gt;.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;If you are using a hosted or public internet facing server, you should now  	ensure that your server had a &lt;strong&gt;PTR Record &lt;/strong&gt;for its IP address.  	The people that gave you your RIPE internet address can do this (usually your  	host or ISP). Do this now so they can get started.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;To prevent spam, most MTAs will do a &lt;strong&gt;reverse DNS (rDNS)&lt;/strong&gt;  	lookup on your server to ensure you have the same domain name as you claim to  	be sending email from. The style of address your server has can also trigger  	a spam detector, so avoid a reverse DNS address such as 100-99-98-97.dynamic.mydomain.com  	as it looks like the dynamic ranges given out to broadband home users (who are  	blacklisted on SMTP servers by default).&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Check &lt;a href="http://spamhaus.org"&gt;http://spamhaus.org&lt;/a&gt; and make sure  	that your IP address is not blacklisted before you begin.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Set the &lt;strong&gt;Simple Mail Transport Protocol&lt;/strong&gt; service to start  	automatically.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;You may want to add an smtp CNAME into your DNS server so you can move it  	in future without editing code or config files.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;In &lt;strong&gt;IIS 7 Manager&lt;/strong&gt;, locate your site and then the &lt;strong&gt; 	SMTP E-mail&lt;/strong&gt; icon and set the email address and check the radio button  	to deliver to localhost on port 25, or the DNS alias you setup. Two things to  	note: setting delivery to a pick-up directory is useful on development boxes  	when you don’t want to flood the mail servers with real email. The .eml files  	can be opened in Outlook. Also, the other settings on this page may actually  	be ignored by clients/your app, but I’m setting them in any case.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Open &lt;strong&gt;IIS 6 Manager&lt;/strong&gt; and you should just have the SMTP node  	in there.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Right-click the SMTP virtual server and go to &lt;strong&gt;Properties&lt;/strong&gt;.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Tab 1: Tick &lt;strong&gt;Enable logging &lt;/strong&gt;and set a valid path.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Tab 2: Under &lt;strong&gt;Authentication&lt;/strong&gt;, set &lt;strong&gt;Anonymous access 	&lt;/strong&gt;only for the time being. Under &lt;strong&gt;Connection&lt;/strong&gt;, check 	&lt;strong&gt;All except the list below &lt;/strong&gt;and under &lt;strong&gt;Relay&lt;/strong&gt;,  	check &lt;strong&gt;All except the list below &lt;/strong&gt;and tick &lt;strong&gt;Allow all  	computers&lt;/strong&gt; at the bottom.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Tab 3: Check the &lt;strong&gt;Badmail directory&lt;/strong&gt; you can fill in the 	&lt;strong&gt;Send copy…&lt;/strong&gt; box but it may not work anyway, at first. Leave  	the other settings.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Tab 4: Set all timeouts and delays to minimum. This is so the server stops  	trying and gives you an error to look at quickly. You should reset these after  	setting up/troubleshooting. Enter &lt;strong&gt;Outbound Security&lt;/strong&gt; and make  	sure that its set to &lt;strong&gt;Anonymous&lt;/strong&gt;.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;You should review the other tabs but otherwise leave them for now and click 	&lt;strong&gt;OK.&lt;/strong&gt;&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Now rename the domain to just the domain part and close IIS 6 Manager.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Open a DOS prompt and test that your SMTP server is listening. &lt;strong&gt;telnet  	localhost 25&lt;/strong&gt; or whatever your server name is. Note “Microsoft ESMTP  	MAIL Service, Version: 7.5”: 7.5 eh? What’s all this needing IIS 6 all about  	then?&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Download &lt;strong&gt;Blat.exe&lt;/strong&gt; and ‘install’ a default profile like so:&lt;/p&gt; 	&lt;code&gt;blat -install -f fromaddress@mydomain.com -server localhost -port 	&lt;span style="color: maroon"&gt;25&lt;/span&gt; -try &lt;span style="color: maroon"&gt;1&lt;/span&gt;  	-profile myprofile&lt;/code&gt; &lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Now you can try sending a test message like so:&lt;/p&gt; 	&lt;code&gt;blat - -to me@hotmail.com -f me@mydomain.com -p myprofile -body 	&lt;span style="color: maroon"&gt;&amp;quot;This is a test.&amp;quot;&lt;/span&gt; -subject 	&lt;span style="color: maroon"&gt;&amp;quot;This is a test message.&amp;quot;&lt;/span&gt;&lt;/code&gt; &lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Hotmail has a very clearly written Non-delivery Report (NDR) message, which  	is why I choose them, also you’ll hear the ping from Live Messenger if it works.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Remember to check your &lt;strong&gt;Junk&lt;/strong&gt; folder!&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Open Event Viewer and ensure nothing was logged by the SMTP service. I use  	a catch all filter for “Everything in the last hour”.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Open the c:\inetpub\mailroot folder and keep an eye on what’s in each of  	the folders. Personally, I’ve found that Badmail doesn’t seem to gather anything  	and that the &lt;strong&gt;Drop&lt;/strong&gt; folder has the most interesting information.  	EML files can be opened in Notepad and the Drop folder is like the Inbox; it  	will receive NDRs that contain error messages.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Also, check the SMTP service log file. A successful connection should be  	visible in the log as &lt;strong&gt;OutboundConnectionResponse&lt;/strong&gt; lines. If  	these are not there, then it is having a problem connecting to the remote mail  	server.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Check that the remote MTA is up. Use &lt;a href="http://mxtoolbox.com"&gt;http://mxtoolbox.com&lt;/a&gt;  	to find the MX record and thus the mail server for the recipient. Check it’s  	up.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Ensure that port 25 is open in your firewall.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Attempt to telnet to the remote server.&lt;/p&gt; 	&lt;/li&gt; 	&lt;li&gt; 	&lt;p&gt;Give up and use &lt;a href="http://Jangomail.com"&gt;http://Jangomail.com&lt;/a&gt;&lt;/p&gt; 	&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;When you get Blat.exe sending successfully, then you can use the &lt;a href="http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx" title="Link to Scott Guthrie's blog post on SmtpClient"&gt; SmtpClient&lt;/a&gt; class to very easily fire out your emails from your ASP.NET app.&lt;/p&gt; &lt;p&gt;Good luck!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-5385019257682151022?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/5385019257682151022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/06/how-to-send-email-from-microsoft-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5385019257682151022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5385019257682151022'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/06/how-to-send-email-from-microsoft-server.html' title='How to: Send Email from a Microsoft Server Application'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7758365718447902781</id><published>2010-05-26T12:10:00.001-07:00</published><updated>2010-05-26T12:10:09.260-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>How to Flash BIOS on an IBM eServer</title><content type='html'>&lt;p&gt;A server being a type of PC, and a PC being a open-platform, the process is less than straight forward. Not least because tiny OSes like DOS are on the way out without a suitable replacement; there’s WinPE but most IHVs have yet to use this for flashing BIOSes – maybe it cannot be done. Floppies have also gone without a really easy way to replace them. And Microsoft have removed SYS and the /S option from FORMAT, just to piss you off.&lt;/p&gt;&lt;p&gt;You’ll also need an XP machine because the tool that’s key to all this doesn’t run on Vista/7. Makes you want to scream doesn’t it?&lt;/p&gt;&lt;ul&gt;   &lt;li&gt;Download the IMG file from the IBM site.&lt;/li&gt;   &lt;li&gt;Download the HP USB Flash Boot Thingy Tool from &lt;a title="HP site" href="http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&amp;amp;cc=us&amp;amp;swItem=MTX-UNITY-I23839&amp;amp;jumpid=reg_R1002_USEN"&gt;here&lt;/a&gt;.&lt;/li&gt;   &lt;li&gt;Install it onto your XP box.&lt;/li&gt;   &lt;li&gt;Stick your USB pen in and run the HP tool.&lt;/li&gt;   &lt;li&gt;Choose to make a floppy and point it to the IBM .img file.&lt;/li&gt;   &lt;li&gt;It should complete in a second.&lt;/li&gt;   &lt;li&gt;Shove the USB pen in your IBM server and hit F12 to boot from Removable Drives.&lt;/li&gt;   &lt;li&gt;Follow the instructions.&lt;/li&gt;&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7758365718447902781?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7758365718447902781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/05/how-to-flash-bios-on-ibm-eserver.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7758365718447902781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7758365718447902781'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/05/how-to-flash-bios-on-ibm-eserver.html' title='How to Flash BIOS on an IBM eServer'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-2301015255197843558</id><published>2010-05-18T07:31:00.001-07:00</published><updated>2010-05-18T07:44:28.919-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='frontiers'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Azure vs Hosting: Bang for Buck</title><content type='html'>&lt;p&gt;&lt;strong&gt;Following on from my &lt;a title="Blog Post Link" href="http://www.lukepuplett.com/2010/05/compare-meerkat-windows-azure-cost.html"&gt;last posting&lt;/a&gt; about the cost of running an Azure hosted little website I have done some more calculations.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;As it turned out, my previous favourite, Fido.net had run out of servers and wanted more money than I was prepared to part with for the next rung up the server ladder.&lt;/p&gt;  &lt;p&gt;Previously, I had toyed with the idea of running my own server. I can do this with Fido but they want me insured, and when I spoke to insurance people, they said that it was a waste of time as it would be incumbent on the OEM of the server that set fire to the building.&lt;/p&gt;  &lt;p&gt;Redstation do co-lo and its cheap. You get a 100Mbit line and around 4Tb traffic cap, a 1U space in the rack and 8 IP addresses (5 usable), 24/7 access and free tea and coffee from the machine.&lt;/p&gt;  &lt;p&gt;Couple them with a little server built &lt;a href="http://gopcn.com/"&gt;here&lt;/a&gt; and I could be onto a sure fire value winner.&lt;/p&gt;  &lt;p&gt;A custom PCN built 1U server with my own added reliable SSD drive will set me back $775. That's a quad core box with 8Gb RAM.&lt;/p&gt;  &lt;p&gt;I can also load it up with my own BizSpark licensed software, which is not an option when you rent a server. Plus I can add another server some day and split out the SQL duties – although I’m getting ahead of myself.&lt;/p&gt;  &lt;p&gt;Let's see how it all stacks up. Sorry for the micro text.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_nweCidX3nlI/S_Kk1j-rixI/AAAAAAAAAEo/5j3Rj1yjtA4/s1600-h/BangBuck%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="BangBuck" border="0" alt="BangBuck" src="http://lh5.ggpht.com/_nweCidX3nlI/S_Kk2AjmL-I/AAAAAAAAAEs/TsujKNFSZbM/BangBuck_thumb%5B3%5D.png?imgmax=800" width="648" height="224" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Unless I’m mistaken, and the point of a blog is much to do with airing thoughts so that others can give theirs, Windows Azure is exceptionally bad value.&lt;/p&gt;  &lt;p&gt;I’m now using the Compute time as “time in existence” of the VM. And when the VMs are so puny, and the price is so large, 7p an hour for 1.6Ghz and 1.75Gb RAM, its not good.&lt;/p&gt;  &lt;p&gt;When I first looked at Microsoft’s Azure platform, I thought it spelled the end for traditional hosters. Evidently not. I thought it was a low barrier to entry way for mobile app makers to get their apps into the cloud.&lt;/p&gt;  &lt;p&gt;They have missed the opportunity to be truly disruptive in this market and charge a base rate plus the amount you use. Being MS, they own the OS and have the power to really accurately charge by utilisation, and auto provision at times or duress. At the moment, the value proposition is in the quick provisioning of servers and would benefit a company that gets massive influxes of traffic for short periods, like ticket sales.&lt;/p&gt;  &lt;p&gt;Anyway, this is as much about Azure as it is about hosting options for a small website/service, and so it now looks like building a cheap server and paying for the rack space is the most cost-effective solution.&lt;/p&gt;  &lt;p&gt;Until I sign a contract though, it could change. One thing that rented boxes provide is a little more peace of mind from driving down to the chilled room with a screwdriver at 2am. Although from my experience, hardware doesn’t fault that easily and its almost always a dodgy spindle.&lt;/p&gt;  &lt;p&gt;With SSD drives, I hope to eliminate that.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-2301015255197843558?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/2301015255197843558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/05/azure-vs-hosting-bang-for-buck.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2301015255197843558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/2301015255197843558'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/05/azure-vs-hosting-bang-for-buck.html' title='Azure vs Hosting: Bang for Buck'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_nweCidX3nlI/S_Kk2AjmL-I/AAAAAAAAAEs/TsujKNFSZbM/s72-c/BangBuck_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-4051970997259584012</id><published>2010-05-15T10:20:00.001-07:00</published><updated>2010-06-11T04:04:34.366-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='frontiers'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Compare the Meerkat: Windows Azure Cost Planning</title><content type='html'>&lt;p&gt;Please read the comments. This was written before I confirmed that Azure compute time is uptime, not CPU time actually used.&lt;/p&gt;&lt;p&gt;&lt;p&gt;I have another &lt;a href="http://www.lukepuplett.com/2010/05/azure-vs-hosting-bang-for-buck.html"&gt;post&lt;/a&gt; written after establishing the above fact.&lt;/p&gt;&lt;strong&gt;This weekend I had planned to get my data into the cloud, Microsoft's cloud to be precise, but was confronted with Microsoft's version of an online shopping service before I could provision my little slice of the cloud. Probably foolishly, I was expecting to just walk right in with my Live ID and MSDN sub, but it gave me the opportunity to compare the Windows Azure prices with the rest of the colo and hosting market.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;As with any cost planning, a load of assumptions have to be made about capacity and requirements. In the ordinary world of hosting, this means basically wondering if you'll use all the RAM on the supplied box or not, but with the Windows Azure model so granularly broken down, it makes it slightly more trifling.&lt;/p&gt;&lt;p&gt;Azure has prices for storage transactions as well as for things like AppFabric Access Control transactions and Service Bus connections. For the sake of my planning I have conveniently pretended that they're not there in a sort of ignorance is bliss line of thinking. Well, I actually don't think I'll use this stuff for my project, yet.&lt;/p&gt;&lt;p&gt;I'll delay no longer and get to the interesting part. For £129.22 I'll be getting an equivalent of a 1Ghz processor running at full chat for a month, as well as 1Mbit of full chat bandwidth, 0.1Mbit incoming and 50Gb storage used. Oh and not forgetting 10Gb of SQL Azure - 1Gb being really rather too measly for anyone's use of a full blown RMDBS.&lt;/p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/S-7XyWDzTSI/AAAAAAAAAEY/JvHI9VQZC5k/s1600-h/AzureSmallScenario%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="AzureSmallScenario" border="0" alt="AzureSmallScenario" src="http://lh4.ggpht.com/_nweCidX3nlI/S-7XzAclnCI/AAAAAAAAAEc/YeRqcTDf3Rc/AzureSmallScenario_thumb%5B3%5D.png?imgmax=800" width="631" height="300" /&gt;&lt;/a&gt;&lt;p&gt;What's perhaps interesting is that MS don't seem to charge for extra RAM. To access more RAM you take a bigger instance with more processors, but if your workload is the same the clock cycles will cost the same, albeit spread over more cores.&lt;/p&gt;&lt;p&gt;For comparison's sake here's a similar costing scenario I did with a bunch of hosting companies in and around the UK. Stop squinting.&lt;/p&gt;&lt;a href="http://lh5.ggpht.com/_nweCidX3nlI/S-7XziJ43JI/AAAAAAAAAEg/TpigVQL4R6Y/s1600-h/2009HostingComparison%5B10%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2009HostingComparison" border="0" alt="2009HostingComparison" src="http://lh3.ggpht.com/_nweCidX3nlI/S-7X06f9E1I/AAAAAAAAAEk/nM3YVByBSk8/2009HostingComparison_thumb%5B8%5D.jpg?imgmax=800" width="631" height="242" /&gt;&lt;/a&gt;&lt;p&gt;The company I has previously chosen was Fido.net which charges about £100p/m for a dedicated dual core box with a single 500Gb HDD and Windows and SQL Server 2008. They give you 2Mbit for about £30p/m which equates to around 600Gb in/out data and 5% of your time you can be bursting to full 100Mbit.&lt;/p&gt;&lt;p&gt;Fasthosts might work out cheaper and CloudHosts have a very good reputation but little Fido.net was setup by an ex colleague and while I don't get mate's rates, I do feel that his small company won't have a saturated network and a lack of care for any woes I might run into.&lt;/p&gt;&lt;p&gt;And regarding that bandwidth, most companies give an unmetered 100mbps mbit (whatever) connection and say that its shared but also that &amp;quot;no one has ever come near to rinsing it&amp;quot; - which makes me think that 1Mbit might probably suffice in my situation and thus the amount assumed in my Azure scenario.&lt;/p&gt;&lt;h4&gt;Half Conclusion&lt;/h4&gt;&lt;p&gt;Fido.net's £100 + £30 is very much like Azure's £129 and so this leaves me in a quandary. I could go with Azure and its instant scalability and other features to plug into etc. but that £130 in the Fido purse gives me much more than what I get with Azure, if I choose to use it. Remember that with Azure I'm pricing that exact usage, whereas with the others, there's a lot more room left before I need to buy and bigger or another dedicated server.&lt;/p&gt;&lt;p&gt;If I were to compare the cost of a fully utilised dedicated server with Azure, the dedicated box would win hands down. And therein lies the rub: those damned usage assumptions.&lt;/p&gt;&lt;p&gt;Mostly though, I am put off by that SQL Azure price; £60p/m for 10Gb when normal hosters will dish out the whole server and SQL Server with the freedom to fill the whole disk with a 250Gb database if you so desire.&lt;/p&gt;&lt;p&gt;I hope this gives someone food for thought, even if my costings aren't terribly scientific.&lt;/p&gt;&lt;p&gt;P.S. Doesn't factor in the 'offers' that Microsoft have for new joiners, which are about 50% off for 6 months ish.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-4051970997259584012?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/4051970997259584012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/05/compare-meerkat-windows-azure-cost.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4051970997259584012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4051970997259584012'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/05/compare-meerkat-windows-azure-cost.html' title='Compare the Meerkat: Windows Azure Cost Planning'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_nweCidX3nlI/S-7XzAclnCI/AAAAAAAAAEc/YeRqcTDf3Rc/s72-c/AzureSmallScenario_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-4580135059780922159</id><published>2010-04-28T07:50:00.001-07:00</published><updated>2010-04-28T07:50:04.714-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='touch'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>My Gestural Listbox in WPF Wearing Windows Phone 7 Clothes</title><content type='html'>&lt;p&gt;&lt;strong&gt;Here's a dire quality video of a control that I hope to find time to blog about in the coming weeks. It's inspiration is obvious, it's execution was tough. Involved crash-learning Newtonian mechanics, solving equations and a bit of calculus.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Essentially, its a smart scrollviewer, so it can house all manner of controls; indeed I've &lt;a href="http://www.youtube.com/watch?v=I8EnMI1RNO4"&gt;uploaded&lt;a&gt; one of a large image being panned with flicks and drags.&lt;/p&gt; &lt;p&gt;If enough people are interesed, I'll put the control up on CodePlex.&lt;/p&gt; &lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Vsc93SUVLyI&amp;amp;hl=en_GB&amp;amp;fs=1&amp;amp;rel=0&amp;amp;color1=0xcc2550&amp;amp;color2=0xe87a9f"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Vsc93SUVLyI&amp;amp;hl=en_GB&amp;amp;fs=1&amp;amp;rel=0&amp;amp;color1=0xcc2550&amp;amp;color2=0xe87a9f" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-4580135059780922159?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/4580135059780922159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/04/my-gestural-listbox-in-wpf-wearing.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4580135059780922159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4580135059780922159'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/04/my-gestural-listbox-in-wpf-wearing.html' title='My Gestural Listbox in WPF Wearing Windows Phone 7 Clothes'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-8460390559406603693</id><published>2010-04-07T09:21:00.001-07:00</published><updated>2010-04-07T09:48:22.573-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Note to self: Events Mostly Don't Leak Memory</title><content type='html'>&lt;p&gt;&lt;strong&gt;Another note-to-self style blog post in which I write down something that I seem to research and then forget the concrete answer some years later. This one is about the half-myth that events leak memory.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Failing to unsubscribe from events is bad because in some cases it keeps objects from being garbage collected. However, in closely integrated models of classes, it probably won't matter.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The following two UML models show how events may or may not leak.&lt;/p&gt;&lt;a title="UML Non-leaky Model by lukepuplett, on Flickr" href="http://www.flickr.com/photos/22787790@N06/4500411432/"&gt;&lt;img alt="UML Non-leaky Model" src="http://farm5.static.flickr.com/4072/4500411432_53f2d0ff00_b.jpg" width="250" height="1024" /&gt;&lt;/a&gt; &lt;a title="UML Leaky Model by lukepuplett, on Flickr" href="http://www.flickr.com/photos/22787790@N06/4500411066/"&gt;&lt;img alt="UML Leaky Model" src="http://farm5.static.flickr.com/4023/4500411066_6fa2472542_b.jpg" width="250" height="1024" /&gt;&lt;/a&gt; &lt;p&gt;On the left hand side, the Application object has a reference to a ViewModel class (the long line), which has a reference to the results of a service query. The ViewModel has subscribed to the CollectionChanged event on a collection exposed by the ServiceQueryResponse class.&lt;/p&gt;&lt;p&gt;Should the ViewModel reference be replaced or nulled in the application (the long line), then the entire object graph will become orphaned; an island to which no references tracks back to any executing code.&lt;/p&gt;&lt;p&gt;&lt;p&gt;Thus, the GC will clean it up.&lt;/p&gt;However, on the right, Application references an 'Other' object - perhaps a service proxy manager which caches the last query - which goes on to reference ServiceQueryResponse.&lt;/p&gt;&lt;p&gt;If the ViewModel reference held by the Application object is nulled, then the ViewModel will &lt;em&gt;not&lt;/em&gt; be collected due to the Target reference(s) in the delegates held by the CollectionChanged event.&lt;/p&gt;&lt;p&gt;Of course, if the Application object nulls out its reference to Other, then the whole lot will be collected and the heavyweight ViewModel will free its resources.&lt;/p&gt;&lt;p&gt;This is why I said that close-knit models, its not such a problem. If the events and references are all in a self-contained class or private unit of functionality, its likely that it will become an island.&lt;/p&gt;&lt;p&gt;Just writing this post has actually highlighted an issue I have with caching; my cache doesn't self clear, rather it replaces, so stuff can sit around for ages. And I cannot say for sure what chain of references the cached objects will be maintaining.&lt;/p&gt;&lt;p&gt;The blog post  &lt;a title="SQL Team Blog link" href="http://weblogs.sqlteam.com/mladenp/archive/2007/10/24/C-Care-about-Event-Memory-Leaks-with-Delegate.GetInvocationList.aspx"&gt;here&lt;/a&gt; is helpful in that the author attempts to solve the perceived problem (that doesn't exist) - read the comments.&lt;/p&gt;&lt;p&gt;And similarly on StackOverflow &lt;a title="Link to StackOverflow" href="http://stackoverflow.com/questions/2533017/c-how-to-unsubscribe-all-event-handlers-from-a-given-event/2568340#2568340"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-8460390559406603693?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/8460390559406603693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/04/note-to-self-events-mostly-don-leak.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8460390559406603693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8460390559406603693'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/04/note-to-self-events-mostly-don-leak.html' title='Note to self: Events Mostly Don&amp;#39;t Leak Memory'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm5.static.flickr.com/4072/4500411432_53f2d0ff00_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-1153381626239402464</id><published>2010-03-29T07:20:00.001-07:00</published><updated>2010-03-29T07:20:25.904-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><title type='text'>The History of the Internet</title><content type='html'>&lt;p&gt;&lt;strong&gt;While looking at a site listing some wonderful animated infographics, I came across Melih Bilgil's fabulous short film and thought it worthy of a post all to itself.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I tagged it with User Experience as the representations of the consituents and their interactions and transitions are inspiring communications.&lt;/p&gt;&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/d3VccCRiP98&amp;amp;hl=en_GB&amp;amp;fs=1&amp;amp;rel=0&amp;amp;color1=0xcc2550&amp;amp;color2=0xe87a9f"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/d3VccCRiP98&amp;amp;hl=en_GB&amp;amp;fs=1&amp;amp;rel=0&amp;amp;color1=0xcc2550&amp;amp;color2=0xe87a9f" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-1153381626239402464?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/1153381626239402464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/03/history-of-internet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1153381626239402464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1153381626239402464'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/03/history-of-internet.html' title='The History of the Internet'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-1609071013967963871</id><published>2010-03-23T04:52:00.001-07:00</published><updated>2010-03-23T04:52:06.952-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='aspnet'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Note to self: Web Page Performance Optimization - Notes from MIX10</title><content type='html'>&lt;p&gt;&lt;strong&gt;My personal notes from Jason Weber's session at MIX10. Essentially just a bulleted list of the 20 or so recommendations he made.&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; 	&lt;li&gt;Compress HTTP but never images.&lt;/li&gt; 	&lt;li&gt;Provide cachable content with future expiry date.&lt;/li&gt; 	&lt;li&gt;Use conditional requests, GET if modified since.&lt;/li&gt; 	&lt;li&gt;Minify JavaScript; can reduce by 25%.&lt;/li&gt; 	&lt;li&gt;Don't scale images, resample them.&lt;/li&gt; 	&lt;li&gt;Use image sprites.&lt;/li&gt; 	&lt;li&gt;Avoid inline JavaScript.&lt;/li&gt; 	&lt;li&gt;Linking JavaScript in head prevents HTML render, or use defer="defer"&lt;/li&gt; 	&lt;li&gt;Avoid embedded styles.&lt;/li&gt; 	&lt;li&gt;Only send styles actually required by the page - server side plug-ins can automate this.&lt;/li&gt; 	&lt;li&gt;Link CSS at top in head.&lt;/li&gt; 	&lt;li&gt;Avoid using @import for hierarchical styles, place them in HTML head.&lt;/li&gt; 	&lt;li&gt;Minimize symbol resolution, cache in method body. Functions also; create function pointers in local method.&lt;/li&gt; 	&lt;li&gt;Use JSON native methods if available.&lt;/li&gt; 	&lt;li&gt;Remove duplicate script file declarations.&lt;/li&gt; 	&lt;li&gt;Minimize DOM interactions, cache references.&lt;/li&gt; 	&lt;li&gt;Built-in DOM methods are always faster.&lt;/li&gt; 	&lt;li&gt;Use selector APIs.&lt;/li&gt; 	&lt;li&gt;Complex element selectors are slow; favor class selectors and child instead of descendant.&lt;/li&gt; 	&lt;li&gt;Apply visual changes in batches.&lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-1609071013967963871?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/1609071013967963871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/03/note-to-self-web-page-performance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1609071013967963871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1609071013967963871'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/03/note-to-self-web-page-performance.html' title='Note to self: Web Page Performance Optimization - Notes from MIX10'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7158686232152678587</id><published>2010-03-04T06:39:00.001-08:00</published><updated>2010-03-04T06:39:42.997-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>WPF Font Rendering Side-by-side</title><content type='html'>&lt;p&gt;&lt;strong&gt;Text rendering in Windows Presentation Framework has been a moot point since its release. Microsoft are responding to this and in WPF 4.0 text rendering will be performed by DirectWrite, some new bit of DirectX. But still, while working on reproducing a mockup done in Corel PHOTO-PAINT, I wanted to get to the bottom of why I am never happy with WPFs rendition and whether I am just imagining the whole thing.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;My original mock-up was done in Corel's Photoshop equivalent at a very high resolution and then I view it in a normal viewer like Windows Live Photo Gallery and zoom it down to the right size.&lt;/p&gt; &lt;p&gt;I then compare my WPF work with the mockup PNG side-by-side and usually squint and shake my head alot.&lt;/p&gt;&lt;p&gt;So I created the same thing in CorelDRAW and Microsoft Word, giving me a total of 4 versions of the same mockup. Here's what I discovered.&lt;/p&gt; &lt;a title="Font Render Side-by-side by lukepuplett, on Flickr" href="http://www.flickr.com/photos/22787790@N06/4405392856/"&gt;&lt;img alt="Font Render Side-by-side" src="http://farm3.static.flickr.com/2735/4405392856_5ca259162f_o.png" width="300" height="425" /&gt;&lt;/a&gt;&lt;p&gt;For me, Corel's versions are the nicest. I just like them more, in the way that I prefer one woman's face over another. It's subtle and innate.&lt;/p&gt;&lt;p&gt;Philosophy aside, the WPF version and the Corel could easily be mistaken for different typefaces. They're both Swiss 721 Lt BT. Here's my analysis:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Corel renders the O under the T, probably because it doesn't need to consider text selection. This is it primary advantage.&lt;/li&gt;&lt;li&gt;Corel apps and Word seem to render the lowercase glyphs slightly larger (1px) so that there is less of a difference in height to the uppercase T.&lt;/li&gt;&lt;li&gt;The top right end of the s in WPF sinks down, caused by confused anti-aliasing.&lt;/li&gt;&lt;li&gt;Word uses coloured anti-aliasing, blue on one side of the T and red on the other - the others do not.&lt;/li&gt;&lt;li&gt;WPF renders the thickest, most woolly lines.&lt;/li&gt;&lt;li&gt;WPF also renders the horizontal bar in e lower than the others, probably because it is slightly smaller and the bar snapped down a pixel.&lt;/li&gt;&lt;/ul&gt;&lt;a title="Font Render Side-by-side Zoomed by lukepuplett, on Flickr" href="http://www.flickr.com/photos/22787790@N06/4405392788/"&gt;&lt;img alt="Font Render Side-by-side Zoomed" src="http://farm3.static.flickr.com/2768/4405392788_8c0783c389_o.png" width="900" height="1275" /&gt;&lt;/a&gt;&lt;p&gt;As far as I see it, the fact that Microsoft Word can render the text quite accurately, the issue is not solely about ClearType but something inherent in WPF. It's a shame that text cannot be tuned per XAML element with varying amounts of anti-aliasing instead of on/off.&lt;/p&gt;&lt;p&gt;I hope they work it out in 4.0.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7158686232152678587?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7158686232152678587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/03/wpf-font-rendering-side-by-side.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7158686232152678587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7158686232152678587'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/03/wpf-font-rendering-side-by-side.html' title='WPF Font Rendering Side-by-side'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-8565174858242042226</id><published>2010-02-26T05:37:00.001-08:00</published><updated>2010-03-01T07:14:31.715-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='touch'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Luke's Ridiculously Simple MVVM Table Grid</title><content type='html'>&lt;p&gt;&lt;strong&gt;Windows Phone 7 Series extends the panning and scrolling UI metaphors seen in Windows Media Center and apparently in the Zune. This is no surprise as they are consumer entertainment products, or at least two are and the phone has been remarketed.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Anyway, to experiment with this style of interface, which lends itself so well to touch, I realised that I need a kind of table that can slide left and right, scroll up and down, be extended dynamically and do all this from a control-agnostic view model. Welcome to my ridiculously simple custom control.&lt;/strong&gt;&lt;/p&gt;&lt;h4&gt;Reductionism&lt;/h4&gt;&lt;p&gt;When thinking about designing a user interface one must adopt a reductionist mentality. Each consituent part of a UI needs breaking down into units of functionality and within each one, there are usually more units of functionality until a reusable control is arrived at. And then there's that control's constituents which are usually a small number of stock WPF controls.&lt;/p&gt;&lt;p&gt;This idea comes quite easily to an object oriented programmer because its pretty much the same thought process as for designing classes of logic.&lt;/p&gt;&lt;p&gt;To be useable from a ViewModel that is not aware of the control, perhaps because the assembly that the view model is in doesn't reference the library of custom controls, it must support data binding using CLR base types.&lt;/p&gt;&lt;p&gt;A table is a bunch of bunches of stuff and at the time of writing, there's only one bunch of stuff class that supports databinding and that's the ObservableCollection&amp;lt;T&amp;gt;.&lt;/p&gt;&lt;p&gt;The Phone 7 interface scrolls sideways between 'pages' of contextual content either by gesture or with a click of a 'column' header - itself in its own slider.&lt;/p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/S4fOmzbkUFI/AAAAAAAAAEI/v3YffcvalrA/s1600-h/500x_xboxlivephone%5B5%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="500x_xboxlivephone" border="0" alt="500x_xboxlivephone" src="http://lh6.ggpht.com/_nweCidX3nlI/S4fOneGlB9I/AAAAAAAAAEM/BMwrakUMOx0/500x_xboxlivephone_thumb%5B3%5D.jpg?imgmax=800" width="613" height="284" /&gt;&lt;/a&gt; &lt;p&gt;Each page scrolls as a normal page, with autohide scrollbars like the iPhone. The simplest logical representation of this logic - remember controls are just logic - is a horizontal StackPanel of ListBox controls.&lt;/p&gt;&lt;p&gt;That harmoniously translates into CLR land as an ObservableCollection of ObservableCollection objects. Nice.&lt;/p&gt;&lt;p&gt;To allow of column headings, I'm going to wedge a KeyValuePair in there, where K is a string and V is the ObservableCollection&amp;lt;object&amp;gt;&lt;/p&gt;&lt;h4&gt;Code&lt;/h4&gt;&lt;p&gt;Here's the full code the control. I'll explain some of the few remarkable points after. However there is a &lt;strong&gt;bug&lt;/strong&gt; bug in this quick attempt: DataBinding doesn't call the setter and so doesn't set the CollectionChanged handler, which is why it works in my non-bound example.&lt;/p&gt;&lt;p&gt;The solution is to add/remove the handlers for this event in the OnTableSourceChanged handler, but I'm sure most of you can work this out. Is that lazy? Sorry but editting formatted code in the published article is a nightmare.&lt;/p&gt;&lt;div style="font-family: courier new"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;namespace&lt;/span&gt; WpfSimpleTableControl &lt;br /&gt;{ &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;using&lt;/span&gt; System.Collections.Generic; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;using&lt;/span&gt; System.Collections.ObjectModel; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;using&lt;/span&gt; System.Windows; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;using&lt;/span&gt; System.Windows.Controls; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// A StackPanel of ListBoxes where each ListBox represents a column of data which can be databound.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;remarks&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// DataBinding works by mirroring the StackPanel of ListBoxes with an ObservableCollection of ObservableCollections.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;/remarks&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;class&lt;/span&gt; SimpleTable : StackPanel &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#region&lt;/span&gt; Constructors &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;static&lt;/span&gt; SimpleTable() &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DefaultStyleKeyProperty.OverrideMetadata(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(SimpleTable), &lt;span style="color: blue"&gt;new&lt;/span&gt; FrameworkPropertyMetadata(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(SimpleTable))); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#endregion&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#region&lt;/span&gt; Properties &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#region&lt;/span&gt; Dependency Properties &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, ObservableCollection&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt; TableSource &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; (ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, ObservableCollection&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;)GetValue(TableSourceProperty); } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;set&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var oldValue = &lt;span style="color: blue"&gt;this&lt;/span&gt;.TableSource; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (oldValue != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; oldValue.CollectionChanged -= &lt;span style="color: blue"&gt;new&lt;/span&gt; System.Collections.Specialized.NotifyCollectionChangedEventHandler(table_CollectionChanged); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value.CollectionChanged += &lt;span style="color: blue"&gt;new&lt;/span&gt; System.Collections.Specialized.NotifyCollectionChangedEventHandler(table_CollectionChanged); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetValue(TableSourceProperty, value); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;readonly&lt;/span&gt; DependencyProperty TableSourceProperty = DependencyProperty.Register( &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: maroon"&gt;&amp;quot;TableSource&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, ObservableCollection&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(SimpleTable), &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;new&lt;/span&gt; PropertyMetadata( &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;new&lt;/span&gt; PropertyChangedCallback(OnTableSourceChanged))); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; Style ListBoxStyle &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; (Style)GetValue(ListBoxStyleProperty); } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;set&lt;/span&gt; { SetValue(ListBoxStyleProperty, value); } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;readonly&lt;/span&gt; DependencyProperty ListBoxStyleProperty = &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DependencyProperty.Register(&lt;span style="color: maroon"&gt;&amp;quot;ListBoxStyle&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(Style), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(SimpleTable), &lt;span style="color: blue"&gt;new&lt;/span&gt; UIPropertyMetadata(&lt;span style="color: blue"&gt;null&lt;/span&gt;)); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; DataTemplate ItemDataTemplate &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; (DataTemplate)GetValue(ItemDataTemplateProperty); } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;set&lt;/span&gt; { SetValue(ItemDataTemplateProperty, value); } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;readonly&lt;/span&gt; DependencyProperty ItemDataTemplateProperty = &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DependencyProperty.Register(&lt;span style="color: maroon"&gt;&amp;quot;ItemDataTemplate&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(DataTemplate), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(SimpleTable), &lt;span style="color: blue"&gt;new&lt;/span&gt; UIPropertyMetadata(&lt;span style="color: blue"&gt;null&lt;/span&gt;)); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#endregion&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#endregion&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#region&lt;/span&gt; Methods &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; ReinitializeTableSource(ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, ObservableCollection&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt; table) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Detach handlers and clear.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;foreach&lt;/span&gt;(ListBox l &lt;span style="color: blue"&gt;in&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;this&lt;/span&gt;.Children) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; l.LostFocus -= &lt;span style="color: blue"&gt;new&lt;/span&gt; RoutedEventHandler(listBox_LostFocus); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Children.Clear(); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (table == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (var columnList &lt;span style="color: blue"&gt;in&lt;/span&gt; table) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; columnName = columnList.Key; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var listBox = &lt;span style="color: blue"&gt;new&lt;/span&gt; ListBox(); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listBox.LostFocus += &lt;span style="color: blue"&gt;new&lt;/span&gt; RoutedEventHandler(listBox_LostFocus); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;this&lt;/span&gt;.ItemDataTemplate != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listBox.ItemTemplate = &lt;span style="color: blue"&gt;this&lt;/span&gt;.ItemDataTemplate; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;this&lt;/span&gt;.ListBoxStyle != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listBox.Style = &lt;span style="color: blue"&gt;this&lt;/span&gt;.ListBoxStyle; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listBox.ItemsSource = columnList.Value; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Children.Add(listBox); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; listBox_LostFocus(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, RoutedEventArgs e) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var listBox = (ListBox)sender; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listBox.SelectedItem = &lt;span style="color: blue"&gt;null&lt;/span&gt;; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; table_CollectionChanged(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ReinitializeTableSource((ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, ObservableCollection&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;)sender); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// Reads properties and fires off the state changer using VSM.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: gray"&gt;/// &amp;lt;param name=&amp;quot;useTransitions&amp;quot;&amp;gt;Whether to trigger animations between the states.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; UpdateStates(&lt;span style="color: blue"&gt;bool&lt;/span&gt; useTransitions) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//if (this.IsFocused)&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&amp;#160;&amp;#160;&amp;#160; VisualStateManager.GoToState(this, Ticker.FocusedStateName, useTransitions);&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//else&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&amp;#160;&amp;#160;&amp;#160; VisualStateManager.GoToState(this, Ticker.UnfocusedStateName, useTransitions);&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; OnTableSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var newTable = (ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, ObservableCollection&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;)args.NewValue; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var control = (SimpleTable)sender; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; control.ReinitializeTableSource(newTable); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#endregion&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#region&lt;/span&gt; Control Overrides &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;override&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; OnApplyTemplate() &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;base&lt;/span&gt;.OnApplyTemplate(); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Grab named ControlTemplate assets and stick em in properties.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//this.ScrollViewerElement = GetTemplateChild(SimpleTable.ScrollViewerPartName) as ScrollViewer;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.UpdateStates(&lt;span style="color: maroon"&gt;false&lt;/span&gt;); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;#endregion&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;} &lt;br /&gt;&lt;/div&gt;&lt;p&gt;Starting at the top, it has no parts. This is because it derives from StackPanel and so it is just itself. It's just a panel.&lt;/p&gt;&lt;p&gt;Moving down the code, there are three DependencyProperty members. The first is the DataTable property which is typed as ObservableCollection&amp;lt;KeyValuePair&amp;lt;string, ObservableCollection&amp;lt;object&amp;gt;&amp;gt;&amp;gt;, the second is ListBoxStyle which accepts a Style object which allows such things as removing the default black border around each element and then there's ItemDataTemplate which is a DataTemplate to apply to each of the listboxes.&lt;/p&gt;&lt;p&gt;It's likely that each ListBox will need its own different DataTemplate but it would be quite trivial to add a property that takes a DataTemplateSelector which can use your own logic to work out which DataTemplate to apply to which items.&lt;/p&gt;&lt;p&gt;The next interesting thing is the ReinitializeTableSource method. This kicks out all the old ListBox instances in the panel (itself) and then adds new ones. It copies over the ItemDataTemplate and ListBoxStyle to each new ListBox and also hooks up the data binding to each collection that represents column data.&lt;/p&gt;&lt;p&gt;It also sets an event handler for the lostfocus event which simply removes the selection, otherwise each independant listbox will have its own selection highlight. There might be situations when this is useful, but not today.&lt;/p&gt;&lt;p&gt;Further down there's the handler for the main outer collection CollectionChanged event which can only really occur when columns are added or removed and triggers the whole thing to be reconfigured.&lt;/p&gt;&lt;p&gt;OnTableSourceChanged handles changes to the TableSource dependency property which could itself be bound, this also trigger a complete reconfig.&lt;/p&gt;&lt;p&gt;The rest is left over from the parts and states model and can support the VisualStateManager paradigm.&lt;/p&gt;&lt;h4&gt;Basic Model&lt;/h4&gt;&lt;p&gt;The most simple use of the control looks like this.&lt;/p&gt;&lt;a href="http://lh6.ggpht.com/_nweCidX3nlI/S4fOoFZus8I/AAAAAAAAAEQ/RYkMW__HuLY/s1600-h/SimpleTable%20UI%5B7%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SimpleTable UI" border="0" alt="SimpleTable UI" src="http://lh6.ggpht.com/_nweCidX3nlI/S4fOogxgbmI/AAAAAAAAAEU/c6Ld12tGBSI/SimpleTable%20UI_thumb%5B5%5D.jpg?imgmax=800" width="448" height="329" /&gt;&lt;/a&gt; &lt;p&gt;The two buttons manipulate a window level private collection of collections which is communicated via the magic of data binding to the table on screen.&lt;/p&gt;&lt;p&gt;The XAML for the window is here:&lt;/p&gt;&lt;pre&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Window&lt;/span&gt; &lt;span style=' color: Red;'&gt;x:Class&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;WpfSimpleTableControl.MainWindow&lt;/span&gt;"&lt;br /&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;br /&gt;&lt;span style=' color: Red;'&gt;xmlns:x&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/span&gt;"&lt;br /&gt;&lt;span style=' color: Red;'&gt;xmlns:local&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;clr-namespace:WpfSimpleTableControl&lt;/span&gt;"&lt;br /&gt;&lt;span style=' color: Red;'&gt;Title&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;MainWindow&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Height&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;350&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Width&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;525&lt;/span&gt;"&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Grid&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;StackPanel&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;local:SimpleTable&lt;/span&gt; &lt;span style=' color: Red;'&gt;x:Name&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;SimpleTable&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Margin&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;20&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Orientation&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;Horizontal&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Height&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;200&lt;/span&gt;"&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;local:SimpleTable.ListBoxStyle&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Style&lt;/span&gt; &lt;span style=' color: Red;'&gt;TargetType&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;{x:Type ListBox}&lt;/span&gt;"&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Setter&lt;/span&gt; &lt;span style=' color: Red;'&gt;Property&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;BorderThickness&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Value&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0&lt;/span&gt;" /&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Setter&lt;/span&gt; &lt;span style=' color: Red;'&gt;Property&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;Width&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Value&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;150&lt;/span&gt;" /&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Style&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;local:SimpleTable.ListBoxStyle&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;local:SimpleTable&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Button&lt;/span&gt; &lt;span style=' color: Red;'&gt;Width&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;150&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Click&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;Button_Click&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Margin&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;2&lt;/span&gt;"&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;Add to column 2&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Button&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Button&lt;/span&gt; &lt;span style=' color: Red;'&gt;Width&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;150&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Click&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;Button_Click&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Margin&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;2&lt;/span&gt;"&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;Add new column&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Button&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;StackPanel&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Grid&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Window&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;And the codebehind, which does not use MVVM for this simple demo, goes like this.&lt;/p&gt;&lt;div style='font-family: Courier New;'&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Collections.Generic; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Linq; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Text; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Controls; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Data; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Documents; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Input; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Media; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Media.Imaging; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Navigation; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Shapes; &lt;br /&gt;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Collections.ObjectModel; &lt;br /&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;namespace&lt;/span&gt;&amp;nbsp;WpfSimpleTableControl &lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Interaction&amp;nbsp;logic&amp;nbsp;for&amp;nbsp;MainWindow.xaml&lt;/span&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;class&lt;/span&gt;&amp;nbsp;MainWindow&amp;nbsp;:&amp;nbsp;Window &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;private&lt;/span&gt;&amp;nbsp;ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;,&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;_table&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;ObservableCollection&amp;lt;KeyValuePair&amp;lt;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;,&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;gt;(); &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;MainWindow() &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Initialized&amp;nbsp;+=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;EventHandler(MainWindow_Initialized); &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;void&lt;/span&gt;&amp;nbsp;MainWindow_Initialized(&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;EventArgs&amp;nbsp;e) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;list&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.Add(&lt;span style=' color: Maroon;'&gt;"Hello"&lt;/span&gt;); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.Add(&lt;span style=' color: Maroon;'&gt;"...world!"&lt;/span&gt;); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_table.Add(&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyValuePair&amp;lt;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;,&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style=' color: Maroon;'&gt;"Column1"&lt;/span&gt;,&amp;nbsp;list)); &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.Add(&lt;span style=' color: Maroon;'&gt;"Latika!"&lt;/span&gt;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_table.Add(&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyValuePair&amp;lt;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;,&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style=' color: Maroon;'&gt;"Column2"&lt;/span&gt;,&amp;nbsp;list)); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.SimpleTable.TableSource&amp;nbsp;=&amp;nbsp;_table; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Green;'&gt;//this.SimpleTable.Background&amp;nbsp;=&amp;nbsp;Brushes.Gray;&lt;/span&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;void&lt;/span&gt;&amp;nbsp;Button_Click(&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;RoutedEventArgs&amp;nbsp;e) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;b&amp;nbsp;=&amp;nbsp;(Button)sender; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;switch&lt;/span&gt;&amp;nbsp;(b.Content.ToString()) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;case&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;"Add&amp;nbsp;to&amp;nbsp;column&amp;nbsp;2"&lt;/span&gt;: &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_table[&lt;span style=' color: Maroon;'&gt;1&lt;/span&gt;].Value.Add(DateTime.Now.Millisecond&amp;nbsp;+&amp;nbsp;b.Content.ToString()); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;break&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;case&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;"Add&amp;nbsp;new&amp;nbsp;column"&lt;/span&gt;: &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_table.Add(&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyValuePair&amp;lt;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;,ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;&amp;gt;(&lt;span style=' color: Maroon;'&gt;"New&amp;nbsp;Column"&lt;/span&gt;,&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;ObservableCollection&amp;lt;&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;gt;())); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_table.Last().Value.Add(&lt;span style=' color: Maroon;'&gt;"Default&amp;nbsp;item."&lt;/span&gt;); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;break&lt;/span&gt;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br /&gt;} &lt;br /&gt;&lt;/div&gt;&lt;p&gt;And with MVVM would really just be a binding in the XAML to a ObservableCollection&amp;lt;KeyValuePair&amp;lt;string, ObservableCollection&amp;lt;object&amp;gt;&amp;gt;&amp;gt; typed property on the ViewModel class.&lt;/p&gt;&lt;p&gt;Because this was designed with MVVM in mind, the clicking of items is not considered in the panel. Usually, the DataTemplate for the item binds a Command to a property on the item's ViewModel and so actions go direct.&lt;/p&gt;&lt;p&gt;I will return when I have made it look nice, added a DataTemplate and probably after discovering some minor nuance which completely trounces the whole thing's feasiblity and makes me look a tit.&lt;/p&gt;&lt;p&gt;Hopefully not though, maybe sometimes WPF can be simple. Maybe.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-8565174858242042226?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/8565174858242042226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/02/luke-ridiculously-simple-mvvm-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8565174858242042226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8565174858242042226'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/02/luke-ridiculously-simple-mvvm-table.html' title='Luke&amp;#39;s Ridiculously Simple MVVM Table Grid'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nweCidX3nlI/S4fOneGlB9I/AAAAAAAAAEM/BMwrakUMOx0/s72-c/500x_xboxlivephone_thumb%5B3%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6377882071745207358</id><published>2010-02-17T04:34:00.001-08:00</published><updated>2010-02-17T04:34:30.104-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><title type='text'>Empty DataContract Causes Misleading Error</title><content type='html'>&lt;p&gt;&lt;strong&gt;After my last &lt;a title="Emtpy DataContract Breaks Type Reuse" href="http://www.lukepuplett.com/2009/05/empty-datacontract-breaks-type-reuse.html"&gt;post&lt;/a&gt; on this subject you'd have thought I'd learnt a lesson but the error message and sheer coincidence of the error being about a class I happened to be working on at the time meant it took me 10 hours to unearth the problem.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;After updating a service reference that had been left for some months, I received the following IDE warning:&lt;/p&gt;&lt;p&gt;&lt;em&gt;Custom tool warning: Cannot import wsdl:portType&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Error: Referenced type 'Steelcore.Spanware.QueryBlock, Steelcore.Spanware, Version=2.0.1.0, Culture=neutral, PublicKeyToken=80726da9f797f65e' with data contract name 'QueryBlock' in namespace 'http://schemas.evoq.co.uk/steelcore/2009/03/spanware' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Because I had just been adding new web methods that use QueryBlock, and because I am working in Visual Studio 2010 RC1 it was difficult to know if this was a genuine error, afterall, I'd not changed the Steelcore code for ages and it used to work.&lt;/p&gt;&lt;h4&gt;Troubleshooting&lt;/h4&gt;&lt;p&gt;I'll spare you the details on all the stuff I tried that didn't work. Getting to the bottom of it was a case of isolation.&lt;/p&gt;&lt;p&gt;To remove the local client project from the equation I created a new WCF Service app in Visual Studio, added the reference to my Steelcore library and configured the service with one web method/operation contract that takes the offending class QueryBlock as its sole argument. I then created a new client app, referenced Steelcore and the WCF service. This caused the same warning.&lt;/p&gt;&lt;p&gt;I then opened the Steelcore solution and commented out some of the DataMember attributes on the QueryBlock and rebuilt. Went back to my little test rig and rebuilt and updated the service references. Warning gone.&lt;/p&gt;&lt;p&gt;Obviously one of the types used in the now defunct DataMembers is causing the issue, probably my LooseTypedCriteria class, so I changed the WCF service to accept one of these as its sole argument and found the warning from SvcUtil was talking about Steelcore.Spanware.Criteria.&lt;/p&gt;&lt;p&gt;I commented out some of the DataMembers on Criteria and repeated the process. It all referenced fine, and so again, one of those members is using a class that SvcUtil doesn't like. I noticed one was an enum and then I recalled my enum DataContract problems.&lt;/p&gt;&lt;h4&gt;Solution&lt;/h4&gt;&lt;p&gt;Sure enough this enum had a DataContract but no DataMember attributes applied. This makes it effectively empty. As before, the solution was to remove the DataContract and let .NET figure out the contract automatically.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6377882071745207358?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6377882071745207358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/02/empty-datacontract-causes-misleading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6377882071745207358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6377882071745207358'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/02/empty-datacontract-causes-misleading.html' title='Empty DataContract Causes Misleading Error'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6928164599783434720</id><published>2010-02-12T04:56:00.001-08:00</published><updated>2010-02-12T04:58:06.222-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Generic Range&lt;T&gt; class</title><content type='html'>&lt;strong&gt;Here is my Range class used a project dealing heavily with time slots. A skinny post this as its in response to a request for example generic types from a discussion on LinkedIn.&lt;/strong&gt; &lt;p&gt;Sorry about line wrapping.&lt;/p&gt;&lt;div style='font-family: Courier New;'&gt;&lt;BR /&gt;&lt;span style=' color: Blue;'&gt;namespace&lt;/span&gt;&amp;nbsp;RootNs.ExampleCorp.Core &lt;BR /&gt;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;using&lt;/span&gt;&amp;nbsp;System.Runtime.Serialization; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Represents&amp;nbsp;a&amp;nbsp;range&amp;nbsp;of&amp;nbsp;some&amp;nbsp;data&amp;nbsp;type.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;typeparam&amp;nbsp;name="T"&amp;gt;The&amp;nbsp;type&amp;nbsp;of&amp;nbsp;data&amp;nbsp;such&amp;nbsp;as&amp;nbsp;DateTime.&amp;lt;/typeparam&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[DataContract(Namespace&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;"http://schemas.ExampleCorp.tv/2008/11/app/entities/core"&lt;/span&gt;)] &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;class&lt;/span&gt;&amp;nbsp;Range&amp;lt;T&amp;gt;&amp;nbsp;:&amp;nbsp;System.ComponentModel.INotifyPropertyChanged&amp;nbsp;where&amp;nbsp;T:&amp;nbsp;IComparable&amp;lt;T&amp;gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#region&lt;/span&gt;&amp;nbsp;Constructors &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;protected&lt;/span&gt;&amp;nbsp;Range()&amp;nbsp;{&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;Range(T&amp;nbsp;start,&amp;nbsp;T&amp;nbsp;stop) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_start&amp;nbsp;=&amp;nbsp;start;&amp;nbsp;_stop&amp;nbsp;=&amp;nbsp;stop; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#endregion&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#region&lt;/span&gt;&amp;nbsp;OnMethods &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Is&amp;nbsp;called&amp;nbsp;upon&amp;nbsp;any&amp;nbsp;property&amp;nbsp;change.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;param&amp;nbsp;name="e"&amp;gt;Args&amp;nbsp;passed&amp;nbsp;through&amp;nbsp;to&amp;nbsp;the&amp;nbsp;PropertyChanged&amp;nbsp;event.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;protected&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;virtual&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;void&lt;/span&gt;&amp;nbsp;OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs&amp;nbsp;e) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Green;'&gt;//&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Green;'&gt;//&amp;nbsp;Actually&amp;nbsp;nothing&amp;nbsp;here&amp;nbsp;-&amp;nbsp;this&amp;nbsp;is&amp;nbsp;more&amp;nbsp;for&amp;nbsp;derived&amp;nbsp;types&amp;nbsp;to&amp;nbsp;override.&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.RaisePropertyChanged(e); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Raises&amp;nbsp;the&amp;nbsp;PropertyChanged&amp;nbsp;event.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[System.Diagnostics.CodeAnalysis.SuppressMessage(&lt;span style=' color: Maroon;'&gt;"Microsoft.Design"&lt;/span&gt;,&amp;nbsp;&lt;span style=' color: Maroon;'&gt;"CA1030:UseEventsWhereAppropriate"&lt;/span&gt;)] &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;protected&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;void&lt;/span&gt;&amp;nbsp;RaisePropertyChanged(System.ComponentModel.PropertyChangedEventArgs&amp;nbsp;e) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.PropertyChanged&amp;nbsp;!=&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;)&amp;nbsp;{&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.PropertyChanged(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;,&amp;nbsp;e);&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#endregion&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#region&lt;/span&gt;&amp;nbsp;Properties &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[DataMember(Order&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;1&lt;/span&gt;)] &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;T&amp;nbsp;Start&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;get&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;_start; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;protected&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;internal&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;set&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_start&amp;nbsp;=&amp;nbsp;value; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.OnPropertyChanged(&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;System.ComponentModel.PropertyChangedEventArgs(&lt;span style=' color: Maroon;'&gt;"Start"&lt;/span&gt;)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;span style=' color: Blue;'&gt;private&lt;/span&gt;&amp;nbsp;T&amp;nbsp;_start; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[DataMember(Order&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;2&lt;/span&gt;)] &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;T&amp;nbsp;Stop &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;get&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;_stop; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;protected&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;internal&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;set&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_stop&amp;nbsp;=&amp;nbsp;value; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.OnPropertyChanged(&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;System.ComponentModel.PropertyChangedEventArgs(&lt;span style=' color: Maroon;'&gt;"Stop"&lt;/span&gt;)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;span style=' color: Blue;'&gt;private&lt;/span&gt;&amp;nbsp;T&amp;nbsp;_stop; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#endregion&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#region&lt;/span&gt;&amp;nbsp;Methods &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;IsOverlapping(Range&amp;lt;T&amp;gt;&amp;nbsp;range)&amp;nbsp;{&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.IsOverlapping(range.Start,&amp;nbsp;range.Stop);&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;IsOverlapping(T&amp;nbsp;start,&amp;nbsp;T&amp;nbsp;stop) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;((&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Start.CompareTo(stop)&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;0&lt;/span&gt;)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;(start.CompareTo(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Stop)&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;0&lt;/span&gt;)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;IsOverlapping(T&amp;nbsp;spot) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.IsEnveloping(spot); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;IsEnveloping(Range&amp;lt;T&amp;gt;&amp;nbsp;range)&amp;nbsp;{&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.IsEnveloping(range.Start,&amp;nbsp;range.Stop);&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;IsEnveloping(T&amp;nbsp;spot) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;((&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Start.CompareTo(spot)&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;0&lt;/span&gt;)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;spot.CompareTo(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Stop)&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;0&lt;/span&gt;); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;IsEnveloping(T&amp;nbsp;start,&amp;nbsp;T&amp;nbsp;stop) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;((&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Start.CompareTo(start)&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;0&lt;/span&gt;)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;(stop.CompareTo(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Stop)&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=' color: Maroon;'&gt;0&lt;/span&gt;)); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#endregion&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#region&lt;/span&gt;&amp;nbsp;INotifyPropertyChanged&amp;nbsp;Members &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;event&lt;/span&gt;&amp;nbsp;System.ComponentModel.PropertyChangedEventHandler&amp;nbsp;&amp;nbsp;PropertyChanged; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#endregion&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#region&lt;/span&gt;&amp;nbsp;Object&amp;nbsp;Overrides &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Returns&amp;nbsp;a&amp;nbsp;string&amp;nbsp;representation&amp;nbsp;of&amp;nbsp;the&amp;nbsp;object.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;override&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;&amp;nbsp;ToString() &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;String.Format(&lt;span style=' color: Maroon;'&gt;"{0}&amp;nbsp;-&amp;nbsp;{1}"&lt;/span&gt;,&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Start.ToString(),&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Stop.ToString()); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Compares&amp;nbsp;this&amp;nbsp;with&amp;nbsp;another&amp;nbsp;for&amp;nbsp;equality.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;override&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;Equals(&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;nbsp;obj) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(obj&amp;nbsp;==&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;)&amp;nbsp;{&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;false&lt;/span&gt;;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Range&amp;lt;T&amp;gt;&amp;nbsp;cast&amp;nbsp;=&amp;nbsp;obj&amp;nbsp;&lt;span style=' color: Blue;'&gt;as&lt;/span&gt;&amp;nbsp;Range&amp;lt;T&amp;gt;; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(cast&amp;nbsp;==&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;)&amp;nbsp;{&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;false&lt;/span&gt;;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Equals(cast); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;Compares&amp;nbsp;this&amp;nbsp;with&amp;nbsp;another&amp;nbsp;for&amp;nbsp;equality.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Gray;'&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;&amp;nbsp;Equals(Range&amp;lt;T&amp;gt;&amp;nbsp;comparison) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(comparison&amp;nbsp;==&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;)&amp;nbsp;{&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Maroon;'&gt;false&lt;/span&gt;;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;(&lt;span style=' color: Blue;'&gt;bool&lt;/span&gt;)(comparison.ToString()&amp;nbsp;==&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.ToString()); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Green;'&gt;//&amp;nbsp;static&amp;nbsp;Equals(obj,&amp;nbsp;obj)&amp;nbsp;actually&amp;nbsp;calls&amp;nbsp;the&amp;nbsp;instance.Equals(obj)&amp;nbsp;anyway&amp;nbsp;so&amp;nbsp;no&amp;nbsp;need&amp;nbsp;to&amp;nbsp;implement.&lt;/span&gt; &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;override&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;int&lt;/span&gt;&amp;nbsp;GetHashCode() &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.ToString().GetHashCode(); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;#endregion&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;} &lt;BR /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6928164599783434720?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6928164599783434720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/02/generic-range-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6928164599783434720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6928164599783434720'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/02/generic-range-class.html' title='Generic Range&amp;lt;T&amp;gt; class'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6554041410471677021</id><published>2010-01-26T13:06:00.001-08:00</published><updated>2010-01-26T13:06:17.469-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Luke’s Guide to the ListBox Control</title><content type='html'>&lt;p&gt;&lt;strong&gt;This post is a copy (I'd cry if it got mauled) of the Community Content I added to the ListBox MSDN &lt;a title="Links to MSDN article." href="http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx"&gt;article&lt;/a&gt; explaining its highly complex model.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Every time I go to sleep I forget this, may I say, overly complicated beast of a control. Here's some community content that might help programmers of a similar disposition.&lt;/p&gt;  &lt;p&gt;Right, a ListBox is a bunch of behaviours over the top of an ItemsControl which is essentially a controller for items in a Panel.&lt;/p&gt;  &lt;p&gt;It's useful to consider its template which consists of a Border, a ScrollViewer (of which the ScrollViewer has a ScrollContentPresenter) and an ItemsPresenter.&lt;/p&gt;  &lt;p&gt;This Panel can be changed via ItemsControl.ItemsPanel but could also be specified in the control template by adding your chosen Panel and setting its IsItemsHost=true which will hook it up to the ItemsControl/ListBox.&lt;/p&gt;  &lt;p&gt;The ItemsControl's job is to generate the items according to customizable templates using an ItemContainerGenerator. For a ListBox, this makes ListBoxItem instances which are ContentControls and thus have ContentPresenters in their templates. Their look is affected using...&lt;/p&gt;  &lt;p&gt;ItemTemplate. Simple except that it should not be used in conjunction with ItemTemplateSelector (which sets a DataTemplateSelector class that returns a DataTemplate when its SelectTemplate method is call and so you can add some kind of logic to determine which one to return).&lt;/p&gt;  &lt;p&gt;And we're not done yet because there's also ItemContainerStyle and ItemContainerStyleSelector which do a similar job except that they style the container (ListBoxItem) around the item's actual rendered content (as defined by ItemTemplate).&lt;/p&gt;  &lt;p&gt;As for the look of the highlight, I guess that's done as part of the template applied to the item in reaction to ListBoxItem.IsSelected. Probably.&lt;/p&gt;  &lt;p&gt;[sigh] Whatever happened to HTML and CSS eh?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6554041410471677021?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6554041410471677021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/01/lukes-guide-to-listbox-control.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6554041410471677021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6554041410471677021'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/01/lukes-guide-to-listbox-control.html' title='Luke’s Guide to the ListBox Control'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-3120650391320217244</id><published>2010-01-23T11:34:00.001-08:00</published><updated>2010-01-24T04:27:34.924-08:00</updated><title type='text'>Blend 3.0 and VS 2010 :-(</title><content type='html'>&lt;p&gt;&lt;strong&gt;This post was written while I was discovering issues with Blend and VS 2010 Beta 2 and publiched in a rush (I’m on my way out but I want to get this out there). Look see, I haven’t even got the time to correct published.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;I’ve hastily posted this from a draft I was working on in Windows Live Writer (loving this app aside from the BR tags google seems to add) because I publicly moaned on Twitter about the fact that Blend and now VS 2010 had gotten slow under the weight of WPF – I ordered a 512Mb DDR3 video card yesterday to try and help it - and a guy named Noah Richards purportedly from the IDE Editor Team in Redmond had his bionic Twitter ears on and heard my wimpering. So I thought I’d publish the raw notes I’d been making for him to read…&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://twitter.com/lukepuplett"&gt;&lt;em&gt;lukepuplett&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a&gt;&lt;em&gt;&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;MS built VS2010 on super h/w so its slow for me. I must order a super card to run VS2010. Then I can make s/w my customers think is slow.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://twitter.com/noahsmark"&gt;&lt;em&gt;noahsmark&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a&gt;&lt;em&gt;&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;@&lt;/em&gt;&lt;a href="http://twitter.com/lukepuplett"&gt;&lt;em&gt;lukepuplett&lt;/em&gt;&lt;/a&gt;&lt;em&gt; My 1GB/single core VMs beg to differ – there are some people with beefy machines, but most are used for server08r2 + hyper-V. &lt;/em&gt;&lt;/p&gt;  &lt;h4&gt;Blend 3.0&lt;/h4&gt;  &lt;p&gt;Still no right click copy in code editor.&lt;/p&gt;  &lt;p&gt;Isolating controls to work on them is improved.&lt;/p&gt;  &lt;p&gt;I think about it all too much instead of getting on and using it.&lt;/p&gt;  &lt;p&gt;Don’t trust it not to screw my XAML up. Everything I do, I do tentatively, holding my breath waiting for it to explode. And this is learnt behaviour, for it crashes with such regularity.&lt;/p&gt;  &lt;p&gt;I found the sample data feature and read about it but within 20 clicks of using it I had broken it.&lt;/p&gt;  &lt;p&gt;InvalidCastException: Unable to cast object of type ‘_SampleData.v7.GuideSearchResultsSampleDataItemCollection’ to type ‘System.Windows.Data.CollectionView’&lt;/p&gt;  &lt;p&gt;Of course, the problem is that I don’t care for why this happened or to find out. I just want it to work and when it doesn’t, to tell me why or to prevent me making the action in the first place. And besides, I don’t know how to troubleshoot this because its not my code that’s throwing, its Blend’s magic sample data design-time wiring.&lt;/p&gt;  &lt;p&gt;Isn’t Blend aimed at creative people or do modern designers have to learn type theory??&lt;/p&gt;  &lt;p&gt;WPF is powerful because it leverages the .NET Framework. But Blend doesn’t work well enough to completely insulate the user from having to know and think in .NET.&lt;/p&gt;  &lt;p&gt;Our creative brain is on the right but our logical brain is on the left. As an artist I learned that we work our best when one or the other is dominating the processing.&lt;/p&gt;  &lt;p&gt;This page &lt;a title="http://www.viewzone.com/bicam.html" href="http://www.viewzone.com/bicam.html"&gt;http://www.viewzone.com/bicam.html&lt;/a&gt; features a nice table of the left and right brain functions.&lt;/p&gt;  &lt;p&gt;Blend doesn’t let my right brain dominate for long enough for me to flow.&lt;/p&gt;  &lt;p&gt;Traditionally web development uses a lot of sliced imagery. This is because drawing applications are typically reliable and easy to use and allow the designer to roam freely around her creative mind, playing. Then they cut the image up and sew it onto an HTML chassis and let a programmer merge it with some stuff from a database.&lt;/p&gt;  &lt;p&gt;Because its unenjoyable I wonder if it means designers may not refine apps as they find it too painful and think “That’ll do”. The World could end up with slightly worse software because the tools are painful. It’s like how the mobile internet only took off when Apple made the tool enjoyable (iPhone).&lt;/p&gt;  &lt;p&gt;In fact, if I’d started this project with XAML and its toolset, I’d have thrown in the towel within weeks. Maybe I’m not cut from UI devigner’s cloth.&lt;/p&gt;  &lt;p&gt;As for my problem with the sample data, I won’t use that ever again. I’ll go back to my way of doing it which was to design the component in another project and then cut and paste the XAML over.&lt;/p&gt;  &lt;h4&gt;Visual Studio 2010 Beta 2&lt;/h4&gt;  &lt;p&gt;Same problem as in VS 2010 with right-clicking highlighted text removes highlight while context menu is open.&lt;/p&gt;  &lt;p&gt;And VS 2010 editing is now painfully slow. This doesn’t surprise me as a WPF programmer because Windows Presentation Foundation is big.&lt;/p&gt;  &lt;p&gt;I’m sure I’m not alone in that my first thoughts with WPF were that such an enormously complicated object model must come at a price. Layers of objects with so many members and events flying both up and down a deep visual tree.&lt;/p&gt;  &lt;p&gt;Toolbar customization is a backward step. I cannot assign icons or edit tool buttons in place.&lt;/p&gt;  &lt;p&gt;Collapsible region highlighting distracts me and the +/- buttons aren’t perfectly lined up, making them take a nanosecond longer to use. Pasting collapsed methods, opens them.&lt;/p&gt;  &lt;p&gt;Scrolling doesn’t feel as fast. Parts of the screen don’t draw properly, sometimes the whole VS real-estate flickers on and off and I see my desktop for a brief moment.&lt;/p&gt;  &lt;p&gt;Switching between code editor/designer tabs takes ~1 second :(&lt;/p&gt;  &lt;p&gt;Mostly its not terrible but the difference that I feel the most is in the text editor, and of course that’s where I spend most of my time. The IntelliSense is a bit slower and it just tips it over to the wrong side of satisfactory.&lt;/p&gt;  &lt;p&gt;The hourglass fails to appear in many situations leaving me trying to click things and hovering over buttons to see if the window has frozen.&lt;/p&gt;  &lt;p&gt;Some resources failed to resolve, leaving the designer to miss rendering parts of my view. An error in the Error List indicated that an xmlns reference could not be resolved. I removed the reference below:&lt;/p&gt;  &lt;pre&gt;xmlns:SampleData=&amp;quot;&lt;span style="color: blue"&gt;clr-namespace:Expression.Blend.SampleData.GuideSearchResultsSampleDataSource&lt;/span&gt;&amp;quot;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And then I replaced the reference because I wanted to look further into the issue resolving that Expression reference but undoing my changes led to the issue being resolved. I reloaded the designer for my view and that too all worked, presumably because the resources had now built.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Incidentally, copying and pasting the text above from App.xaml to this blog entry resulted in the App.cs file unexpectedly opening – since uninstalling “Copy from Visual Studio for Windows Live Writer” this seems to have stopped happening.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Loading multiple-projects seems to be a bit faster and they’re sorted A-Z now. Builds seem a bit quicker, particularly if its dependencies were only just built.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And generally it is a nicer place to be that 2008. Visual Studio has been a wonderful piece of software since 2005 and wasn’t ever bad at all. I often wonder if I could ever get on using another major technology stack because I’d miss VS too much.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Remember I’ve posted this without checking it or removing google’s BRs. Here goes nothing.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-3120650391320217244?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/3120650391320217244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/01/blend-30-and-vs-2010.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3120650391320217244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3120650391320217244'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/01/blend-30-and-vs-2010.html' title='Blend 3.0 and VS 2010 :-('/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-5251607788161897484</id><published>2010-01-15T11:08:00.001-08:00</published><updated>2010-01-15T11:08:46.338-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Flowing Custom Control Values to ViewModel/Bindings</title><content type='html'>&lt;p&gt;&lt;strong&gt;This article discusses an issue I had when making a custom login box control, particularly the issue of getting the values in the username and password boxes to flow back down to the view-model. The issue might be my design, which could be fundamentally wrong, if only I knew of another way to do it.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The problem with Windows Presentation Foundation and its more promiscuous sister, Silverlight, is that its as good as it is bad. That is, its hard to deny its brilliance when you&amp;#39;re carving out complex drawings and alpha gradients, adding subtleties to button animations and then there&amp;#39;s the whole hardware accelerated 3D bit. But its bloody complicated because its mandate is to be everything to everyone and when so much is done for you all that stuff has to be massively multifaceted.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;My LoginControl uses the parts and states &lt;a href="http://scorbs.com/2008/06/11/parts-states-model-with-visualstatemanager-part-1-of/"&gt;model&lt;/a&gt; and the &lt;a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29117"&gt;WPFToolkit&lt;/a&gt; to get at the VisualStateManager. I won&amp;#39;t go into these things as they&amp;#39;re documented enough and Karen Corby has a great MIX session &lt;a href="http://videos.visitmix.com/MIX09/T16F"&gt;video&lt;/a&gt; on it, too.&lt;/p&gt;&lt;p&gt;So I have a few parts, two TextBox controls and a Button. You can guess that these are username, password and the logon button.&lt;/p&gt;&lt;p&gt;Firstly, and I'll get this one over and done with quickly: I don't use the PasswordBox control. It does not support data binding because it takes a cautious approach and does things securely. Instead I apply a strikethrough formatting to a regular TextBox within its default style in generic.xaml.&lt;/p&gt;&lt;p&gt;You can see how this is done by reading my comments at the bottom of the MSDN &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.passwordbox.aspx"&gt;article&lt;/a&gt; on the PasswordBox.&lt;/p&gt;&lt;h4&gt;Welcome to my LoginControl&lt;/h4&gt;&lt;p&gt;Cutting straight to the meat of the implementation, my control has the following properties:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;private TextBox UsernameTextBox // the property which stores the TextBox UI control part/element for the username&lt;/li&gt;&lt;li&gt;private TextBox PasswordTextBox // the property which stores the TextBox UI control part/element for the password&lt;/li&gt;&lt;li&gt;public string Username // the dependency property which stores the username that can be bound to from a view model&lt;/li&gt;&lt;li&gt;public string Password // ditto but for the password&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Because I can't bind my view model to a property of a the LoginControl's username TextBox and I don't want to expose the TextBox controls publicly, I use the following trick to hook up a binding between the TextBox.Text dependency property and LoginControl.Username (ditto for the password):&lt;/p&gt;&lt;div style='font-family: Courier New;'&gt;&lt;span style=' color: Blue;'&gt;private&lt;/span&gt;&amp;nbsp;TextBox&amp;nbsp;UsernameTextBox &lt;BR /&gt;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;get&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;&amp;nbsp;(TextBox)GetValue(UsernameTextBoxProperty); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;set&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Green;'&gt;//&amp;nbsp;Detach&amp;nbsp;observer&amp;nbsp;from&amp;nbsp;outgoing&amp;nbsp;value.&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Green;'&gt;//&lt;/span&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;oldValue&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.UsernameTextBox; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(oldValue&amp;nbsp;!=&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BindingOperations.ClearAllBindings(oldValue); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oldValue.GotKeyboardFocus&amp;nbsp;-=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyboardFocusChangedEventHandler(TextBoxes_GotKeyboardFocus); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oldValue.KeyUp&amp;nbsp;-=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyEventHandler(Username_KeyUp); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SetValue(UsernameTextBoxProperty,&amp;nbsp;value); &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(value&amp;nbsp;!=&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value.SetBinding(TextBox.TextProperty,&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;Binding(&lt;span style=' color: Maroon;'&gt;"Username"&lt;/span&gt;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Source&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;, &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Mode&amp;nbsp;=&amp;nbsp;BindingMode.TwoWay &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value.GotKeyboardFocus&amp;nbsp;+=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyboardFocusChangedEventHandler(TextBoxes_GotKeyboardFocus); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value.KeyUp&amp;nbsp;+=&amp;nbsp;&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyEventHandler(Username_KeyUp); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;}&lt;/div&gt;&lt;p&gt;And once that's done there's nothing else to consider except that when adding my LoginControl to my XAML page, I need to hook up the binding to the appropriate properties in the view model. That's easy:&lt;/p&gt; &lt;pre&gt;Username="&lt;span style=' color: Blue;'&gt;{Binding Path=Username, Mode=TwoWay}&lt;/span&gt;" Password="&lt;span style=' color: Blue;'&gt;{Binding Path=Password, Mode=TwoWay}&lt;/span&gt;"&lt;/pre&gt;&lt;p&gt;No worries there.&lt;/p&gt;&lt;h4&gt;In Practice it Fails&lt;/h4&gt;&lt;p&gt;The problem occurs when the login button is clicked and the ICommand is executed. The RelayCommand on the view model kicks in and my Action runs but if I stop the debugger right there I see that my view model does not have up-to-date Username and Password values!&lt;/p&gt;&lt;p&gt;My theory is that the binding system has not done its magic in between my typing of text and clicking of button. And although in theory the LostFocus events upon which data binding updates rely should have been triggered, my daisy-chained setup is somehow ballsing things up. Actually, there is a LostFocus on the username TextBox which should update the LoginControl.Username property, it doesn't, but even if it had, what's the activator to get the value to then jump from the Username property to its source down in my view model? By the way, flows up from source seem to work fine.&lt;/p&gt;&lt;p&gt;Whatever, I don't know. My solution was to grab each of my bindings and manually hit the UpdateSource method from within the login button's click method:&lt;/p&gt;&lt;div style='font-family: Courier New;'&gt;&lt;span style=' color: Blue;'&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=' color: Blue;'&gt;void&lt;/span&gt;&amp;nbsp;LoginButtonElement_Click(&lt;span style=' color: Blue;'&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;RoutedEventArgs&amp;nbsp;e) &lt;BR /&gt;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;utbx&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.UsernameTextBox.GetBindingExpression(TextBox.TextProperty); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;utbx.UpdateSource(); &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;ptbx&amp;nbsp;=&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.PasswordTextBox.GetBindingExpression(TextBox.TextProperty); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ptbx.UpdateSource(); &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;ubx&amp;nbsp;=&amp;nbsp;BindingOperations.GetBindingExpression(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;,&amp;nbsp;UsernameProperty); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;pbx&amp;nbsp;=&amp;nbsp;BindingOperations.GetBindingExpression(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;,&amp;nbsp;PasswordProperty); &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ubx.UpdateSource(); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pbx.UpdateSource(); &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.PasswordTextBox&amp;nbsp;!=&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(!&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.PasswordTextBox.IsFocused) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.PasswordTextBox.Focus(); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(!&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.TryLoginButton.IsMouseOver) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;return&lt;/span&gt;; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Command&amp;nbsp;!=&amp;nbsp;&lt;span style=' color: Blue;'&gt;null&lt;/span&gt;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Command.Execute(&lt;span style=' color: Blue;'&gt;new&lt;/span&gt;&amp;nbsp;KeyValuePair&amp;lt;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;,&amp;nbsp;&lt;span style=' color: Blue;'&gt;string&lt;/span&gt;&amp;gt;(&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Username,&amp;nbsp;&lt;span style=' color: Blue;'&gt;this&lt;/span&gt;.Password)); &lt;BR /&gt;}&lt;/div&gt;&lt;p&gt;Which brings me right back to the point I made earlier about not doing this the right way. I'm not sure any other way would flow the values in time anyway. But then there's always the question of how everyone else doesn't seem to have this problem...&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-5251607788161897484?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/5251607788161897484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/01/flowing-custom-control-values-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5251607788161897484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5251607788161897484'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/01/flowing-custom-control-values-to.html' title='Flowing Custom Control Values to ViewModel/Bindings'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6186915354318327826</id><published>2010-01-13T09:57:00.001-08:00</published><updated>2010-01-13T09:58:10.607-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Note to self: Turning a Path into a Resource in XAML</title><content type='html'>&lt;p&gt;&lt;strong&gt;Simple post mainly as a reminder to myself explaining how to make a complex path reusable because I keep forgetting this easy thing.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This goes in the asset resource dictionary.&lt;/p&gt; &lt;pre&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;PathGeometry&lt;/span&gt; &lt;span style=' color: Red;'&gt;x:Key&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;ArrowHeadPath&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Figures&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;M140.00002,39.999641 C134.47716,39.999641 129.47714,42.23822 125.85786,45.857513 L124.94602,46.962662 51.908844,119.99984 124.94678,193.03778 125.85786,194.14201 C129.47714,197.76131 134.47716,199.99988 140.00002,199.99988 151.04572,199.99988 160.00005,191.04556 160.00005,179.99985 160.00005,174.47699 157.76146,169.47699 154.14217,165.8577 L153.43225,165.27196 153.55394,165.14679 108.407,119.99986 154.20343,74.203423 154.14198,74.141975 154.14217,74.14183 C157.76146,70.522537 160.00005,65.52253 160.00005,59.999672 160.00005,48.95396 151.04572,39.999641 140.00002,39.999641 z M120,0.5 C185.99803,0.5 239.5,54.001972 239.5,120 239.5,185.99803 185.99803,239.5 120,239.5 54.001972,239.5 0.5,185.99803 0.5,120 0.5,54.001972 54.001972,0.5 120,0.5 z&lt;/span&gt;" /&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Then this is how to use it (StaticResource probably better, transforms just for demo):&lt;/p&gt;&lt;pre&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Path&lt;/span&gt; &lt;span style=' color: Red;'&gt;Data&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;{DynamicResource ArrowHeadPath}&lt;/span&gt;" &lt;span style=' color: Red;'&gt;RenderTransformOrigin&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0.7,0.5&lt;/span&gt;" &lt;span style=' color: Red;'&gt;MouseLeftButtonDown&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;ActivateWindowDrag&lt;/span&gt;" &lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Path.Fill&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;RadialGradientBrush&lt;/span&gt; &lt;span style=' color: Red;'&gt;GradientOrigin&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0.495,0.55&lt;/span&gt;"&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;GradientStop&lt;/span&gt; &lt;span style=' color: Red;'&gt;Color&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;#FFE2E2E2&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Offset&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0&lt;/span&gt;"/&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;GradientStop&lt;/span&gt; &lt;span style=' color: Red;'&gt;Color&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;#CC0F0316&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Offset&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0.3&lt;/span&gt;"/&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;RadialGradientBrush&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Path.Fill&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;Path.RenderTransform&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;TransformGroup&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;ScaleTransform&lt;/span&gt; &lt;span style=' color: Red;'&gt;ScaleX&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;3.6&lt;/span&gt;" &lt;span style=' color: Red;'&gt;ScaleY&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;3.6&lt;/span&gt;"/&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;SkewTransform&lt;/span&gt; &lt;span style=' color: Red;'&gt;AngleX&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0&lt;/span&gt;" &lt;span style=' color: Red;'&gt;AngleY&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;0&lt;/span&gt;"/&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;RotateTransform&lt;/span&gt; &lt;span style=' color: Red;'&gt;Angle&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;8&lt;/span&gt;"/&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;&lt;span style=' color: Maroon;'&gt;TranslateTransform&lt;/span&gt; &lt;span style=' color: Red;'&gt;X&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;5&lt;/span&gt;" &lt;span style=' color: Red;'&gt;Y&lt;/span&gt;="&lt;span style=' color: Blue;'&gt;-160&lt;/span&gt;"/&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;TransformGroup&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Path.RenderTransform&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=' color: Blue;'&gt;&amp;lt;&lt;/span&gt;/&lt;span style=' color: Maroon;'&gt;Path&lt;/span&gt;&lt;span style=' color: Blue;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6186915354318327826?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6186915354318327826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/01/note-to-self-turning-path-into-resource.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6186915354318327826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6186915354318327826'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/01/note-to-self-turning-path-into-resource.html' title='Note to self: Turning a Path into a Resource in XAML'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-367781857328522862</id><published>2010-01-12T11:08:00.001-08:00</published><updated>2010-04-14T06:48:40.377-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wpf'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>How I Dynamically Load a ViewModel from the Web</title><content type='html'>&lt;p&gt;&lt;strong&gt;For my vuPlan client I wanted to avoid those 'update me' messages that Adobe products are good at annoying me with. My aim was to be able to tweak my application logic, perhaps fix bugs, and do it unobtrusively. I also wanted to maintain a typical execution context of an ordinary locally installed application. To be clear, I've not fully investigated the options open to me with ClickOnce, and recently I became a user of Seesmic Desktop which is the first time I've seen it used in the wild. But even if you have different design goals, here's how I do dynamic MVVM.&lt;/strong&gt;&lt;/p&gt;&lt;h4&gt;Objective&lt;/h4&gt;&lt;p&gt;To download a compiled ViewModel class from the web at runtime and inject it into a local client application so that it hooks into the view just like a normal View-ViewModel does. Also to allow the last known good ViewModel to load when the web version is unavailable.&lt;/p&gt;&lt;p&gt;This article is not a complete code breakdown of the method, rather a 10,000ft overview with a few details. The concept is straight-forward enough for most OO programmers to get.&lt;/p&gt;&lt;h4&gt;Overview&lt;/h4&gt;&lt;p&gt;Dunno about you but I'm a visual learner and find graphics and diagrams more palatable than words alone. This schematic should compress most of what would otherwise be a long and arduous blog post into 1080x673 (if you look at the full size one I stuck on &lt;a title="Link to larger schematic on Flickr" href="http://farm3.static.flickr.com/2803/4256957297_9ba6b1769e_o.jpg"&gt;flickaarrrr&lt;/a&gt;).&lt;/p&gt;&lt;img title="Dynamic ViewModel Schematic" border="0" alt="Diagram of ViewModel class relationships" src="http://farm3.static.flickr.com/2803/4256957297_9ba6b1769e_o.jpg" width="628" /&gt; &lt;p&gt;Each of the black-rimmed screen looking objects are ViewModel classes. The inheritence tree runs right to left and so rooted with ViewModel.cs.&lt;/p&gt;&lt;p&gt;This class is the base for all and every view model I use thoughtout my application and is very similar to the base VM Josh Smith defines in his excellent MSDN &lt;a title="Link to MSDN article." href="http://bit.ly/55OIJ3"&gt;article&lt;/a&gt; on the Model-View-ViewModel pattern.&lt;/p&gt;&lt;p&gt;The only addition to Josh's base ViewModel worth mentioning is that I add a property (typed as object) which I used to store a reference to the Dispatcher for the UI control to which the ViewModel will be bound.&lt;/p&gt;&lt;p&gt;The coloured blocks define the code distribution in the sense of partitioning over assemblies. (A) is the actual WPF application executable/project and would reside on the client PC once deployed, (B) is the dynamically loaded assembly containing business logic and (C) is a reusable shared library.&lt;/p&gt;&lt;p&gt;The assemblies reference each other like so:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Assembly A references &lt;ul&gt;&lt;li&gt;The shared library C &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Assembly B references &lt;ul&gt;&lt;li&gt;The shared library C &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Assembly C references &lt;ul&gt;&lt;li&gt;Nothing other than the usual &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;The Shared Client .dll (C)&lt;/h4&gt;&lt;p&gt;Two classes are defined in here. The abstract base ViewModel, as mentioned above, and an abstract base MainViewModel class. This latter class defines all the properties that the WPF view will bind to, but contains no other logic.&lt;/p&gt;&lt;p&gt;It also defines the ICommand properties into which behaviour and logic will be placed. This is an example of an ICommand to hook up to a Login button (in MainViewModel.cs):&lt;/p&gt;&lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; ICommand LoginCommand &lt;br /&gt;{ &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&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; (_loginCommand == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _loginCommand = &lt;span style="color: blue"&gt;new&lt;/span&gt; RelayCommand(param =&amp;gt; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Login(param), param =&amp;gt; &lt;span style="color: blue"&gt;this&lt;/span&gt;.CanLogin(param)); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//_loginCommand = new RelayCommand(param =&amp;gt; this.Login(param));&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; _loginCommand; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;} &lt;br /&gt;RelayCommand _loginCommand; &lt;br /&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;virtual&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; Login(&lt;span style="color: blue"&gt;object&lt;/span&gt; obj) { &lt;span style="color: blue"&gt;throw&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;new&lt;/span&gt; NotImplementedException(); } &lt;br /&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;virtual&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;bool&lt;/span&gt; CanLogin(&lt;span style="color: blue"&gt;object&lt;/span&gt; obj) { &lt;span style="color: blue"&gt;throw&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;new&lt;/span&gt; NotImplementedException(); }&lt;/div&gt;&lt;p&gt;The RelayCommand comes straight from Josh Smith's article mentioned above. The key to it are the two virtual methods which will be overridden in the implementation assembly.&lt;/p&gt;&lt;p&gt;&lt;em&gt;N.B. It may be possible to skip this class as I think WPF bindings are loosely coupled and not checked at build time. The XAML for my view simply contains lines like {Binding Path=Username} (for the username textbox) and so it stands to reason that any object instance could be set as the DataContext and binding/reflection will just work where it works and fail where it fails - although don't quote me on that.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;I also define delegates for some actions such as closing the window or application which allows me to shift the implementation of that logic to where I know how I want it to work (in the application UI itself).&lt;/p&gt;&lt;h4&gt;The Implementation Logic .dll (B)&lt;/h4&gt;&lt;p&gt;I call this class MainImplViewModel and it contains an InitializeComponent method which in many ways is the main initializer for the application - remember that the UI assembly (A) is supposed to be 'dumb'.&lt;/p&gt;&lt;p&gt;For my app, it assigns some delegates and default property values. It also does things like checking if the internet is connected and altering property values which can affect whether various UI controls are active as well as loading stuff in from &lt;a title="Opens MSDN article on Isolated Storage" href="http://msdn.microsoft.com/en-us/library/3ak841sy.aspx"&gt;IsolatedStorage&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;As mentioned above, I have a reference to the Dispatcher for the UI and so I also define utility methods for marshalling work onto that thread and my application also has a synchronisation process, so there's a private BackgroundWorker variable and event handlers there, too.&lt;/p&gt;&lt;p&gt;And of course, I override the methods that my RelayCommand objects rely on (in MainImplViewModel):&lt;/p&gt;&lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;override&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;bool&lt;/span&gt; CanLogin(&lt;span style="color: blue"&gt;object&lt;/span&gt; obj) { ... } &lt;br /&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;override&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; Login(&lt;span style="color: blue"&gt;object&lt;/span&gt; obj) { ... }&lt;/div&gt;&lt;p&gt;Within which is the actual implementation which can trigger UI changes by modifying the properties, starting my BackgroundWorker and all manner of stuff.&lt;/p&gt;&lt;h4&gt;The Application UI XAML .exe&lt;/h4&gt;&lt;p&gt;The job of the pared-down application code is to i) check we're online or that the local cache is available (Isolated Storage), ii) download the implementation assembly (B) from a URL and iii) load it.&lt;/p&gt;&lt;p&gt;Once loaded, the types defined in the implementation assembly are scanned and the first class of type MainViewModel that is found is instantiated and assigned to a local variable within the application as well as the DataContext of the main window.&lt;/p&gt;&lt;p&gt;I have written a pretty complex background component loader/initializer class but the main thrust of what its doing is simple; download the file from a website using an ordinary http get, then load the assembly from the raw bytes with Assembly.Load(bytes).&lt;/p&gt;&lt;p&gt;After this is done, it fires an event which continues the ViewModel load process and is handled like so (in app.xaml.cs):&lt;/p&gt;&lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;void&lt;/span&gt; Initializer_AfterComponentLoaded(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, TypeLoadEventArgs e) &lt;br /&gt;{ &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (e.Instance.GetType() == &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(ResourceDictionary)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Application.Current.Resources = (ResourceDictionary)e.Instance; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.MainWindow = (Window)LoadComponent(&lt;span style="color: blue"&gt;new&lt;/span&gt; Uri(&lt;span style="color: maroon"&gt;@&amp;quot;MainWindow.xaml&amp;quot;&lt;/span&gt;, UriKind.Relative)); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.MainWindow.Show(); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;else&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;if&lt;/span&gt; (e.Instance.GetType() == &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(System.Reflection.Assembly)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UI.MainViewModel mainVm; &lt;br /&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: blue"&gt;this&lt;/span&gt;.Initializer.AssemblyLoader.TryLoadType&amp;lt;UI.MainViewModel&amp;gt;(&lt;span style="color: blue"&gt;out&lt;/span&gt; mainVm)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.MainWindowViewModel = mainVm; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.MainWindow.DataContext = mainVm; &lt;span style="color: green"&gt;// DataContext set to view model.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mainVm.ShutdownApplicationAction = &lt;span style="color: blue"&gt;new&lt;/span&gt; Action&amp;lt;&lt;span style="color: blue"&gt;int&lt;/span&gt;&amp;gt;(ShutdownVuplan); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mainVm.ScrollIntoViewAction = &lt;span style="color: blue"&gt;new&lt;/span&gt; Action(&lt;span style="color: blue"&gt;delegate&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//var listBox = ((Window1)this.MainWindow).MainListBox;&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//if (listBox.Items.Count &amp;gt; 0)&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&amp;#160;&amp;#160;&amp;#160; listBox.ScrollIntoView(listBox.Items.GetItemAt(listBox.Items.Count - 1));&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mainVm.Dispatcher = &lt;span style="color: blue"&gt;this&lt;/span&gt;.MainWindow.Dispatcher; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mainVm.ParentControl = &lt;span style="color: blue"&gt;this&lt;/span&gt;.MainWindow; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.SessionEnding += &lt;span style="color: blue"&gt;new&lt;/span&gt; SessionEndingCancelEventHandler(App_SessionEnding); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mainVm.SyncStatusMessages.Add(Client.UI.StringHelper.TryGetWinFxResourceString(&lt;span style="color: maroon"&gt;&amp;quot;Status_Message_Initializing&amp;quot;&lt;/span&gt;)); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; mainVm.InitializeComponent(&lt;span style="color: blue"&gt;this&lt;/span&gt;.CloudStatus); &lt;span style="color: green"&gt;// Warning: Go To Definition will jump to base impl.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;this&lt;/span&gt;.Initializer.AssemblyLoader.TypeLoadException != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;throw&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;this&lt;/span&gt;.Initializer.AssemblyLoader.TypeLoadException; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;}&lt;/div&gt;&lt;p&gt;I like to leave all my code around so you can get an idea of the other stuff I do. For example, my loader also loads a resource dictionary from the web, based on location – this is a subject for a different blog post, but you can see that I roll my own localization this way. The method above checks what type of object was loaded and if its an Assembly (the implementation assembly) it hooks it up.&lt;/p&gt;&lt;p&gt;What’s most important here is that I set MainWindowViewModel to point to the view model and then set the DataContext of my main window. Further down, I call the all important InitializeComponent and so any state changes to the view model made during this method will be reflected in the view.&lt;/p&gt;&lt;p&gt;To load a type from the implementation assembly I use a generic method TryLoadType&amp;lt;T&amp;gt;&lt;/p&gt;&lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;bool&lt;/span&gt; TryLoadType&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;out&lt;/span&gt; T instance) where T : &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;br /&gt;{ &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.TypeLoadException = &lt;span style="color: blue"&gt;null&lt;/span&gt;; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; instance = &lt;span style="color: blue"&gt;null&lt;/span&gt;; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;try&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&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: blue"&gt;this&lt;/span&gt;.Assembly == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;throw&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;new&lt;/span&gt; InvalidOperationException(UI.StringHelper.TryGetResourceString(&lt;span style="color: maroon"&gt;&amp;quot;ErrorMessages&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;ErrorVitalReferenceIsNull&amp;quot;&lt;/span&gt;)); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (Type t &lt;span style="color: blue"&gt;in&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;this&lt;/span&gt;.Assembly.GetTypes()) &lt;span style="color: green"&gt;// Exceptions here probably due to assembly dependencies of wrong version (remote assembly not latest build).&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(T).IsAssignableFrom(t)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; instance = (T)&lt;span style="color: blue"&gt;this&lt;/span&gt;.Assembly.CreateInstance(t.FullName); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// this.OnLoaded(new TypeLoadEventArgs(instance));}&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;catch&lt;/span&gt; (Exception e) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Could throw any of 6 exceptions.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;//&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.TypeLoadException = e; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; (instance != &lt;span style="color: blue"&gt;null&lt;/span&gt;); &lt;br /&gt;}&lt;/div&gt;&lt;p&gt;The important bit here is the foreach loop that looks for the type specified in T. MainImplViewModel is derived from MainViewModel so the calling code only need know of the MainViewModel type and it will load the class with all the implementation logic.&lt;/p&gt;&lt;p&gt;The caller (in this case, the method above this one) can also set properties on the view model because it knows of the base type – this is why I have a MainViewModel (recall that I mentioned that in theory it could be excluded).&lt;/p&gt;&lt;h4&gt;Conclusion&lt;/h4&gt;&lt;p&gt;I've not the time to simplify my example code above, I've just ripped out lumps of code from my projects, thus making it more complicated and excluding things that may have made it more readable, sorry, but I think the general idea can be grasped by most programmers au fait with MVVM.&lt;/p&gt;&lt;p&gt;Using this technique, I can keep my business logic in an implementation assembly, fix bugs in it, and then publish the .dll file to a web server and my clients will be updated invisibly.&lt;/p&gt;&lt;p&gt;&lt;em&gt;Which reminds me: remember to add an XCOPY command to the post build actions for the implementation DLL which copies the assembly to your web server. Easily forgotton - you'll wonder why your breakpoints aren't being hit.&lt;/em&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-367781857328522862?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/367781857328522862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/01/how-i-dynamically-load-viewmodel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/367781857328522862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/367781857328522862'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/01/how-i-dynamically-load-viewmodel.html' title='How I Dynamically Load a ViewModel from the Web'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-1637633920116797185</id><published>2010-01-01T13:05:00.001-08:00</published><updated>2010-01-02T01:56:27.542-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Debugging an Assembly Load (Reflection or not)</title><content type='html'>&lt;p&gt;&lt;strong&gt;The Visual Studio Solution I have been using for a while has grown to 11 projects. It's also dependant on a bunch of libraries from a resuable framework I've been working on which I intend to use across various products. Since working in XAML, I broke off the client components to lighten the burden on the IDE. Problems arose after I made some major changes to my resuable framework.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The framework I have is an evolving beast that I call Steelcore. My vuPlan projects use various libraries from this framework by referencing the release built DLLs.&lt;/p&gt;&lt;p&gt;Since VS 2010 is around the corner and has a &lt;a title="Thread Debugging Video on Channel9" href="http://channel9.msdn.com/posts/DanielMoth/Multi-threading-Debugging-Enhancements-in-Visual-Studio-2008/"&gt;slew&lt;/a&gt; of thread debugging features, and due to an &lt;a title="Tracing documentation on MSDN" href="http://msdn.microsoft.com/en-us/library/system.diagnostics.trace.aspx"&gt;issue&lt;/a&gt; with the way I added tracing instrumentation to my code, I cut out a few classes related to thread tracking and even entire namespaces and re-versioned to 2.0.0.0.&lt;/p&gt;&lt;p&gt;This is not an issue for my unfinished vuPlan project as I own the source and I can just right-click each reference under each vuPlan component, check its property sheet states 2.0.0.0 and rebuild the lot. Nothing else to worry about right?&lt;/p&gt;&lt;p&gt;Right. All was fine when building, sure, but when working in my light-weight solution (just has the WPF client bits) and I tried to run it.&lt;/p&gt;&lt;blockquote&gt;Could not load file or assembly 'Steelcore.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdef0123456789' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)&lt;/blockquote&gt;&lt;p&gt;An interesting point about the way I've written the vuPlan client is that it has only the skinniest of clients, just UI, and the implementation logic is downloaded from the web at startup, loaded with reflection and plugged-in to the UI using polymorphic viewmodels. One day I shall blog about that. But the reflection part of the scenario is a red-herring and I troubleshot the problem as if it were an ordinary 'early bound' load error.&lt;/p&gt;&lt;p&gt;The exception was being thrown by a class that downloads the implementation assembly and enumerates the types within. Just the enumeration caused it to blow up. Needless to say, I rebuilt and ensured my implementation assembly was up-to-date and that the locally cached copy was, too.&lt;/p&gt;&lt;h4&gt;Troubleshooting Method&lt;/h4&gt;&lt;p&gt;My first mode of attack was to double-check all references within all projects, in all solutions including the Steelcore library itself, just in case one component was using an old version or using a version that was using an old version.&lt;/p&gt;&lt;p&gt;I also made a decision to increment the minor version number of all vuPlan assemblies to reflect their dependence on the radically different Steelcore DLLs. This would prove useful later.&lt;/p&gt;&lt;p&gt;My second was to fire up I'll Dazzle 'em (&lt;a title="Short MSDN article on Ildasm" href="http://msdn.microsoft.com/en-us/library/ceats605.aspx"&gt;ILDASM.exe&lt;/a&gt;) and take a peek at the manifest. This was a good move because within the list of references was this intriguing bunch of text:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;.assembly extern Steelcore.Data as Steelcore.Data_13&lt;br /&gt;{&lt;br /&gt;  .publickeytoken = (80 72 6D A9 F7 97 F6 5E )                         // .rm....^&lt;br /&gt;  .ver 1:0:0:0&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Must admit it might have said "as Data_13" I'm not sure because my machine crashed on resume from sleep just before typing this and I lost the original paste.&lt;/p&gt;&lt;p&gt;Anyway, there were TWO references to Steelcore.Data.dll and the one above looks like some auto-gen alias to help it reference an old version probably by proxy, i.e. probably because some other reference references it.&lt;/p&gt;&lt;p&gt;So my final tool was &lt;a title="MSDN article on Fusion Log Viewer" href="http://msdn.microsoft.com/en-us/library/e74a18c4.aspx"&gt;Fuslogvw.exe&lt;/a&gt; which is the Fusion log viewer/manager. Fusion is the name for the bit of the .NET Framework that goes looking for referenced assemblies and so this would prove most useful indeed. This was Suzanne Cook’s baby when she blogged and her &lt;a title="A Suzanne Cook blog article" href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx"&gt;articles&lt;/a&gt; haven’t lost any of their usefulness.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/Sz5jggkaMvI/AAAAAAAAAD0/IOggxTl48DU/s1600-h/Fuslogvw.exe[4].jpg"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="Fuslogvw.exe" border="0" alt="Fuslogvw.exe" src="http://lh3.ggpht.com/_nweCidX3nlI/Sz5jhpAemmI/AAAAAAAAAD4/UuzXnvj4s3c/Fuslogvw.exe_thumb[2].jpg?imgmax=800" width="634" height="330" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;The interesting section is obviously the blue section. Here we see that two S26.Vuplan.Core libraries are being loaded, each of differing versions, and that dastardly Steelcore.Data 1.0.0.0.&lt;/p&gt;&lt;p&gt;Each item in the log opens an HTML doc which shows further information.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/Sz5ji3AFgzI/AAAAAAAAAD8/z1rGiJ-051Q/s1600-h/Captured%20Fusion%20Log%20Entry[4].jpg"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="Captured Fusion Log Entry" border="0" alt="Captured Fusion Log Entry" src="http://lh4.ggpht.com/_nweCidX3nlI/Sz5jkWoIrzI/AAAAAAAAAEA/Jnn0jr6v73I/Captured%20Fusion%20Log%20Entry_thumb[2].jpg?imgmax=800" width="633" height="470" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;And as expected, the "Calling assembly" line shows that it is the old version of Vuplan.Core that's causing my grief.&lt;/p&gt;&lt;h4&gt;Solution&lt;/h4&gt;&lt;p&gt;Despite having thought I'd checked each of the assemblies, I'd clearly missed one. Aware that an old copy of the core lib was being referenced, I suspected and double-checked the client components again and found the bad reference.&lt;/p&gt;&lt;p&gt;I twigged that when I'd broken off those projects a few weeks ago, I must have reset the references to the built DLLs although I still find it unusual that it didn't just pick up the new version and work - my references to Steelcore did! Maybe it was pointed at a different path or something.&lt;/p&gt;&lt;h4&gt;Blames His Tools&lt;/h4&gt;&lt;p&gt;What would have helped was if Visual Studio had a different colored icon for project references and static file references.&lt;/p&gt;&lt;p&gt;It'd also be nice to see the version number next to each reference.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-1637633920116797185?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/1637633920116797185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2010/01/debugging-assembly-load-reflection-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1637633920116797185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1637633920116797185'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2010/01/debugging-assembly-load-reflection-or.html' title='Debugging an Assembly Load (Reflection or not)'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_nweCidX3nlI/Sz5jhpAemmI/AAAAAAAAAD4/UuzXnvj4s3c/s72-c/Fuslogvw.exe_thumb[2].jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-7851848384691410035</id><published>2009-12-29T05:26:00.001-08:00</published><updated>2009-12-29T05:26:40.359-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><title type='text'>ActiveSync Encountered a Problem on the Desktop</title><content type='html'>&lt;p&gt;&lt;strong&gt;This is just a quick note explaining a method I used to resolve the error message above.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Firstly, I disconnected the phone and closed Outlook and repaired all my storage files using the old ScanPst.exe tool that's secreted away when Outlook is installed.&lt;/p&gt; &lt;p&gt;C:\Program Files\Microsoft Office\Office12\SCANPST.EXE&lt;/p&gt; &lt;p&gt;I pointed this at my primary storage file, which is an Offline Store because I used the Windows Live Connector to get at my Hotmail account.&lt;/p&gt; &lt;p&gt;C:\Users\lukepup\AppData\Local\Microsoft\Outlook\lukepup_hotmail.ost&lt;/p&gt; &lt;p&gt;And then I repaired all other PST files I use, just for completeness. During the repair, ScanPst can hang and be reported as Not Responding - this is surely because while its single thread does the repair it stop pumping the window message queue.&lt;/p&gt; &lt;p&gt;Then I deleted the partnership in Windows and also on ActiveSync actually on the phone itself; run ActiveSync and then in Options, hit Delete on the head of the tree of folders which kills the partnership and cleans up.&lt;/p&gt; &lt;p&gt;I opened Outlook on the desktop and let it do it's thing with Windows Live. It seemed to detect major changes because it appeared to exhaustively sync every item in all folders, taking 10 minutes.&lt;/p&gt; &lt;p&gt;Closed Outlook when done and connected the phone. Setup a new partnership with different names in case it linked back to old registry data. Allowed a good 10 minutes to complete. Well, actually it never completes because I've had a problem for months where it encounters some kind of error and restarts, but this doesn't happened until all items are in, so I don't really worry about it.&lt;/p&gt; &lt;p&gt;Disconnected, done.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-7851848384691410035?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/7851848384691410035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/12/activesync-encountered-problem-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7851848384691410035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/7851848384691410035'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/12/activesync-encountered-problem-on.html' title='ActiveSync Encountered a Problem on the Desktop'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-9145632008188708804</id><published>2009-12-17T21:56:00.001-08:00</published><updated>2009-12-17T21:56:01.560-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><title type='text'>Snow on the Pantiles</title><content type='html'>&lt;p&gt;&lt;strong&gt;Off topic, but hey its snow and its on the right side of Christmas – or white side. Got up at 3.30am to run down to &lt;a title="Google Maps" href="http://maps.google.com/maps?hl=en&amp;amp;source=hp&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=Royal+Tunbridge+Wells+TN1,+United+Kingdom&amp;amp;t=h&amp;amp;layer=x&amp;amp;g=tn1&amp;amp;sll=51.140579,0.272052&amp;amp;sspn=0.032617,0.027963&amp;amp;ll=51.125937,0.257932&amp;amp;spn=0.005104,0.010139&amp;amp;z=17"&gt;The Pantiles&lt;/a&gt; and get some super festive shots.&lt;/strong&gt;&lt;/p&gt; &lt;a href="http://lh5.ggpht.com/_nweCidX3nlI/SysZTfQc9PI/AAAAAAAAAC8/PPBTWp1ieDY/s1600-h/DSC07619%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07619" border="0" alt="DSC07619" src="http://lh6.ggpht.com/_nweCidX3nlI/SysZTpPcTuI/AAAAAAAAADA/LuYucrh51eE/DSC07619_thumb.jpg?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt; &lt;a href="http://lh6.ggpht.com/_nweCidX3nlI/SysZUfhhVKI/AAAAAAAAADE/n4z7PXsZ0Uc/s1600-h/DSC07632%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07632" border="0" alt="DSC07632" src="http://lh3.ggpht.com/_nweCidX3nlI/SysZVbM697I/AAAAAAAAADI/1kVgt_0Jjbg/DSC07632_thumb.jpg?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt; &lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/SysZWhPRdoI/AAAAAAAAADM/P-jmP20p3cw/s1600-h/DSC07630%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07630" border="0" alt="DSC07630" src="http://lh6.ggpht.com/_nweCidX3nlI/SysZW5XfeoI/AAAAAAAAADQ/DTaeFaBv4M4/DSC07630_thumb.jpg?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt; &lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/SysZXkmNK8I/AAAAAAAAADU/dXlDJZ36-lE/s1600-h/DSC07611%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07611" border="0" alt="DSC07611" src="http://lh3.ggpht.com/_nweCidX3nlI/SysZXwjILrI/AAAAAAAAADY/x67k0UN_Xmw/DSC07611_thumb.jpg?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt; &lt;a href="http://lh5.ggpht.com/_nweCidX3nlI/SysZZH41UoI/AAAAAAAAADc/VQ7HHrH6brk/s1600-h/DSC07603%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07603" border="0" alt="DSC07603" src="http://lh3.ggpht.com/_nweCidX3nlI/SysZZpRlpoI/AAAAAAAAADg/jO1nucFjaCE/DSC07603_thumb.jpg?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt; &lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/SysZalxBiQI/AAAAAAAAADk/kS-VVmYQqEM/s1600-h/DSC07584%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07584" border="0" alt="DSC07584" src="http://lh5.ggpht.com/_nweCidX3nlI/SysZbPMNuQI/AAAAAAAAADo/zNp_o_K20TE/DSC07584_thumb.jpg?imgmax=800" width="244" height="164" /&gt;&lt;/a&gt; &lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/SysZbgT9GBI/AAAAAAAAADs/ONK8wjIHWzM/s1600-h/DSC07578%5B2%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DSC07578" border="0" alt="DSC07578" src="http://lh5.ggpht.com/_nweCidX3nlI/SysZcFMZjrI/AAAAAAAAADw/ZmC514yapMg/DSC07578_thumb.jpg?imgmax=800" width="164" height="244" /&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-9145632008188708804?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/9145632008188708804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/12/snow-on-pantiles.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/9145632008188708804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/9145632008188708804'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/12/snow-on-pantiles.html' title='Snow on the Pantiles'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_nweCidX3nlI/SysZTpPcTuI/AAAAAAAAADA/LuYucrh51eE/s72-c/DSC07619_thumb.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6396806746954443837</id><published>2009-12-14T03:14:00.000-08:00</published><updated>2009-12-14T03:41:00.346-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='tv'/><title type='text'>Windows 7 Remote (Web) Media Streaming</title><content type='html'>&lt;span style="font-weight: bold;"&gt;I stumbled across this post while having a rare look on the Channel 10 site and was surprised to have discovered it this way, and not through a tech news site. I've not tested it but Windows 7 and its Media Player allow your library to be streamed to different computers - this part is nothing groundbreaking since the invention of a LAN, but then I haven't told you that it allows your library to be streamed over an internet connection to your other PC, at work or by the pool at the holiday villa.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Connections are secured by SSL and certificates, which is why it requires both machine's user IDs to be associated with your Windows Live ID (or some other provider, but probably, effectively Windows Live). As I remember, its hard to unassociate so if you fancy doing this on a mate's laptop, make a new local Windows account first, rather than link your Live ID to your mates admin account or something.&lt;br /&gt;&lt;br /&gt;I would also be interested to know if this works with your recorded television content and weather a remotely scheduled television programme can be recorded and streamed at the same time, as it can be locally recorded and viewed.&lt;br /&gt;&lt;br /&gt;And finally, what of Windows Mobile 7?&lt;br /&gt;&lt;br /&gt;&lt;a href="http://on10.net/blogs/sarahintampa/How-to-Use-Play-to-and-Remote-Media-Streaming-in-Windows-7/"&gt;http://on10.net/blogs/sarahintampa/How-to-Use-Play-to-and-Remote-Media-Streaming-in-Windows-7/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6396806746954443837?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6396806746954443837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/12/windows-7-remote-web-media-streaming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6396806746954443837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6396806746954443837'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/12/windows-7-remote-web-media-streaming.html' title='Windows 7 Remote (Web) Media Streaming'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-3328493610455286711</id><published>2009-12-02T07:16:00.001-08:00</published><updated>2009-12-02T07:19:05.182-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Dragging a WPF Window Around</title><content type='html'>&lt;p&gt;&lt;strong&gt;This short article shows how to drag a WPF application window around your desktop when you have removed the stock Microsoft Windows chrome.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Applications using WPF and having a particularly stylistic look and feel often don’t sit well with the standard Windows chrome supplied by the operating system. It’s &lt;a title="Link to MSDN documentation" href="http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle.aspx"&gt;easy&lt;/a&gt; to remove this chrome, but once it’s gone your users lose the ability to move your application window around.&lt;/p&gt;&lt;p&gt;Here’s how to hook up a region (in this case, a grid) to serve as a handle so as long as the mouse is held down and dragging around, the window moves with it.&lt;/p&gt;&lt;p&gt;First, hook up a single MouseLeftButtonDown handler in your XAML on the element you wish to use.&lt;/p&gt;  &lt;pre&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Grid&lt;/span&gt; &lt;span style="color: red"&gt;Grid.Row&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;MouseLeftButtonDown&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;Grid_MouseLeftButtonDown&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;The codebehind file for the Window looks like this – see notes at the bottom.&lt;/p&gt;&lt;div style="font-family: courier new"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;partial&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;class&lt;/span&gt; Window1 : Window &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt; System.Drawing.Point _windowMoveMouseStart; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;double&lt;/span&gt; _windowMoveStartTop; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;double&lt;/span&gt; _windowMoveStartLeft; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;public&lt;/span&gt; Window1() &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.InitializeComponent(); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Insert code required on object creation below this point.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;private&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; Grid_MouseLeftButtonDown(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, MouseButtonEventArgs e) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UIElement handle = sender &lt;span style="color: blue"&gt;as&lt;/span&gt; UIElement; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (handle == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _windowMoveMouseStart = System.Windows.Forms.Control.MousePosition; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _windowMoveStartTop = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Top; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _windowMoveStartLeft = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Left; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; handle.MouseMove += Handle_MouseMove; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; handle.CaptureMouse(); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;void&lt;/span&gt; Handle_MouseMove(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, MouseEventArgs e) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UIElement handle = sender &lt;span style="color: blue"&gt;as&lt;/span&gt; UIElement; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (handle == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (e.LeftButton == MouseButtonState.Released) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; handle.MouseMove -= Handle_MouseMove; &lt;span style="color: green"&gt;// Detach listener on mouse up.&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; handle.ReleaseMouseCapture(); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var smp = System.Windows.Forms.Control.MousePosition; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var distanceX = smp.X - _windowMoveMouseStart.X; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var distanceY = smp.Y - _windowMoveMouseStart.Y; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Left = _windowMoveStartLeft + distanceX; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Top = _windowMoveStartTop + distanceY; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/div&gt;&lt;p&gt;At the top is a System.Drawing.Point which means you need to add a reference to System.Drawing as well as System.Windows.Forms to get access to the Control.MousePosition static property – unless you know of a better way to get at non-relative mouse data.&lt;/p&gt;&lt;h4&gt;CaptureMouse&lt;/h4&gt;&lt;p&gt;Key to this is the UIElement.CaptureMouse() method which sets the eventing system to continue firing even when the mouse is outside the bounds of the element. Without this the mouse can ‘'skid off’ the handle when its moved too fast – too fast being quite slow actually.&lt;/p&gt;&lt;p&gt;If a mouse move is captured and the button isn’t down, we disconnect all the mechanics previously setup. Since the mouse move should always be captured, even when its not over the original handle, the mechanics should always get detached.&lt;/p&gt;&lt;h4&gt;Windows 7 Aero Shake&lt;/h4&gt;&lt;p&gt;Not sure if this will then trigger the Windows 7 shake feature...&lt;/p&gt;&lt;object width="445" height="364"&gt;&lt;param name="movie" value="http://www.youtube.com/v/0JdV0sG6sFI&amp;amp;hl=en_GB&amp;amp;fs=1&amp;amp;rel=0&amp;amp;color1=0xcc2550&amp;amp;color2=0xe87a9f&amp;amp;border=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/0JdV0sG6sFI&amp;amp;hl=en_GB&amp;amp;fs=1&amp;amp;rel=0&amp;amp;color1=0xcc2550&amp;amp;color2=0xe87a9f&amp;amp;border=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="445" height="364"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-3328493610455286711?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/3328493610455286711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/12/dragging-wpf-window-around.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3328493610455286711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/3328493610455286711'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/12/dragging-wpf-window-around.html' title='Dragging a WPF Window Around'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-8352802459167496150</id><published>2009-11-20T07:51:00.001-08:00</published><updated>2009-11-20T07:54:11.785-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Linq to Visual Tree</title><content type='html'>&lt;p&gt;&lt;strong&gt;Over on Peter McGrattan’s &lt;a title="Peter&amp;#39;s Blog Link" href="http://petermcg.wordpress.com/2009/03/04/linq-to-visual-tree-beta/"&gt;blog&lt;/a&gt; is a simple extension method for a DependencyObject which returns the visual tree descending from a particular visual element in a WPF application. The genius in Peter’s simple extension is that it automatically leverages the power of LINQ because the tree is IEnumerable:&lt;/strong&gt;&lt;/p&gt;&lt;div style="font-family: courier new"&gt;myPanel.GetVisualOfType&amp;lt;TextBox&amp;gt;().Where(t =&amp;gt; t.Foreground... etc&lt;/div&gt;&lt;p&gt;&lt;strong&gt;But I had a problem: the tree would not descend fully.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;To cut a long story short, the issue was caused because VisualTreeHelper.GetChildrenCount doesn’t count the content of a ContentControl as a child.&lt;/p&gt;&lt;p&gt;The following is my version of Peter’s good work – this is just one method cut from the original class, so I implore you to head over to his blog and see the whole thing. I have made the following changes:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Added support for ContentControl objects.&lt;/li&gt;&lt;li&gt;Modified the type checking to use IsAssignableFrom so types can be collated using their base classes.&lt;/li&gt;&lt;/ul&gt;&lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; GetVisualOfType&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt; DependencyObject element)&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;{&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; GetVisualTree(element).Where(&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; t =&amp;gt; &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(T).IsAssignableFrom(t.GetType())).Cast&amp;lt;T&amp;gt;(); &lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt; IEnumerable&amp;lt;DependencyObject&amp;gt; GetVisualTree(&lt;span style="color: blue"&gt;this&lt;/span&gt; DependencyObject element) &lt;br /&gt;{ &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;int&lt;/span&gt; childrenCount = VisualTreeHelper.GetChildrenCount(element); &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; ((childrenCount == &lt;span style="color: maroon"&gt;0&lt;/span&gt;) &amp;amp;&amp;amp; (element &lt;span style="color: blue"&gt;is&lt;/span&gt; ContentControl)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ContentControl cc = element &lt;span style="color: blue"&gt;as&lt;/span&gt; ContentControl; &lt;br /&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; (cc.Content != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DependencyObject content = cc.Content &lt;span style="color: blue"&gt;as&lt;/span&gt; DependencyObject; &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (content != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;yield&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;return&lt;/span&gt; content;&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (DependencyObject obj &lt;span style="color: blue"&gt;in&lt;/span&gt; GetVisualTree(content)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;yield&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;return&lt;/span&gt; obj; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;for&lt;/span&gt; (&lt;span style="color: blue"&gt;int&lt;/span&gt; i = &lt;span style="color: maroon"&gt;0&lt;/span&gt;; i &amp;lt; childrenCount; i++) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var visualChild = VisualTreeHelper.GetChild(element, i); &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;yield&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;return&lt;/span&gt; visualChild; &lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: courier new"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (var visualChildren &lt;span style="color: blue"&gt;in&lt;/span&gt; GetVisualTree(visualChild)) &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;yield&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;return&lt;/span&gt; visualChildren; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;br /&gt;}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-8352802459167496150?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/8352802459167496150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/11/linq-to-visual-tree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8352802459167496150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/8352802459167496150'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/11/linq-to-visual-tree.html' title='Linq to Visual Tree'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-6791961011130377880</id><published>2009-11-09T20:42:00.001-08:00</published><updated>2009-11-09T21:25:42.827-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='xaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Beginning XAML</title><content type='html'>&lt;p&gt;&lt;strong&gt;This week I’ve begun to get somewhere with XAML after almost crying with frustration and sleep deprivation last week! Starting from scratch with an unfamiliar technology is like crawling around naked in a blackened room in which large pans of boiling water are lying around.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Its true that I have held off using Silverlight for as long as possible while I coded up the server application, but there’s no more I can do on that phase so I have turned to the user experience for my client application, at least so I can get something out there for my test users.&lt;/p&gt;&lt;p&gt;As soon as Companies House (the government department in the UK that oversees business trading entities) approves my company name change I can register on the Microsoft MPower scheme and get MSDN again after my last one expired just before SL3 RTM.&lt;/p&gt;&lt;h4&gt;Clip Joint&lt;/h4&gt;&lt;p&gt;That means I’m still on SL2 and Expression Blend 2.0 which, in my opinion, were transitional releases with many functionality holes. One of them being the fact that the PathGeometry.Figures property doesn’t work and results in the following error message even though the similar Path.Data is supported.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The TypeConverter for &amp;quot;PathFigureCollection&amp;quot; does not support converting from a string.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Instead, you have to specify the components of the path using loads of LineSegment objects, which is frankly impossible if you’re working with a 26-line piece of mini path markup syntax exported from your favourite drawing application.&lt;/p&gt;&lt;p&gt;- OR -&lt;/p&gt;&lt;p&gt;Specify the mini mark-up within the Clip attached property directly:&lt;/p&gt;  &lt;pre&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;Image&lt;/span&gt; &lt;span style="color: red"&gt;Clip&lt;/span&gt;=&amp;quot;&lt;span style="color: blue"&gt;M 286,55 C276.24915,55.9...&lt;/span&gt;&amp;quot; [...] /&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;h4&gt;CorelDRAW to Expression Blend 2.0&lt;/h4&gt;&lt;p&gt;My favourite drawing application happens to be CorelDRAW X3. When I was a teenager still at school I practically lived in Corel’s drawing suite so it wasn’t a difficult decision when it came to buying a decent vector drawing tool for UI work. Especially when faced with the extortionate price of Adobe’s market-leading equivalent.&lt;/p&gt;&lt;p&gt;Below are some of my logo designs. The first one is for my consulting company from which I will ‘host’ the new vuPlan web product, providing this complies with BizSpark rules.&lt;/p&gt;&lt;p&gt;But before I get to the logos, here’s how to get complex shapes out of CorelDRAW and into Expression Blend 2.0. – in 3.0 you’d export from Corel to an AI file and then pull in the artwork using Blend’s new import features.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;From CorelDRAW, select the asset that you wish to use in Expression Blend. &lt;/li&gt;&lt;li&gt;Click through File and Print... tick to print Selected Only. &lt;/li&gt;&lt;li&gt;Choose the Microsoft XPS Document Writer* &lt;/li&gt;&lt;li&gt;Change the options to reposition the output to top left. &lt;/li&gt;&lt;li&gt;Print the document and provide a filename.xps &lt;/li&gt;&lt;li&gt;In Windows, rename the .xps file to .zip &lt;/li&gt;&lt;li&gt;Extract the zip contents to a folder. &lt;/li&gt;&lt;li&gt;Browse the folder structure and find Documents\1\Pages\1.fpage &lt;/li&gt;&lt;li&gt;Rename and change the file extension to .xaml &lt;/li&gt;&lt;li&gt;Open it in Notepad and pull out the content within the FixedPage element. &lt;/li&gt;&lt;li&gt;Paste the mark-up into your Expression Blend project. &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;*I believe that the XPS writer is installed as part of Microsoft Office 2003 or later and forms part of Microsoft’s Metro initiative, or &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Metro"&gt;OpenXPS&lt;/a&gt;.&lt;/p&gt;&lt;h4&gt;Logos&lt;/h4&gt;&lt;p&gt;The first logo is for my company Evoq Limited, once its renamed. In colour theory, blue conveys trust and loyalty and is popular with large companies. The swoosh, or flame rises to emulate a subtle tick or positive connotations with rising stock charts. &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/SvjvHPn6KxI/AAAAAAAAACs/9OmcP_L3RnA/s1600-h/EvoqAlphaBack%5B1%5D.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="EvoqAlphaBack" border="0" alt="EvoqAlphaBack" src="http://lh5.ggpht.com/_nweCidX3nlI/SvjvHljqT5I/AAAAAAAAACw/O5x6QchPVmA/EvoqAlphaBack_thumb.png?imgmax=800" width="240" height="51" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;At the time of writing, I have not purchased the rights to the typeface (until the company name is set) but it was designed by Benoit Sjoholm of &lt;a href="http://benoitsjoholm.blogspot.com/2009/07/typographie-dekers.html"&gt;Calame Design&lt;/a&gt; in France.&lt;/p&gt;&lt;p&gt;My original logo ideas (on &lt;a href="http://www.flickr.com/photos/22787790@N06/sets/72157622724898262/detail/"&gt;flickr&lt;/a&gt;) had smaller flames, but after rescaling it to use the Golden Ratio (1.618) of the text length it feels more unified.&lt;/p&gt;&lt;p&gt;The second logo is for the web service I’m working on and is below. Its this logo that I’ve recently been working on in CorelDRAW and Expression Blend – see flickr link above where I have uploaded some wireframes. CorelDRAW now has a very nice snapping system allowing the nodes along a line to be snapped over lines of other (guide) objects.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_nweCidX3nlI/SvjvH-RvgCI/AAAAAAAAAC0/Y9dhTYbXoPI/s1600-h/Master%20Logo%20Edition%202%20-%20200px%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Master Logo Edition 2 - 200px" border="0" alt="Master Logo Edition 2 - 200px" src="http://lh4.ggpht.com/_nweCidX3nlI/SvjvIFGT86I/AAAAAAAAAC4/IZ4sZAl43b4/Master%20Logo%20Edition%202%20-%20200px_thumb%5B3%5D.png?imgmax=800" width="200" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Interestingly, the PNG output by Corel doesn’t seem to be as well anti-aliased into the transparent alpha channel than my ancient copy of Photoshop seems to achieve.&lt;/p&gt;&lt;p&gt;Now I don’t know if I’m enjoying myself or just being too finicky but time seems to be absolutely flying past when I’m doing the visuals. My old art teacher would tell me its because I am working in my right-hemisphere and its the other side of the brain that maintains the concept of time.&lt;/p&gt;&lt;p&gt;I’ve enjoyed this process and as of 4am this morning I now have them in my Silverlight test project.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-6791961011130377880?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/6791961011130377880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/11/beginning-xaml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6791961011130377880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/6791961011130377880'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/11/beginning-xaml.html' title='Beginning XAML'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_nweCidX3nlI/SvjvHljqT5I/AAAAAAAAACw/O5x6QchPVmA/s72-c/EvoqAlphaBack_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-1407738123079874224</id><published>2009-10-26T08:01:00.001-07:00</published><updated>2009-10-26T08:01:29.224-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><title type='text'>Stuttering Sound on Windows</title><content type='html'>&lt;p&gt;&lt;strong&gt;An LG LS55 laptop I bought for a family member from eBay had an awful affliction which I seem to have encountered a number of times and is a common condition.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;T&lt;/strong&gt;&lt;strong&gt;he sound stutters or vibrates, particularly when playing Microsoft encoded sound and video files, WMV, WMA and now Silverlight movies and particularly when the machine is busy or buffering.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;I fixed it and so for the sake of helping people googling the symptoms, here’s what I did.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Firstly, I ensured it wasn’t a codec or driver issue. The laptop in question has a C-Media 9880 sound chipset, which is Intel I think and runs under the Microsoft UAA standard. I tried to disable the Xear 3D DSP but its just not possible – its ‘in’ the driver.&lt;/p&gt;  &lt;p&gt;Reinstalling Microsoft codecs is a case of downloading and installing Windows Media Player again. Suspecting a conflict with the ATI video card, I used the performance settings of Display in Control Panel to take the hardware acceleration to none and did the same in Windows Media Player.&lt;/p&gt;  &lt;p&gt;After a lot of time and with horrible pixellated videos, I still had stuttering, echoey and stretched sound, and I was really sure that it was a hardware conflict.&lt;/p&gt;  &lt;p&gt;Also, the mouse pointer would jolt every second when smoothly drawing a circle, even though the CPU was at 4%.&lt;/p&gt;  &lt;p&gt;Device manager showed that many devices were hanging off IRQ 15 or 16, and of course I couldn’t change them. The BIOS on this machine is pretty basic, too.&lt;/p&gt;  &lt;p&gt;Although the BBC iPlayer was fine, the growth of Silverlight meant that it wouldn’t be long before my uncle would call from Belgium complaining about video playback – I couldn’t let him have it like this.&lt;/p&gt;  &lt;p&gt;I tried disabling the parallel port to free up IRQ5 and hoped that Windows would move a device. No joy.&lt;/p&gt;  &lt;p&gt;So my only choice was to disable IRQ Steering and take back control of my device allocations. There was some bad advice and warnings out on forums about this but I came across a great article.&lt;/p&gt;  &lt;p&gt;I have a friend in the music business and their needs for high-performance and reliable studio computers tells me that if anyone knows how to solve pops and clicks in sounds, it’s the music industry. (my friend now runs an 8-core Mac with 32 gig RAM)&lt;/p&gt;  &lt;p&gt;This article from Sound-on-sound magazine was my saviour.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.soundonsound.com/sos/Mar02/articles/pcmusician0302.asp" href="http://www.soundonsound.com/sos/Mar02/articles/pcmusician0302.asp"&gt;http://www.soundonsound.com/sos/Mar02/articles/pcmusician0302.asp&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I simply when into Device Manager, right-clicked “Computer” and updated the driver to Standard PC from its current ACPI one. It copied over a new HAL, I rebooted and Windows started back up and happily detected and reinstalled all devices!&lt;/p&gt;  &lt;p&gt;My mouse moved quickly, my sound sounds sound and videos are silky smooth. I just have to press the power button when Windows shuts down now, and there’s no standy, but its worth it.&lt;/p&gt;  &lt;p&gt;Apparently Vista and Win7 are better at spreading devices across the available interrupts. I just wish that user and computer could work cooperatively when I need to force a device setting and let IRQ Steering work around my needs.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-1407738123079874224?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/1407738123079874224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/10/stuttering-sound-on-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1407738123079874224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/1407738123079874224'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/10/stuttering-sound-on-windows.html' title='Stuttering Sound on Windows'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-4578229486747017784</id><published>2009-10-06T02:45:00.001-07:00</published><updated>2009-10-06T02:45:19.738-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='frontiers'/><category scheme='http://www.blogger.com/atom/ns#' term='user experience'/><category scheme='http://www.blogger.com/atom/ns#' term='touch'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><title type='text'>The future is a mouse you can stroke</title><content type='html'>&lt;p&gt;Posted on Channel 9 this morning was a short 5 minute video showing a number of prototype mice that replace the wheel and buttons with touch/finger/whole hand sensors.&lt;/p&gt;  &lt;p&gt;Given that holding our arms out in front of us to touch our screens all day will be prohibitively hard to sustain for 11 hours in the office, the future has to be some variation on the desktop pointing device or trackpad.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_nweCidX3nlI/SssRrYnsZ5I/AAAAAAAAACk/OQxvZvWsQG8/s1600-h/TouchMouse%5B3%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="TouchMouse" border="0" alt="TouchMouse" src="http://lh3.ggpht.com/_nweCidX3nlI/SssRrpTdufI/AAAAAAAAACo/kb5BCs3Rhyc/TouchMouse_thumb%5B1%5D.jpg?imgmax=800" width="244" height="148" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Check it out (and enjoy the bleepy futuristic music):&lt;/p&gt;  &lt;p&gt;&lt;a title="http://channel9.msdn.com/posts/LarryLarsen/This-May-Be-Your-Next-Mouse/" href="http://channel9.msdn.com/posts/LarryLarsen/This-May-Be-Your-Next-Mouse/"&gt;http://channel9.msdn.com/posts/LarryLarsen/This-May-Be-Your-Next-Mouse/&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-4578229486747017784?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/4578229486747017784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/10/future-is-mouse-you-can-stroke.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4578229486747017784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/4578229486747017784'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/10/future-is-mouse-you-can-stroke.html' title='The future is a mouse you can stroke'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_nweCidX3nlI/SssRrpTdufI/AAAAAAAAACo/kb5BCs3Rhyc/s72-c/TouchMouse_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-5396780002610544307</id><published>2009-10-02T10:58:00.001-07:00</published><updated>2009-10-02T11:00:04.018-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><title type='text'>What the &amp;#x0</title><content type='html'>&lt;p&gt;The character combination above is no obfuscation for an expletive. Its HTML notation for NULL and I know this for many reasons. Firstly, because it says so &lt;a href="http://www.fileformat.info/info/unicode/char/0000/index.htm"&gt;here&lt;/a&gt;, but also because it ended up being appended to a JSON object I was passing around.&lt;/p&gt;  &lt;p&gt;I have a WCF web method that takes a string but its design is to take some entity as XML. Unfortunately, when there’s a big payload XML wrapped in XML seems to cause HTTP 400 bad request to be spat out by IIS or WCF.&lt;/p&gt;  &lt;p&gt;Rather than troubleshoot that, and because I need to get on, my brainwave was to switch serializers. So out went my &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx"&gt;XmlSerializer&lt;/a&gt; and in came &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx"&gt;DataContractJsonSerializer&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Immediately the deserialization routine threw out a message saying something like &lt;strong&gt;invalid character \0&lt;/strong&gt; in my Json string.&lt;/p&gt;  &lt;p&gt;Reaching for Fiddler I inspected the raw data going over the wire. My Json was all there but so too was &amp;amp;#x0;&amp;amp;#x0;&amp;amp;#x0;&amp;amp;#x0; etc. at the end of the object.&lt;/p&gt;  &lt;p&gt;I have a helper class which has serialization boilerplate inside and one of the methods takes an array of Char as the raw data to deserialize. Looking at the array of characters as it went in revealed a whole bunch of character 0 elements.&lt;/p&gt;  &lt;p&gt;My initial thought was that the object being serialized has an array that has not been trimmed (TrimExcess) and serialization is making an exact representation, excess included.&lt;/p&gt;  &lt;p&gt;Trimming didn’t fix it so I wondered if Microsoft’s DataContractJsonSerializer was pushing arrays around and MS had forgotten to trim the excess.&lt;/p&gt;  &lt;p&gt;No. My helper class goes like this (this one is for Xml):&lt;/p&gt;  &lt;div style="font-family: courier new"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;static&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;void&lt;/span&gt; Serialize(&lt;span style="color: blue"&gt;object&lt;/span&gt; serializable, &lt;span style="color: blue"&gt;out&lt;/span&gt;&amp;#160;&lt;span style="color: blue"&gt;string&lt;/span&gt; xml)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var memoryStream = &lt;span style="color: blue"&gt;new&lt;/span&gt; SysIO.MemoryStream();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Serialize(serializable, memoryStream); // delegates to overload    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; var encoding = &lt;span style="color: blue"&gt;new&lt;/span&gt; System.Text.UTF8Encoding();&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; xml = encoding.GetString(memoryStream.GetBuffer()); // bug    &lt;br /&gt;}&lt;/div&gt;  &lt;p&gt;While looking at the MemoryStream instance I noticed its buffer size was the same as the character array length at my service end.&lt;/p&gt;  &lt;p&gt;The problem/solution is this: the GetBuffer() method returns the &lt;em&gt;buffer &lt;/em&gt;(okay, its obvious now) while the ToArray() method, which is what I should be using, returns just the data. I assume the buffer has automatically sized itself and has spare capacity.&lt;/p&gt;  &lt;p&gt;What is unusual is that the problem is only evident when deserializing Json object strings. The empty data is encoded in the raw string so it must have been there when the text was XML, so it must also have been there when I succesfully deserialized it at the service – maybe the XmlSerializer simply ignores character 0 and gets on with the job.&lt;/p&gt;  &lt;p&gt;It you don’t have control over the creator of the data, then writing a function to clean the trailing 0s from the end of a string.ToCharArray() would likely fix the issue.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-5396780002610544307?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/5396780002610544307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/10/what.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5396780002610544307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/5396780002610544307'/><link rel='alternate' type='text/html' href='http://www.lukepuplett.com/2009/10/what.html' title='What the &amp;amp;#x0'/><author><name>Luke Puplett</name><uri>http://www.blogger.com/profile/08367127592060126449</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_nweCidX3nlI/SbkC01-ayYI/AAAAAAAAAAs/O__YKMcovFA/S220/LukeBW2008bsmt.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5416778419136716668.post-2607464341459899736</id><published>2009-09-14T07:41:00.001-07:00</published><updated>2009-09-14T07:41:14.789-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='frontiers'/><category scheme='http://www.blogger.com/atom/ns#' term='tangent'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrency'/><title type='text'>Intel Ready for On-die GPU with Core i5/i7</title><content type='html'>&lt;p&gt;“The floor plan above shows the main blocks in Nehalem, and if you've followed previous Nehalem launches (most notably Bloomfield) then you may be able to spot what's missing: there is no QuickPath Interconnect (QPI) interface. Instead, in a significant twist that differentiates Intel's new PC system architecture from even AMD's offerings, there is now a PCIe interface that enables the GPU to attach directly to the processor socket. This latter move was made in anticipation of two things: 1) the GPU will migrate right into the processor socket at a later point when Intel releases a CPU with an on-die GPU integrated into it, and 2) for a discrete GPU, Intel hopes you'll use Larrabee.”&lt;/p&gt;  &lt;p&gt;&lt;a title="http://arstechnica.com/hardware/news/2009/09/intel-launches-all-new-pc-architecture-with-core-i5i7-cpus.ars" href="http://arstechnica.com/hardware/news/2009/09/intel-launches-all-new-pc-architecture-with-core-i5i7-cpus.ars"&gt;http://arstechnica.com/hardware/news/2009/09/intel-launches-all-new-pc-architecture-with-core-i5i7-cpus.ars&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5416778419136716668-2607464341459899736?l=www.lukepuplett.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.lukepuplett.com/feeds/2607464341459899736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.lukepuplett.com/2009/09/intel-ready-for-on-die-gpu-with-core.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5416778419136716668/posts/default/260
