<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D04DRXs4fip7ImA9WhRUEUo.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038</id><updated>2012-01-21T11:59:34.536-08:00</updated><category term="MatLab" /><category term="Reading" /><category term="LINQ" /><category term="Visual Studio" /><category term="Nontechnical" /><category term="MVVM" /><category term="SQL" /><category term="Technology" /><category term="Javascript" /><category term="Screencast" /><category term="Entertainment" /><category term="F#" /><category term="DataBinding" /><category term="Windows" /><category term="lambda" /><category term="Objective C" /><category term="D" /><category term="Ninject" /><category term="XCode" /><category term="Programming" /><category term="Politics" /><category term="Embedded" /><category term="C#" /><category term="C++" /><category term="ReSharper" /><category term="WCF" /><category term="STL" /><category term="NetBurner" /><category term="Eclipse" /><category term="Mac" /><category term="Humor" /><category term="Office 2007" /><category term="CodeContracts" /><category term="iPad" /><category term="SVN" /><category term="WPF" /><category term="Unit Testing" /><category term="vista" /><category term=".NET" /><category term="Windows 7" /><title>Tod's Tomes</title><subtitle type="html">Thoughts on  programming in C# and C++.&lt;br&gt;
The C++ posts will focus on embedded systems, &lt;br&gt;
with an emphasis on the NetBurner and the Eclipse IDE.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://syncor.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>185</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/TodsTomes" /><feedburner:info uri="todstomes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DUUNQHw7eCp7ImA9WhRXEEs.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-6353756860512391378</id><published>2011-12-16T12:28:00.001-08:00</published><updated>2011-12-16T12:28:11.200-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-16T12:28:11.200-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Editing Percentages in XAML Part II</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QR4OctqOHxyXcJkC74yjVlcT6Qw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QR4OctqOHxyXcJkC74yjVlcT6Qw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QR4OctqOHxyXcJkC74yjVlcT6Qw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QR4OctqOHxyXcJkC74yjVlcT6Qw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Very recently (OK it was yesterday), I wrote up a &lt;a href="http://syncor.blogspot.com/2011/12/displaying-and-editing-percentages-in.html" target="_blank"&gt;blog entry&lt;/a&gt; on how to show a percentage and edit a percentage without it throwing exceptions or changing by orders of magnitude the backing field. Specifically storing 20% and .2 in the backend (making calculations easier) but showing the user 20% for the field. &lt;/p&gt;  &lt;p&gt;Today, I want to share something I learned from &lt;a href="http://stackoverflow.com/" target="_blank"&gt;StackOverflow&lt;/a&gt; member Rachel in her response to &lt;a href="http://stackoverflow.com/questions/8526476/how-do-i-get-simple-editing-on-a-percent-formatted-field-in-wpf-textbox/8526563#8526563" target="_blank"&gt;my question&lt;/a&gt; on why &lt;font face="Courier New"&gt;StringFormat=P&lt;/font&gt; doesn't work like the&lt;font face="Courier New"&gt; StringFormat=C&lt;/font&gt;. Rachel prefers to allow editing values in their native format, and after implementing her solution I decided I also preferred this approach. Instead of writing C# code that implements IValueConverter, this approach uses a trigger and all XAML.&lt;/p&gt;  &lt;p&gt;The downside to this approach is it isn't as general purpose as having a converter, on the plus side it results in less cluttered XAML at the control location. &lt;/p&gt;  &lt;p&gt;The XAML which implements the trigger could go anywhere, since these percentage fields are only used on one form in my solution I just added a &lt;font face="Courier New"&gt;&amp;lt;UserControl.Resources&amp;gt;&lt;/font&gt; tag at the top of the form and put the relevant XAML there. I'll only show one control, but I needed to replicate this code three times one for each control, modifying the binding in each case.&amp;#160; In the example below you can see I still bind to my CostMarkup property in both cases but when the code is being displayed it adds a &lt;font face="Courier New"&gt;StringFormat=P&lt;/font&gt;, when the code is being edited there is no formatting so the field changes from 20% to .2. When the user moves off the field the display reverts back to 20%. You'll also notice I incorporated my &lt;em&gt;ctrlSpacingTight&lt;/em&gt; style.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:696741ac-f0a0-4612-b6a3-e16cdcf2f793" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Trigger XAML&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;UserControl&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#800080"&gt;Resources&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;Style&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#00008b"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#800080"&gt;CostMarkupPct&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;TargetType&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#800080"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#00008b"&gt;Type&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#00008b"&gt;TextBox}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;          &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;BasedOn&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#00008b"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;ctrlSpacingTight}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Property&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#800080"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;               &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#00008b"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; CostMarkup&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;StringFormat&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=P}&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;Style&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#800080"&gt;Triggers&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;Trigger&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Property&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#800080"&gt;IsKeyboardFocused&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;True&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;Setter&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Property&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#800080"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                       &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#00008b"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; CostMarkup}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#00008b"&gt;Trigger&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#00008b"&gt;Style&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#800080"&gt;Triggers&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#00008b"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#00008b"&gt;UserControl&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#800080"&gt;Resources&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Down in the control XAML I replaced the Style tag and removed both the binding and the associated StringFormat.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:21e8419f-95a7-4a8a-a0ce-0f9131d0b5bd" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#00008b"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#00008b"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;CostMarkupPct}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-6353756860512391378?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/6353756860512391378/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=6353756860512391378" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/6353756860512391378?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/6353756860512391378?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/lqxTqqqHoVc/editing-percentages-in-xaml-part-ii.html" title="Editing Percentages in XAML Part II" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/12/editing-percentages-in-xaml-part-ii.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUIGRHg6cSp7ImA9WhRXEEs.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-412920899854629741</id><published>2011-12-15T18:33:00.001-08:00</published><updated>2011-12-16T12:32:05.619-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-16T12:32:05.619-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Displaying and Editing Percentages in WPF</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MRhHAA97xsisF4Pct3XPNf9ywrI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MRhHAA97xsisF4Pct3XPNf9ywrI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MRhHAA97xsisF4Pct3XPNf9ywrI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MRhHAA97xsisF4Pct3XPNf9ywrI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Showing percentages isn't even worth a blog post (spoiler alert StringFormat=P) but modifying the value proved to be more work than it seems it should be. If you show a percentage in a TextBox you want code similar to the following:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8683774f-d182-4cf5-8f36-f95ec4f8324e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;CostMarkup&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt; &lt;br&gt;                        &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;StringFormat&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=P,&lt;/span&gt;&lt;br&gt;                        &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Converter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;pctConverter}}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-IXYjDIRkSX8/Tuqt3lSpz6I/AAAAAAAABHI/nWU7j7VzQhk/s1600-h/image%25255B2%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 8px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh4.ggpht.com/-fxtylSinxvY/Tuqt3--2kDI/AAAAAAAABHQ/SjPpCRFUCsc/image_thumb.png?imgmax=800" width="165" height="70" /&gt;&lt;/a&gt;If you have a backing value for CostMarkup of say 0.25, it will show as 25% as shown to the left. Unfortunately, if you go in and edit the value to say 30 %, first you'll get some exceptions &lt;em&gt;(depending on your Debug-&amp;gt;Exception settings)&lt;/em&gt; and at best you'll end up with a red box indicating a validation error and at worst you'll have accidentally changed the markup to 3,000% (well in the case of a Markup that's kind of&amp;#160; a happy accident if you can actually sell anything).&amp;#160; If you try this same experiment with a field formatted for money (i.e. StringFormat=C) this doesn't happen. Obviously we avoid the multiply by 100 problem since we don't store currency in a different order of magnitude than how we display it, but that $ and all those commas don't cause us a problem either. That's really slick and it's unfortunate that the percent format doesn't do the same thing. I suspect the built in currency converter is helping out behind the scenes here.&lt;/p&gt;  &lt;p&gt;Luckily we can manually reproduce the behavior of currency by writing our converter. Writing your first converter probably seems like a lot of work but it's not that hard and once you have one in a project, it's pretty boiler plate to write additional ones. I start by creating a new Folder named &lt;em&gt;Converters&lt;/em&gt; under my &lt;em&gt;ViewModel&lt;/em&gt; folder. Then since I'm a big fan of small classes I create a PercentageConverter class in its own file, that implements the IValueConverter interface.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:19b581b9-9ec9-4c90-9a81-210b07401463" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Percentage Convertor Class&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;System&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;System&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Windows&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Data&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;namespace&lt;/span&gt; &lt;span style="color:#00008b"&gt;HssOrderTracker&lt;/span&gt;.&lt;span style="color:#00008b"&gt;ViewModel&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Converters&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;class&lt;/span&gt; &lt;span style="color:#4044e3"&gt;PercentageConverter&lt;/span&gt; : &lt;span style="color:#078398"&gt;IValueConverter&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;object&lt;/span&gt; &lt;span style="color:#008b8b"&gt;Convert&lt;/span&gt;(&lt;span style="color:#000080"&gt;object&lt;/span&gt; value, &lt;span style="color:#4044e3"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#000080"&gt;object&lt;/span&gt; parameter, &lt;span style="color:#00008b"&gt;System&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Globalization&lt;/span&gt;.&lt;span style="color:#4044e3"&gt;CultureInfo&lt;/span&gt; culture)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#000080"&gt;return&lt;/span&gt; value;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;object&lt;/span&gt; &lt;span style="color:#008b8b"&gt;ConvertBack&lt;/span&gt;(&lt;span style="color:#000080"&gt;object&lt;/span&gt; value, &lt;span style="color:#4044e3"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#000080"&gt;object&lt;/span&gt; parameter, &lt;span style="color:#00008b"&gt;System&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Globalization&lt;/span&gt;.&lt;span style="color:#4044e3"&gt;CultureInfo&lt;/span&gt; culture)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#000080"&gt;string&lt;/span&gt; &lt;span style="color:#354471"&gt;value_str&lt;/span&gt; = value.&lt;span style="color:#008b8b"&gt;ToString&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#000080"&gt;if&lt;/span&gt; (&lt;span style="color:#4044e3"&gt;String&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;IsNullOrWhiteSpace&lt;/span&gt;(&lt;span style="color:#354471"&gt;value_str&lt;/span&gt;)) &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#000080"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#354471"&gt;value_str&lt;/span&gt; = &lt;span style="color:#354471"&gt;value_str&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;TrimEnd&lt;/span&gt;(culture.&lt;span style="color:#0080c0"&gt;NumberFormat&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;PercentSymbol&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToCharArray&lt;/span&gt;());&lt;/li&gt; &lt;li&gt;           &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#000080"&gt;double&lt;/span&gt; &lt;span style="color:#354471"&gt;result&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#000080"&gt;if&lt;/span&gt;(&lt;span style="color:#00008b"&gt;Double&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;TryParse&lt;/span&gt;(&lt;span style="color:#354471"&gt;value_str&lt;/span&gt;, &lt;span style="color:#000080"&gt;out&lt;/span&gt; &lt;span style="color:#354471"&gt;result&lt;/span&gt;))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#354471"&gt;result&lt;/span&gt;/100.0;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#000080"&gt;return&lt;/span&gt; value;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Since I'm going to use percentage fields in various places in my application, I modify my SharedResources.xaml file which holds my shared resource dictionary. At the top of my resource dictionary I add&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0b0d4caf-755b-4864-94b7-09576006aae9" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Converters&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;clr-namespace:&lt;/span&gt;&lt;span style="color:#00008b"&gt;HssOrderTracker&lt;/span&gt;&lt;span style="color:#0000ff"&gt;.&lt;/span&gt;&lt;span style="color:#00008b"&gt;ViewModel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;.&lt;/span&gt;&lt;span style="color:#00008b"&gt;Converters&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;Then I can easily add a reference for any converter I write. For the current percent converter it looks like:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c1f74754-4108-4728-9840-07ce157d42af" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Converters&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#4044e3"&gt;PercentageConverter&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:Key=&amp;quot;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;pctConverter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;Once all this in place, the actual XAML is a piece of cake to modify. I just add a reference to the Convertor in the binding. The final XAML becomes:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3b764ccd-7a14-44eb-92d4-d0d1c95e0bcf" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;XAML with convertor specified&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;CostMarkup&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt; &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                       &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;StringFormat&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=P,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                       &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Converter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;pctConverter}}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Now when I edit the field, the % symbol can stay there and I can enter the value as a percentage, changing the 25 to a 30 and the backing field gets set to .3, the screen shows 30% and all is well.&lt;/p&gt;  &lt;p&gt;For completeness sake, I'll mention that I modify my app.xaml file to make my resource dictionary available as shown below:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7a80c81d-5af9-46a4-b674-e23b68f6c451" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Sharing the Dictionary&lt;/div&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Application&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Resources&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#0080c0"&gt;MergedDictionaries&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;             &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Source&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;View&amp;#92;Reusable&amp;#92;SharedResources.xaml&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#0080c0"&gt;MergedDictionaries&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Application&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Resources&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;If you would prefer to edit your percentages in their native format (i.e. .25), use only XAML and forgo writing an IValueConverter check out my second post on this topic: &lt;strong&gt;&lt;a href="http://syncor.blogspot.com/2011/12/editing-percentages-in-xaml-part-ii.html" target="_blank"&gt;Editing Percentages in XAML Part II&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-412920899854629741?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/412920899854629741/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=412920899854629741" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/412920899854629741?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/412920899854629741?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/YhZgTQyZqjE/displaying-and-editing-percentages-in.html" title="Displaying and Editing Percentages in WPF" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-fxtylSinxvY/Tuqt3--2kDI/AAAAAAAABHQ/SjPpCRFUCsc/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/12/displaying-and-editing-percentages-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4DQXc4eip7ImA9WhRSGUU.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-9141635860835534728</id><published>2011-11-22T10:52:00.001-08:00</published><updated>2011-11-22T10:52:50.932-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-22T10:52:50.932-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Exceptional Extensions</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TnlTaIfIHGou5W4VsD6PZEF3JSM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TnlTaIfIHGou5W4VsD6PZEF3JSM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TnlTaIfIHGou5W4VsD6PZEF3JSM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TnlTaIfIHGou5W4VsD6PZEF3JSM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I didn't fully embrace extensions when the were introduced, I'm finding out that was a mistake. I have started a small library with extensions for the string and exception classes. I'm sure as time goes on this library will grow. One of the things I like the most is how innocuous you can make them. You put them in your own namespace and they'll never bother anyone, but they can always come to your aid when summoned. &lt;/p&gt;  &lt;p&gt;Recently I was working with Entity Framework and got a Validation Error. Finding out how to retrieve the actual errors was not intuitive and is exactly the kind of thing I immediately forget after I write it. Then I need it again in&amp;#160; a future project, so I either write a blog so I can remember or I go searching through Subversion. Now, when appropriate I can just add it to my extension library.&amp;#160; Inside my Syncor.Extensions.ExceptionExtensions class I recently added the following two extension methods (the first one was inspried by &lt;a href="http://stackoverflow.com/q/7798264/633267" target="_blank"&gt;this answer&lt;/a&gt; at &lt;a href="http://stackoverflow.com/" target="_blank"&gt;StackOverflow&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fa0b1e18-c7ad-4ecc-a4d1-6ed32838132a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Two Exception Extension Method&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;static&lt;/span&gt; &lt;span style="color:#000080"&gt;string&lt;/span&gt; &lt;span style="color:#008b8b"&gt;GetAllValidationErrors&lt;/span&gt; (&lt;span style="color:#000080"&gt;this&lt;/span&gt; &lt;span style="color:#4044e3"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#4044e3"&gt;DbEntityValidationResult&lt;/span&gt;&amp;gt; eveList)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#4044e3"&gt;StringBuilder&lt;/span&gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;StringBuilder&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    eveList.&lt;span style="color:#008b8b"&gt;ForEach&lt;/span&gt;(eve=&amp;gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Append&lt;/span&gt;(eve.&lt;span style="color:#008b8b"&gt;GetValidationErrors&lt;/span&gt;()) );&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToString&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;static&lt;/span&gt; &lt;span style="color:#000080"&gt;string&lt;/span&gt; &lt;span style="color:#008b8b"&gt;GetValidationErrors&lt;/span&gt;(&lt;span style="color:#000080"&gt;this&lt;/span&gt; &lt;span style="color:#4044e3"&gt;DbEntityValidationResult&lt;/span&gt; eve)&lt;/li&gt; &lt;li&gt;{           &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#4044e3"&gt;StringBuilder&lt;/span&gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;StringBuilder&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;string&lt;/span&gt; &lt;span style="color:#354471"&gt;entity_msg&lt;/span&gt; = &lt;span style="color:#4044e3"&gt;String&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Format&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;Entity of type:{&lt;/span&gt;&lt;span style="color:#3cb371"&gt;0}&lt;/span&gt;&lt;span style="color:#6300c6"&gt;, in state:{&lt;/span&gt;&lt;span style="color:#3cb371"&gt;1}&lt;/span&gt;&lt;span style="color:#6300c6"&gt;, has the following validation errors:&amp;#92;n&amp;quot;&lt;/span&gt;,&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                               eve.&lt;span style="color:#0080c0"&gt;Entry&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Entity&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;GetType&lt;/span&gt;().&lt;span style="color:#0080c0"&gt;Name&lt;/span&gt;,&lt;/li&gt; &lt;li&gt;                               eve.&lt;span style="color:#0080c0"&gt;Entry&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;State&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Append&lt;/span&gt;(&lt;span style="color:#354471"&gt;entity_msg&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;var&lt;/span&gt; &lt;span style="color:#354471"&gt;err_msgs&lt;/span&gt; = eve.&lt;span style="color:#0080c0"&gt;ValidationErrors&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToList&lt;/span&gt;().&lt;span style="color:#008b8b"&gt;Select&lt;/span&gt;(ve =&amp;gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#4044e3"&gt;String&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Format&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;  Property: {&lt;/span&gt;&lt;span style="color:#3cb371"&gt;0}&lt;/span&gt;&lt;span style="color:#6300c6"&gt;, Error: {&lt;/span&gt;&lt;span style="color:#3cb371"&gt;1}&amp;#92;&lt;/span&gt;&lt;span style="color:#6300c6"&gt;n&amp;quot;&lt;/span&gt;, ve.&lt;span style="color:#0080c0"&gt;PropertyName&lt;/span&gt;, ve.&lt;span style="color:#0080c0"&gt;ErrorMessage&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#354471"&gt;err_msgs&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToList&lt;/span&gt;().&lt;span style="color:#008b8b"&gt;ForEach&lt;/span&gt;(msg =&amp;gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Append&lt;/span&gt;(msg));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToString&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;You could easily make this one method if you wanted. I just find it more flexible and easier to understand when broken apart. Not only will I never forget how to do it, I won't need to remember, and the code that uses this is now pretty clean:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4f47d3da-9712-49ce-91b1-87d733a2c6b5" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;The clean catch&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;catch&lt;/span&gt; (&lt;span style="color:#4044e3"&gt;DbEntityValidationException&lt;/span&gt; &lt;span style="color:#354471"&gt;ex&lt;/span&gt;)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;string&lt;/span&gt; &lt;span style="color:#354471"&gt;full_msg&lt;/span&gt; = &lt;span style="color:#354471"&gt;ex&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;EntityValidationErrors&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToList&lt;/span&gt;().&lt;span style="color:#008b8b"&gt;GetAllValidationErrors&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008b8b"&gt;RaiseError&lt;/span&gt;(&lt;span style="color:#354471"&gt;full_msg&lt;/span&gt;);              &lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;      &lt;p&gt;Another useful exception extension is one that chains together the immediate extension message and any messages from inner extensions. It looks like this&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5c94c8c0-f0cf-49a0-bd68-ea450991dcbc" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Chain Inner Exception Messages&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;static&lt;/span&gt; &lt;span style="color:#000080"&gt;string&lt;/span&gt; &lt;span style="color:#008b8b"&gt;ChainExceptions&lt;/span&gt;( &lt;span style="color:#000080"&gt;this&lt;/span&gt; &lt;span style="color:#4044e3"&gt;Exception&lt;/span&gt; source)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#4044e3"&gt;StringBuilder&lt;/span&gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;StringBuilder&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;while&lt;/span&gt; (source != &lt;span style="color:#000080"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;AppendFormat&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;{&lt;/span&gt;&lt;span style="color:#3cb371"&gt;0}&amp;#92;&lt;/span&gt;&lt;span style="color:#6300c6"&gt;n&amp;quot;&lt;/span&gt;, source.&lt;span style="color:#0080c0"&gt;Message&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        source = source.&lt;span style="color:#0080c0"&gt;InnerException&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#354471"&gt;sb&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ToString&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The use of this extension might look like:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:62be5ee9-4097-439d-b32e-9b7dc9580886" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Using ChainExceptions&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;catch&lt;/span&gt; (&lt;span style="color:#4044e3"&gt;Exception&lt;/span&gt; &lt;span style="color:#354471"&gt;ex&lt;/span&gt;)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;var&lt;/span&gt; &lt;span style="color:#354471"&gt;msg&lt;/span&gt; = &lt;span style="color:#4044e3"&gt;String&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Format&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;An error occurred while trying to save changes back to the database.&amp;#92;n{&lt;/span&gt;&lt;span style="color:#3cb371"&gt;0}&lt;/span&gt;&lt;span style="color:#6300c6"&gt;&amp;quot;&lt;/span&gt;,&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;               &lt;span style="color:#354471"&gt;ex&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ChainExceptions&lt;/span&gt;());&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008b8b"&gt;RaiseError&lt;/span&gt;(&lt;span style="color:#354471"&gt;msg&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&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/7714188728416201038-9141635860835534728?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/9141635860835534728/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=9141635860835534728" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/9141635860835534728?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/9141635860835534728?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/FOwjkH39Chs/i-didnt-fully-embrace-extensions-when.html" title="Exceptional Extensions" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/11/i-didnt-fully-embrace-extensions-when.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQGQXwyfyp7ImA9WhRTE08.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-454177106838561941</id><published>2011-11-03T05:12:00.000-07:00</published><updated>2011-11-03T05:12:00.297-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-03T05:12:00.297-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><title>Don't you just hate inconsistent hives?</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/1VWaT_2ukS_WLV_x1PfQuEomHnE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1VWaT_2ukS_WLV_x1PfQuEomHnE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/1VWaT_2ukS_WLV_x1PfQuEomHnE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1VWaT_2ukS_WLV_x1PfQuEomHnE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;While trying to install some SQL Server tools recently, I found out my computer was in violation of the &amp;quot;Performance counter registry hive consistency check&amp;quot; rule. Oh no! The link next to this error sends you to a &lt;a href="http://support.microsoft.com/kb/300956" target="_blank"&gt;Microsoft knowledge base article&lt;/a&gt; that has a set of directions that made me cancel all thoughts of getting any productive work done for the rest of the day. &lt;/p&gt;  &lt;p&gt;Luckily a &lt;a href="http://geekswithblogs.net/robz/archive/2008/08/10/possible-performance-counter-corruption-or-performance-counters-are-just-disabled.aspx" target="_blank"&gt;geek with a blog&lt;/a&gt; figured out that all of this is unnecessary. I was able to follow step 2 on his blog which was to just open the registry entry for &lt;font face="Courier New"&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib&lt;/font&gt; and set the &lt;font face="Courier New"&gt;Disable Performance Counters&lt;/font&gt; entry from 1 to 0. (I'm suspecting that implementing a suggestion for optimization by JV16 caused this.)&amp;#160; I reran the SQL installer and no more hives! Well no more inconsistent hives anyway. Back to being a worker bee. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-454177106838561941?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/454177106838561941/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=454177106838561941" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/454177106838561941?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/454177106838561941?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/XU-BkqrxRfo/don-you-just-hate-inconsistent-hives.html" title="Don&amp;#39;t you just hate inconsistent hives?" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/11/don-you-just-hate-inconsistent-hives.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0IDQHY7eyp7ImA9WhRQE0o.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-4081643269347598182</id><published>2011-10-28T10:56:00.001-07:00</published><updated>2011-12-08T11:12:51.803-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-08T11:12:51.803-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>New WPF DataGrid Rows Throw on SelectedItem Binding</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6IKuKWfCKn-Bzzi3k_NTjsPuO38/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6IKuKWfCKn-Bzzi3k_NTjsPuO38/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6IKuKWfCKn-Bzzi3k_NTjsPuO38/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6IKuKWfCKn-Bzzi3k_NTjsPuO38/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;In my DataGrid I have the attribute for SelectedItem bound to a property on my ModelView. This works perfectly for existing data, not so much for creating a new row. I don't understand why, but the application first throws an exception about a conversion problem with MS.Internal.NamedObject, whatever that is. Then&amp;nbsp; I eventually got an exception that had the magic word NewItemPlaceholder in the message. This was the key to finding the solution.&amp;nbsp; In effect what I think is happening is when a new row is created, the binding to the SelectedItem is failing. I think it may be related to the order in which things are happening. The solutions boils down to telling the system to not bother doing the binding when a new row is encountered.&amp;nbsp; This requires writing an IValueConverter class and having ConvertBack return DependencyProperty.UnsetValue. Rather that duplicate the fine work of Nigel Spencer, you can get all the details on doing this from his blog post &lt;a href="http://blog.spencen.com/2009/04/30/problems-binding-to-selectedvalue-with-microsoftrsquos-wpf-datagrid.aspx" target="_blank"&gt;Problems binding to SelectedValue with Microsoft's WPF DataGrid&lt;/a&gt;. Thank's Nigel, you're a sanity saver.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-4081643269347598182?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/4081643269347598182/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=4081643269347598182" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/4081643269347598182?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/4081643269347598182?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/-3e1696FVb4/new-wpf-datagrid-rows-throw-on.html" title="New WPF DataGrid Rows Throw on SelectedItem Binding" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/10/new-wpf-datagrid-rows-throw-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIASX06fCp7ImA9WhdaFks.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-5880820342657834394</id><published>2011-10-26T13:52:00.001-07:00</published><updated>2011-10-26T15:02:28.314-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T15:02:28.314-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Crashing Visual Studio 2010 with XAML</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GnFHzv0RD_h-gkKOeJL_Q7NAGK8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GnFHzv0RD_h-gkKOeJL_Q7NAGK8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GnFHzv0RD_h-gkKOeJL_Q7NAGK8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GnFHzv0RD_h-gkKOeJL_Q7NAGK8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I recently found two ways to crash the Visual Studio IDE. The first (and trickier of the two) involves adding a design time DataContext for a WPF User Control. Setting the d:DesignContext strikes me as still very useful but it helps to be aware of the potential dangers. It took me the better part of half a day to track the problem down. &lt;/p&gt;  &lt;p&gt;The first mistake I made was I added a design time DataContext to a parent user control without making sure that all the child user controls were setting a design time DataContext. This isn't actually a requirement, but I would &lt;strong&gt;strongly&lt;/strong&gt; suggest you always do this, because then you'll know what's really causing the crash. In my case, multiple generations down I had a very simple control that was unhappy but I didn't know it because the UserControl wrapping that simple control wasn't using a design time DataContext.&lt;/p&gt;  &lt;h2&gt;It Pays to Data Bind to the EXACT Matching Type&lt;/h2&gt;  &lt;p&gt;I was using the IntegerUpDown control from the &lt;a href="http://wpftoolkit.codeplex.com/"&gt;Extended WPF Toolkit&lt;/a&gt;.&amp;#160; It's a very useful control but it appears to be a bit persnickety when it comes to using the d:DesignContext. Keep in&amp;#160; mind my XAML and code worked perfectly when running,&amp;#160; it was just when Visual Studio went to parse the XAML that I had problems. It boiled down to the data binding on the Value property on the IntegerUpDown control. It expects to be bound to an int? (a nullable int) and I was binding it to a property of type int.&amp;#160; You aren't going to get any compiler errors or warnings when you do this, or even any hints from &lt;a href="http://www.jetbrains.com/resharper"&gt;ReSharper&lt;/a&gt; in the XAML code. Everything will look and work fine, until you add a design time DataContext. I suspect that when running I didn't have a problem because the Property was never null, but at design time it was.&lt;/p&gt;  &lt;h2&gt;Recursion Crash&lt;/h2&gt;  &lt;p&gt;If you're looking for another way to crash Visual Studio (aren't we all), Try referencing a view inside of itself. In my QuoteView.xaml I meant to write:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9c01acc6-2a38-4bc3-aa24-c47b1423fcc8" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Quote&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;QuoteHeaderView&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; DataContext&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; QuoteHeaderVm}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;However, instead I wrote &amp;lt;Quote:QuoteView … /&amp;gt; which crashes surprisingly fast considering I have a lot of RAM, but maybe Visual Studio was able to short circuit running out of stack and just gave up and went home early. &lt;/p&gt;  &lt;p&gt;The only reason I mention this bone-headed mistake is because prior to WPF I don't think I could ever do anything in my code to crash Visual Studio. That is no longer true and it's worthwhile to be aware of the price of progress.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-5880820342657834394?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/5880820342657834394/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=5880820342657834394" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5880820342657834394?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5880820342657834394?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/eCm-LDIweB4/crashing-visual-studio-2010-with-xaml.html" title="Crashing Visual Studio 2010 with XAML" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/10/crashing-visual-studio-2010-with-xaml.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQAQXg8cSp7ImA9WhdaFUk.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-7250070655525003931</id><published>2011-10-25T05:39:00.000-07:00</published><updated>2011-10-25T05:39:00.679-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-25T05:39:00.679-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Reusable WPF</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/EpE9IZOZ_j5LDlhBc934JbZ-2nk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EpE9IZOZ_j5LDlhBc934JbZ-2nk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/EpE9IZOZ_j5LDlhBc934JbZ-2nk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EpE9IZOZ_j5LDlhBc934JbZ-2nk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;One of the immediate benefits I saw in moving to WPF was the ability to design a small (or large) user control and reuse it, both multiple times in the same application and in some cases across multiple applications. I have now done both, and even though I'm a relative newcomer to WPF, I feel there are a few simple techniques worth documenting that make the process of reusing components easier and cleaner. &lt;/p&gt;  &lt;h2&gt;Who's Got the DataContext&lt;/h2&gt;  &lt;p&gt;The biggest hurdle for me was binding to the proper data context for the control. Even in the same application there is no guarantee that a user control will be nested in the same chain. Obviously across applications you can't rely on the same data context being present. This means in general you don't want the actual data context to be set anywhere in the view, i.e. not in the xaml and not in the code behind. This doesn't mean you can't bind to the properties by name. In my case I create a View/ViewModel pairing for every reusable control. The two go together everywhere just like an old married couple. The property names will never change. Not having a DataContext does mean that tools like &lt;a href="http://www.jetbrains.com/resharper"&gt;Resharper&lt;/a&gt; will put a info icon under the property letting you know it couldn't find a DataContext to resolve the property against. Not that big a deal, and if you want, you can always set the design time DataContext to make sure you got the names right. You'll probably want to remove that design time context once you plan on reusing the control across multiple solutions.&amp;#160; Here's how one tab in the final solution was structured. &lt;/p&gt;  &lt;h2&gt;A Real World Example&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-YNc6Ws4oYnE/TqXgGJdVA-I/AAAAAAAABGg/i_oP7shZNBU/s1600-h/SNAGHTMLb42011%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTMLb42011" border="0" alt="SNAGHTMLb42011" src="http://lh6.ggpht.com/-3Smj_fROpkc/TqXgHO2MVaI/AAAAAAAABGo/MadusxqA50I/SNAGHTMLb42011_thumb%25255B1%25255D.png?imgmax=800" width="884" height="437" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Working with the Reusable Control&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-jT0iIw2D2G4/TqXgHVrYB4I/AAAAAAAABGw/iUkFQNZD074/s1600-h/image%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh5.ggpht.com/-QiB7RERTkqs/TqXgHgApB4I/AAAAAAAABG4/03FUPEXaXvA/image_thumb%25255B1%25255D.png?imgmax=800" width="126" height="73" /&gt;&lt;/a&gt; The line item navigation box for this order entry system needs to be used on multiple tabs. On some tabs it will be nested directly within the the GroupBox that holds the line items on other tabs (like the one shown) it may be a level deeper inside a grouping of controls for the line items. The user control takes up only about 40 lines of xaml (included below)&amp;#160; and does nothing more than allow the user to jump to a particular line item (there can be hundreds) and scroll that line item into view, or bring up a dialog allowing the user to search by the line item description and jump to that line item again bringing it into view. There is &lt;strong&gt;NOTHING&lt;/strong&gt; in the code behind except the default call to&amp;#160; &lt;strong&gt;InitializeComponent&lt;/strong&gt; method call. All the logic for the control is in the LineItemNavViewModel.&amp;#160; The question is where do I put a property that returns the LineItemNavViewModel such that the control can find it.&lt;/p&gt;  &lt;h2&gt;The Navigation&lt;/h2&gt;  &lt;p&gt;While the line item navigation box may be in one of several container controls, and those controls may themselves be nested in other controls, they all only make sense in the context of an actual order. Therefore I decided to add a property at the OrderEntryViewModel that holds my LineItemNavViewModel. &lt;/p&gt;  &lt;p&gt;The question becomes: how do I reach up from inside a control that already has an assigned data context to a parent control an unknown number of levels above that has a different data context? It turns out it's not that hard. The syntax appears a little convoluted but the RelativeSource attribute is very flexible. &lt;/p&gt;  &lt;p&gt;For the sake of completeness, let me specify how the parent container is used. The LineItemNavView sits in another control LineItemActionsView (the red outlined box in the image).&amp;#160; The code for that row looks like this:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:21156fd0-b971-4c90-b2a4-5d2eb5c5fd67" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Order&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#4044e3"&gt;LineItemActionsView&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000"&gt;.&lt;/span&gt;&lt;span style="color:#008b8b"&gt;Row&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;br&gt;                       &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;DataContext&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;LineItemActionVm}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You can see the DataContext is set to LineItemActionVm and not to the parent OrderEntryViewModel.&amp;#160;&amp;#160; In the LineItemActionsView.xaml I specify the&amp;#160; LineItemNavView control as follows: &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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:15d0d00e-2ee3-40df-8b3f-166a9ba1585f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Shared&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#4044e3"&gt;LineItemNavView&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000"&gt;.&lt;/span&gt;&lt;span style="color:#008b8b"&gt;Column&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt; &lt;br&gt;                       &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;DataContext&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#4044e3"&gt;RelativeSource&lt;/span&gt; &lt;br&gt;    &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#800080"&gt;FindAncestor&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#0080c0"&gt;AncestorType&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#0080c0"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Type&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Order&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#4044e3"&gt;OrderTabLineItemsView}}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=DataContext.LineItemNavVm}&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;em&gt;Shared:&lt;/em&gt;&amp;#160; and &lt;em&gt;Order:&lt;/em&gt; are&amp;#160; just&amp;#160; xmlns paths to the clr-namespaces that hold my xaml code for the respective user controls. The &lt;em&gt;RelativeSource&lt;/em&gt; is specifying that somewhere up the chain of controls holding the LineItemActionsView is a user control of type &lt;strong&gt;OrderTabLineItemsView&lt;/strong&gt; (the View that holds the entire tab). The Path portion of the binding says that I want to reuse the &lt;strong&gt;DataContext&lt;/strong&gt; of&amp;#160; that view, and in that DataContext there will be a property named &lt;strong&gt;LineItemNavVm&lt;/strong&gt; that holds my LineItemNavViewModel.&amp;#160; &lt;/p&gt;  &lt;p&gt;There were two things that took me a while to discover, one was just the rather strange double use of RelativeSource, and the second was discovering that I had to explicitly state in the path, that I wanted the DataContext. It seemed obvious once I discovered it but without a rather &lt;a href="http://stackoverflow.com/questions/3316218/relativesource-findancestor-without-static-resource-in-mvvm"&gt;casual reference&lt;/a&gt; to it on &lt;a href="http://stackoverflow.com/" target="_blank"&gt;StackOverflow&lt;/a&gt; I might still be struggling. &lt;/p&gt;  &lt;p&gt;In my case everywhere I reuse this control I'll be able to use this same Binding but that's only because in this application I know there will always be an ancestor Order:OrderTabLineItemsView. If there weren't it wouldn't be a problem, it just means I need to specify a RelativeSource that makes sense for the application where I want to use the control. Remember the reusable control knows nothing about its DataContext, it just references the properties on its ViewModel. As long as you specify where that ViewModel can be found, the control will work. In fact if I saw this particular control as being useful across multiple applications I would move it into its own assembly, or at least into an assembly with other related reusable controls. &lt;/p&gt;  &lt;p&gt;There are other ways to use the RelativeSource binding. You can specify another control explicitly using an x:Type of UserControl and the AncestorLevel attribute to specify the level where the UserControl of interest can be found. This struck me as a rather fragile way to do things but nonetheless might be prove to be a useful technique to know about. Below as promised is the entire XAML of the little user control LineItemNavView. Those three properties, &lt;em&gt;MaxLineItem&lt;/em&gt;, &lt;em&gt;CurrentLineItem&lt;/em&gt; and &lt;em&gt;FindLineItemCommand&lt;/em&gt; are all in the LineItemNavViewModel class (they are shown in red because the xaml can't resolve them because it doesn't know the data context.).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc6e4295-3482-4740-8db0-cb441c897bdf" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;LineItemNavView xaml&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;UserControl&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:Class=&amp;quot;&lt;/span&gt;&lt;span style="color:#00008b"&gt;HssOrderTracker&lt;/span&gt;&lt;span style="color:#0000ff"&gt;.&lt;/span&gt;&lt;span style="color:#00008b"&gt;View&lt;/span&gt;&lt;span style="color:#0000ff"&gt;.&lt;/span&gt;&lt;span style="color:#00008b"&gt;OrderEntry&lt;/span&gt;&lt;span style="color:#0000ff"&gt;.&lt;/span&gt;&lt;span style="color:#00008b"&gt;Shared&lt;/span&gt;&lt;span style="color:#0000ff"&gt;.&lt;/span&gt;&lt;span style="color:#4044e3"&gt;LineItemNavView&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#0080c0"&gt;x&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#0080c0"&gt;mc&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;            &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#0080c0"&gt;d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/expression/blend/2008&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#ff0000"&gt; xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#0080c0"&gt;extToolkit&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;mc&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:Ignorable=&amp;quot;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;            &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:DesignHeight=&amp;quot;300&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;d&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:DesignWidth=&amp;quot;300&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;GroupBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Header&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Line Item Nav.&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;             &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;gbBackground}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;             &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Foreground&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;Black&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Margin&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;0,0,0,2&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#0080c0"&gt;ColumnDefinitions&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;auto&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Width&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;auto&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#a31515"&gt;.&lt;/span&gt;&lt;span style="color:#0080c0"&gt;ColumnDefinitions&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#0080c0"&gt;extToolkit&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#4044e3"&gt;IntegerUpDown&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000"&gt;.&lt;/span&gt;&lt;span style="color:#008b8b"&gt;Column&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                     &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;nudSpacingTight}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                                     &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Minimum&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                     &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Maximum&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; MaxLineItem}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                                     &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; CurrentLineItem}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                     &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;UseLayoutRounding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;False&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                                     &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;IsTabStop&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;False&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;btnStyleNav}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                   &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000"&gt;.&lt;/span&gt;&lt;span style="color:#008b8b"&gt;Column&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                   &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Command&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FindLineItemCommand}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                   &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;IsTabStop&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;False&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Orientation&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#800080"&gt;Horizontal&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Image&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Source&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;/Artwork/Find.png&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                          &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;btnImage}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;GroupBox&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#4044e3"&gt;UserControl&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;For the insatiably curious here is the LineItemNavViewModel code:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9a08ecb7-0938-4756-932d-4043385e03c0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;LineItemNavViewModel&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;System&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Windows&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;System&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Windows&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Input&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;HssOrderTracker&lt;/span&gt;.&lt;span style="color:#00008b"&gt;View&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Dialogs&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;JetBrains&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Annotations&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;Syncor&lt;/span&gt;.&lt;span style="color:#00008b"&gt;MvvmLib&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; &lt;span style="color:#00008b"&gt;Syncor&lt;/span&gt;.&lt;span style="color:#00008b"&gt;Ninject&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;namespace&lt;/span&gt; &lt;span style="color:#00008b"&gt;HssOrderTracker&lt;/span&gt;.&lt;span style="color:#00008b"&gt;ViewModel&lt;/span&gt;.&lt;span style="color:#00008b"&gt;OrderEntry&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    [&lt;span style="color:#4044e3"&gt;IoC&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;class&lt;/span&gt; &lt;span style="color:#4044e3"&gt;LineItemNavViewModel&lt;/span&gt; : &lt;span style="color:#4044e3"&gt;ViewModelBase&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;readonly&lt;/span&gt; &lt;span style="color:#4044e3"&gt;OrderEntryViewModel&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_orderEntryViewModel&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#4044e3"&gt;LineItemNavViewModel&lt;/span&gt;(&lt;span style="color:#4044e3"&gt;OrderEntryViewModel&lt;/span&gt; orderEntryViewModel)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0080c0"&gt;_orderEntryViewModel&lt;/span&gt; = orderEntryViewModel;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#008000"&gt;//Take and int and pass it to the OrderEntryViewModel which can turn it into a OrderLineItemViewModel&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#008000"&gt;//and raise the property change to the view.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;int&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_currentLineItem&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        [&lt;span style="color:#4044e3"&gt;UsedImplicitly&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;int&lt;/span&gt; &lt;span style="color:#0080c0"&gt;CurrentLineItem&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_currentLineItem&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008b8b"&gt;set&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#000080"&gt;if&lt;/span&gt; (&lt;span style="color:#000080"&gt;value&lt;/span&gt; == &lt;span style="color:#0080c0"&gt;_currentLineItem&lt;/span&gt;) &lt;span style="color:#000080"&gt;return&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0080c0"&gt;_currentLineItem&lt;/span&gt; = &lt;span style="color:#000080"&gt;value&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0080c0"&gt;_orderEntryViewModel&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;SetCurrentLineItem&lt;/span&gt;(&lt;span style="color:#0080c0"&gt;_currentLineItem&lt;/span&gt;-1);&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#008b8b"&gt;RaisePropertyChanged&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;CurrentLineItem&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        [&lt;span style="color:#4044e3"&gt;UsedImplicitly&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;int&lt;/span&gt; &lt;span style="color:#0080c0"&gt;MaxLineItem&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_orderEntryViewModel&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;LineItems&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Count&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;#region&lt;/span&gt; FindLineItemCommand&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#4044e3"&gt;RelayCommand&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_findLineItemCommand&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        [&lt;span style="color:#4044e3"&gt;UsedImplicitly&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#078398"&gt;ICommand&lt;/span&gt; &lt;span style="color:#0080c0"&gt;FindLineItemCommand&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_findLineItemCommand&lt;/span&gt; ?? (&lt;span style="color:#0080c0"&gt;_findLineItemCommand&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;RelayCommand&lt;/span&gt;(x =&amp;gt; &lt;span style="color:#008b8b"&gt;FindLineItemCommandExecute&lt;/span&gt;(), x =&amp;gt; &lt;span style="color:#0080c0"&gt;FindLineItemCommandCanExecute&lt;/span&gt;)); }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#0080c0"&gt;FindLineItemCommandCanExecute&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_orderEntryViewModel&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;LineItems&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Count&lt;/span&gt; &amp;gt; 1; } &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;void&lt;/span&gt; &lt;span style="color:#008b8b"&gt;FindLineItemCommandExecute&lt;/span&gt;()&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#4044e3"&gt;FindLineItemDlogView&lt;/span&gt; &lt;span style="color:#354471"&gt;find_dlog_view&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;FindLineItemDlogView&lt;/span&gt;(&lt;span style="color:#0080c0"&gt;_orderEntryViewModel&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;LineItems&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#354471"&gt;find_dlog_view&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Owner&lt;/span&gt;=&lt;span style="color:#4044e3"&gt;Application&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Current&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;MainWindow&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#000080"&gt;if&lt;/span&gt; ( &lt;span style="color:#354471"&gt;find_dlog_view&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;ShowDialog&lt;/span&gt;() == &lt;span style="color:#000080"&gt;true&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#000080"&gt;if&lt;/span&gt; (&lt;span style="color:#354471"&gt;find_dlog_view&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;SelectedLineNumber&lt;/span&gt; != -1)&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    &lt;span style="color:#0080c0"&gt;CurrentLineItem&lt;/span&gt; = &lt;span style="color:#354471"&gt;find_dlog_view&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;SelectedLineNumber&lt;/span&gt; + 1;&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-7250070655525003931?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/7250070655525003931/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=7250070655525003931" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/7250070655525003931?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/7250070655525003931?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/1MhEN4RytP4/reusable-wpf.html" title="Reusable WPF" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-3Smj_fROpkc/TqXgHO2MVaI/AAAAAAAABGo/MadusxqA50I/s72-c/SNAGHTMLb42011_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/10/reusable-wpf.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEEQH4yfCp7ImA9WhdUGUk.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-5426017681049517509</id><published>2011-10-06T17:16:00.001-07:00</published><updated>2011-10-06T17:16:41.094-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-06T17:16:41.094-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>Visio and the L2100 Error</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/UlWBkx4kC1Syx4oeQbhZsw2wzYs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UlWBkx4kC1Syx4oeQbhZsw2wzYs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/UlWBkx4kC1Syx4oeQbhZsw2wzYs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UlWBkx4kC1Syx4oeQbhZsw2wzYs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Every now and then Visio for Enterprise Architects (and I suspect other versions) seems to to corrupt itself. While this is the version from 2003, it still appears to be the last one with full ERD support.&amp;#160; I'll get an error about a relationship not connected at both ends. The only problem is the relationship is not visible on the diagram anywhere so there is no way to &amp;quot;fix&amp;quot; it, or delete it.&amp;#160; Luckily I found a &lt;a href="http://social.technet.microsoft.com/Forums/en-CA/visiogeneral/thread/3216ab11-08d8-4bdd-898c-2d473793ec1c"&gt;solution on Microsoft's technet forums&lt;/a&gt;.&amp;#160; I'm just repeating here with some additional annotation the advice I found there:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Select &lt;em&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/em&gt;→&lt;em&gt;&lt;strong&gt;Macros→Visual Basic Editor&lt;/strong&gt;&lt;/em&gt; from the Visio menus (or hit Alt-F11). &lt;/li&gt;    &lt;li&gt;Select &lt;em&gt;&lt;strong&gt;Tools→References&lt;/strong&gt;&lt;/em&gt;&amp;#160; from the Visual Basic editor. &lt;/li&gt;    &lt;li&gt;Check &lt;strong&gt;&lt;em&gt;Microsoft Visio Database Modeling Engine Type Library&lt;/em&gt;&lt;/strong&gt; and       &lt;br /&gt;click the OK button to dismiss the dialog. Yes, the are in alphabetical order, and notice this is under &amp;quot;Microsoft&amp;quot; not under &amp;quot;Visio&amp;quot; &lt;/li&gt;    &lt;li&gt;If you don't have a code window open use the &lt;strong&gt;&lt;em&gt;Insert&lt;/em&gt; → &lt;em&gt;Module&lt;/em&gt;&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Copy this subroutine shown below and paste it into the text area under &lt;em&gt;General.&lt;/em&gt;&lt;/li&gt;    &lt;li&gt; Select &lt;strong&gt;&lt;em&gt;Run→Run Sub/UserForm&lt;/em&gt;&lt;/strong&gt; (or hit the play button)       &lt;br /&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;If you switch back to your ERD view and run a Model check again the error should be gone.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:590e6ad4-0121-4cf1-a81d-ad7df9e40f98" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Credit to Chang Oh, Microsoft&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;Sub&lt;/span&gt; DeleteAllDisconnectedRelationshipsFromAllModels()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;Dim&lt;/span&gt; vme &lt;span style="color:#000080"&gt;As&lt;/span&gt; &lt;span style="color:#000080"&gt;New&lt;/span&gt; VisioModelingEngine&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;Dim&lt;/span&gt; models &lt;span style="color:#000080"&gt;As&lt;/span&gt; IEnumIVMEModels&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;Dim&lt;/span&gt; model &lt;span style="color:#000080"&gt;As&lt;/span&gt; IVMEModel&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;Dim&lt;/span&gt; elements &lt;span style="color:#000080"&gt;As&lt;/span&gt; IEnumIVMEModelElements&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;Dim&lt;/span&gt; element &lt;span style="color:#000080"&gt;As&lt;/span&gt; IVMEModelElement&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;Dim&lt;/span&gt; relationship &lt;span style="color:#000080"&gt;As&lt;/span&gt; IVMERelationship&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    models = vme.models&lt;/li&gt; &lt;li&gt;    model = models.Next&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;Do&lt;/span&gt; &lt;span style="color:#000080"&gt;While&lt;/span&gt; &lt;span style="color:#000080"&gt;Not&lt;/span&gt; model &lt;span style="color:#000080"&gt;Is&lt;/span&gt; &lt;span style="color:#000080"&gt;Nothing&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        elements = model.elements&lt;/li&gt; &lt;li&gt;        element = elements.Next&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#000080"&gt;Do&lt;/span&gt; &lt;span style="color:#000080"&gt;While&lt;/span&gt; &lt;span style="color:#000080"&gt;Not&lt;/span&gt; element &lt;span style="color:#000080"&gt;Is&lt;/span&gt; &lt;span style="color:#000080"&gt;Nothing&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#000080"&gt;If&lt;/span&gt; (element.Type = eVMEKindERRelationship) &lt;span style="color:#000080"&gt;Then&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                relationship = element&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#000080"&gt;If&lt;/span&gt; (&lt;span style="color:#000080"&gt;Not&lt;/span&gt; relationship.IsFullyConnected) &lt;span style="color:#000080"&gt;Then&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    model.DeleteElement(element.ElementID)&lt;/li&gt; &lt;li&gt;                    elements = model.elements&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#000080"&gt;End&lt;/span&gt; &lt;span style="color:#000080"&gt;If&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#000080"&gt;End&lt;/span&gt; &lt;span style="color:#000080"&gt;If&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            element = elements.Next&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;Loop&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        model = models.Next&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;Loop&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;End&lt;/span&gt; &lt;span style="color:#000080"&gt;Sub&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-5426017681049517509?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/5426017681049517509/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=5426017681049517509" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5426017681049517509?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5426017681049517509?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/owNzje5AKIg/visio-and-l2100-error.html" title="Visio and the L2100 Error" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/10/visio-and-l2100-error.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4AQXY-fCp7ImA9WhdUFE0.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-5665518478437425576</id><published>2011-09-30T11:39:00.000-07:00</published><updated>2011-09-30T11:39:00.854-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-30T11:39:00.854-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>When Dispose Throws the Baby Out with the Bathwater</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/o4tQmaTZIpMmj60eRkfGJpaThOo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/o4tQmaTZIpMmj60eRkfGJpaThOo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/o4tQmaTZIpMmj60eRkfGJpaThOo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/o4tQmaTZIpMmj60eRkfGJpaThOo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;As I said in my last post, there is a lot to like about .NET but every now and then they do some really screwy stuff. This post is about BinaryReader and BinaryWriter and why you shouldn't dispose of the them when you're done with them (or do the equivalent by&amp;#160; putting them in using statements), unless you follow one particular idiom of usage. That idiom is the one you see in MSDN and in a lot of examples. Unfortunately, nothing I've seen in MSDN (or in my Nutshell reference) properly explains what is going on here.&lt;/p&gt;  &lt;p&gt;The idiom typically wraps the creation of the stream inside the creation of the BinaryWriter e.g.&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ce07b84f-2edf-4665-9517-aacf0d5cfc99" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; (&lt;span style="color:#4044e3"&gt;BinaryWriter&lt;/span&gt; &lt;span style="color:#354471"&gt;binWriter&lt;/span&gt; =&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt; &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;BinaryWriter&lt;/span&gt;(&lt;span style="color:#00008b"&gt;File&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Open&lt;/span&gt;(&lt;span style="color:#ff0000"&gt;filename&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;FileMode&lt;/span&gt;.&lt;span style="color:#800080"&gt;Create&lt;/span&gt;)))&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The enclosed call to File.Open returns a FileStream. A FileStream derives from Stream and all Stream's are disposable.&amp;#160; Who owns it? Who should dispose of it? Looking at this example it seems obvious that BinaryWriter is the only one that can dispose of it. But what happens when you don't use this idiom? For example, assume you have a previously created Stream you're going to use for an extended period of time. Say you open a TCP connection with TcpListener and get the underlying stream:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cde207b5-fb47-483a-a94b-92c97cdd72d1" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0080c0"&gt;_serverTcpClient&lt;/span&gt; = &lt;span style="color:#0080c0"&gt;_tcpServer&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;AcceptTcpClient&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0080c0"&gt;_myClientStream&lt;/span&gt; = &lt;span style="color:#0080c0"&gt;_serverTcpClient&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;GetStream&lt;/span&gt;();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Mostly you're going to use this stream directly via something like _myClientStream.Write(data, offset, size). But maybe there's a point where a BinaryWriter can help you; say you want to kick start communications with a protocol message:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5df4557c-9fbc-4b94-ba9f-8fef9096d5ea" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#4044e3"&gt;BinaryWriter&lt;/span&gt; &lt;span style="color:#354471"&gt;w&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;BinaryWriter&lt;/span&gt;(&lt;span style="color:#0080c0"&gt;_myClientStream&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#354471"&gt;w&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Write&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&lt;span style="color:#354471"&gt;w&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Flush&lt;/span&gt;();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;If you strive to be careful about disposing of everything that should be disposed you probably think it would be better to write&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6c691923-edc8-47b1-802c-9957622c1f84" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;using&lt;/span&gt; (&lt;span style="color:#4044e3"&gt;BinaryWriter&lt;/span&gt; &lt;span style="color:#354471"&gt;w&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;BinaryWriter&lt;/span&gt;(&lt;span style="color:#0080c0"&gt;_myClientStream&lt;/span&gt;))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#354471"&gt;w&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Write&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;);  &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Or at least to manually call w.Dispose(), but you'd only be right, if sending &amp;quot;Hello&amp;quot; is the last&amp;#160; thing you ever want to do with _myClientStream. This is counterintuitive to me, the stream was created in another method in this class and lives in a member field, it seems obvious that BinaryWriter doesn't own this resource and shouldn't dispose of it when finished. The reason it behaves this way is because of the previous idiom where the stream is created in the constructor of BinaryWriter. This tells me this idiom is &lt;strong&gt;wrong&lt;/strong&gt; and shouldn't be used but .NET decided (wrongly) that this was the only useful idiom that would &lt;strong&gt;ever&lt;/strong&gt; be used so they dispose of the stream. It's just one of those little gotcha's you need to be aware of. Just keep the bathwater (the dog will drink it any way), it's better than throwing out the baby.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-5665518478437425576?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/5665518478437425576/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=5665518478437425576" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5665518478437425576?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5665518478437425576?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/xGAyL9aFe5s/when-dispose-throws-baby-out-with.html" title="When Dispose Throws the Baby Out with the Bathwater" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/09/when-dispose-throws-baby-out-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QAR30yfyp7ImA9WhdUF0s.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-142386867654022750</id><published>2011-09-29T10:58:00.001-07:00</published><updated>2011-10-04T16:02:26.397-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-04T16:02:26.397-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Not Well Connected</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/v3Rl9hHEG2AHKsCZbw63YHKLOzs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v3Rl9hHEG2AHKsCZbw63YHKLOzs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/v3Rl9hHEG2AHKsCZbw63YHKLOzs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v3Rl9hHEG2AHKsCZbw63YHKLOzs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Let me first say that I find .NET to be the best designed, easiest to use framework I've ever had the pleasure of dealing with in 30 years of programming. However, that doesn't mean they got everything right. The topic today is the Socket &lt;em&gt;&lt;strong&gt;Connected&lt;/strong&gt;&lt;/em&gt; property that lives in the System.Net.Sockets namespace.&lt;/p&gt;  &lt;p&gt;You probably suspect that a property named &lt;em&gt;Connected&lt;/em&gt; returns true if a socket is connected and returns false if it isn't connected. In fact it seems so obvious, that like me, you probably aren't too tempted to go read the docs on this property. That would be a mistake. A more accurate name for this property would be &lt;strong&gt;LastOperationSucceeded&lt;/strong&gt;. Below is the relevant excerpt from the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.connected(v=VS.110).aspx"&gt;MSDN docs on the Connected property&lt;/a&gt; (emphasis is mine): &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="3" face="Lucida Bright"&gt;The Connected property gets the connection state of the &lt;/font&gt;&lt;font size="3" face="Lucida Bright"&gt;Socket&lt;/font&gt;&lt;font size="3" face="Lucida Bright"&gt; &lt;strong&gt;&lt;font size="4"&gt;as of the last I/O operation&lt;/font&gt;&lt;/strong&gt;. When it returns false, the &lt;/font&gt;&lt;font size="3" face="Lucida Bright"&gt;Socket&lt;/font&gt;&lt;font size="3" face="Lucida Bright"&gt; was either never connected, or is no longer connected.&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font size="3" face="Lucida Bright"&gt;The value of the Connected property reflects the state of the connection as of the most recent operation. If you need to determine the current state of the connection, make a non-blocking, zero-byte Send call.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I don't believe the docs are accurate. The Connected property returning false DOES NOT mean the socket is no longer connected. It just means the last operation failed. The difference is not pedantic and in fact designing code assuming &lt;em&gt;Connected&lt;/em&gt; means there is a valid or invalid connection can easily lead to much confusion and heartache and ultimately a non-working design. &lt;/p&gt;  &lt;p&gt;This became obvious to me because on the Server side of a connection (that sends data only) I wanted to know when the the client dropped the connection. The client drops the connection when it stops receiving data for a predefined amount of time. This means the last send by the server was a success so the server never knew the client was gone. &lt;/p&gt;  &lt;p&gt;Equally important, on the server side I was checking Connected before doing a write to make sure the client was still connected. &lt;strong&gt;Big Mistake.&lt;/strong&gt; In this application I shortened the send timeout to 50ms. If the client was too busy to get a frame of data it was no big deal I could just drop the packet on the floor.&amp;#160; The problem was that after dropping the packet Connected returns false. That means the server would quit sending data after the first dropped packet. The client is in fact still connected but since the last operation failed &lt;em&gt;Connected&lt;/em&gt; returned false.&amp;#160; &lt;/p&gt;  &lt;p&gt;The first problem&amp;#160; caused a hard to find problem when the next measurement started. For some reason if a client reestablished a connection (the old one was still valid) within 3 minutes all was well.&amp;#160; After three minutes the client connection would fail and the measurement would not work. &lt;/p&gt;  &lt;p&gt; In my case since the client and server also exchange info through a WCF service my fix was to have the client directly inform the server about the end of the measurement, and force the server to disconnect. Now a client reconnecting always works. I also belatedly set the&amp;#160; &lt;em&gt;&lt;strong&gt;ExclusiveAddressUse&lt;/strong&gt;&lt;/em&gt; to true. It being false (the default) may have contributed to the strange three minute reconnect issue.&lt;/p&gt;  &lt;p&gt;If you want to tell if you can still communicate&amp;#160; by doing a zero byte send here's a somewhat simplified version of the approach suggested from the above referenced MSDN docs. _serverTcpClient is the TcpClient field that was returned from the TcpListener call to TcpAcceptClient(). However, I don't even recommend this because this again, it isn't really telling you if the connection is valid, just if this operation worked. &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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1911c935-d1f3-48ed-b654-a495d355e075" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;ConnectionIsValid&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#008b8b"&gt;ConnectionIsValid&lt;/span&gt;()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;if&lt;/span&gt; (&lt;span style="color:#0080c0"&gt;_serverTcpClient&lt;/span&gt; == &lt;span style="color:#000080"&gt;null&lt;/span&gt;) &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#000080"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#4044e3"&gt;Socket&lt;/span&gt; &lt;span style="color:#354471"&gt;client&lt;/span&gt; = &lt;span style="color:#0080c0"&gt;_serverTcpClient&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Client&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#354471"&gt;blocking_state&lt;/span&gt; = &lt;span style="color:#354471"&gt;client&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Blocking&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#354471"&gt;is_connected&lt;/span&gt; = &lt;span style="color:#000080"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;byte&lt;/span&gt;[] &lt;span style="color:#354471"&gt;tmp&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#000080"&gt;byte&lt;/span&gt;[1];&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#354471"&gt;client&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Blocking&lt;/span&gt; = &lt;span style="color:#000080"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#354471"&gt;client&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Send&lt;/span&gt;(&lt;span style="color:#354471"&gt;tmp&lt;/span&gt;, 0, 0);&lt;/li&gt; &lt;li&gt;       &lt;span style="color:#000080"&gt;return&lt;/span&gt;  &lt;span style="color:#354471"&gt;client&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Connected&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#000080"&gt;catch&lt;/span&gt; (&lt;span style="color:#4044e3"&gt;SocketException&lt;/span&gt; &lt;span style="color:#354471"&gt;e&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;if&lt;/span&gt; (&lt;span style="color:#354471"&gt;e&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;NativeErrorCode&lt;/span&gt;.&lt;span style="color:#008b8b"&gt;Equals&lt;/span&gt;(10035)) &lt;span style="color:#008000"&gt;//send would block&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#000080"&gt;true&lt;/span&gt;; &lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#000080"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;          &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#000080"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    }&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#000080"&gt;finally&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#354471"&gt;client&lt;/span&gt;.&lt;span style="color:#0080c0"&gt;Blocking&lt;/span&gt; = &lt;span style="color:#354471"&gt;blocking_state&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-142386867654022750?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/142386867654022750/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=142386867654022750" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/142386867654022750?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/142386867654022750?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/y7Eiv8PQ-BM/not-well-connected.html" title="Not Well Connected" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/09/not-well-connected.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMFQH8-fCp7ImA9WhdXGUw.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-852480389139376528</id><published>2011-09-01T15:31:00.001-07:00</published><updated>2011-09-01T15:33:31.154-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-01T15:33:31.154-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Forcing WPF Controls to Update</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/j6WNsT6adTaQwmCYBbRdeWHA23U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j6WNsT6adTaQwmCYBbRdeWHA23U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/j6WNsT6adTaQwmCYBbRdeWHA23U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j6WNsT6adTaQwmCYBbRdeWHA23U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;One of the nice things about WPF is how easy it makes implementing MVVM. You can easily decouple the view from the logic that affects the view. Every application I write needs to disable and enable certain controls. Recently I was working on an application that plays back data files. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-nN-f3XX-0Jc/TmAHriFwIrI/AAAAAAAABEc/HK0VTYWp15M/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/-rVI_5KnNVuM/TmAHsJPlaMI/AAAAAAAABEg/DBFCrTmHx3o/image_thumb%25255B1%25255D.png?imgmax=800" width="276" height="314" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The figure at the left shows both the user interface and an example plot. The program opens a data file.&amp;#160; Then when the user hits play, a separate thread starts playing back the data in the second window. Everything worked perfectly in WPF using MVVM until the end of the data file was reached. &lt;/p&gt;  &lt;p&gt;I know from my WinForm experience that updating the UI from a separate thread is a no-no (OK the official term is cross-threading violation). No problem, there are multiple ways I can get things to happen on the correct thread.&amp;#160; I decided in this case to move from my home-rolled thread to the BackgroundWorker class that .NET provides.&amp;#160; I set up the thread start method as the DoWork event handler and hooked up a ProgressChanged event handler. Finally, I set the property WorkerReportsProgress to true. &lt;/p&gt;  &lt;p&gt;Now when all the data is read from the file, I just call the ProgressChanged method. The final key was determining which method to call to make the form properly update. Application.Current.MainWindow.UpdateLayout() or&amp;#160; the related InvalidateVisual() methods seemed like good candidates. Turns out they didn't work. Since the buttons implement ICommand, indirectly through the RelayCommand pattern I needed to get the form to check for a change in the underlying state. Luckily I did eventually discover just such an animal . All the progress changed handler had to do was make a single call to:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000a0"&gt;CommandManager&lt;/font&gt;.&lt;/strong&gt;&lt;font color="#408080"&gt;&lt;strong&gt;InvalidateRequerySuggested(). &lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-852480389139376528?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/852480389139376528/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=852480389139376528" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/852480389139376528?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/852480389139376528?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/IK3bN6WrKLA/forcing-wpf-controls-to-update.html" title="Forcing WPF Controls to Update" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-rVI_5KnNVuM/TmAHsJPlaMI/AAAAAAAABEg/DBFCrTmHx3o/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/09/forcing-wpf-controls-to-update.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMFQnw7eip7ImA9WhdRE0Q.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-6716436994308732445</id><published>2011-08-03T11:50:00.001-07:00</published><updated>2011-08-03T11:50:13.202-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-03T11:50:13.202-07:00</app:edited><title>How to Find Anything in Outlook 2010</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/U6m1lFPKQEN-kwPONUjVr4q964Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/U6m1lFPKQEN-kwPONUjVr4q964Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/U6m1lFPKQEN-kwPONUjVr4q964Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/U6m1lFPKQEN-kwPONUjVr4q964Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2&gt;&lt;font color="#4f81bd"&gt;My Old Way&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-PGGzlv6xwRM/TjmYVSWyE7I/AAAAAAAABDs/SUnoLLg61EY/s1600-h/SNAGHTML26bcaa%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML26bcaa" border="0" alt="SNAGHTML26bcaa" align="left" src="http://lh4.ggpht.com/-Tvy0nZ_0OEA/TjmYV4fLb7I/AAAAAAAABDw/q3fx90IfT58/SNAGHTML26bcaa_thumb%25255B2%25255D.png?imgmax=800" width="501" height="400" /&gt;&lt;/a&gt;I've never been crazy about trying to find things in Outlook. I used to use the &lt;em&gt;Advanced Find&lt;/em&gt; feature and I just memorized the Shift-Ctrl-F shortcut because since Microsoft went to the ribbon bar I could never find it. The only problem with this search is it takes quite a few clicks to configure as you can see in the figure.&amp;#160; It's particularly easy to forget to enable the &lt;em&gt;Search subfolders&lt;/em&gt; checkbox. This approach is still worth knowing but recently I've found some of the features in Outlook 2010 to be more useful in most cases.&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;  &lt;h2&gt;&lt;font color="#4f81bd"&gt;Find the Search Box&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;At first discovering how to search is a bit annoying. Search as you might through the ribbon, you won't find a search tab or any search items. Seems highly bizarre to me to hide the search tab, but as I've mentioned in past posts Microsoft seems to take perverse pleasure in anti-discoverability. Maybe it's a rite of passage thing with them. Once you stop looking in the ribbon bar you will notice that for each major type of outlook item (Mail, Calendar, Contacts etc.) there is a search field. It's typically in the upper right hand corner, not too hard to find, but in my typically large Outlook window not exactly in my line of sight either. You can play hunt the search bar in the image below, but the green arrow is a big hint. Still this search method is not very effective for me. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-E5tCvyCQWyc/TjmYWZZUfgI/AAAAAAAABD0/9o2kr4-9Fw8/s1600-h/image%25255B4%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://lh4.ggpht.com/-yoLWjY826lA/TjmYWymnXRI/AAAAAAAABD4/2Sf9-jJqp1A/image_thumb%25255B2%25255D.png?imgmax=800" width="611" height="103" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;&lt;font color="#4f81bd"&gt;Using the Right Search Box&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;The default search box limits itself to whatever folder you are currently in. That is not typically what I need when I'm searching. I have contacts divided up into multiple contact lists (otherwise all 600 contacts would sync onto my cell phone). I just want to find a person and I don't want to search across all five lists. Luckily it's easy, but it's in that hidden Search tab. When you click in the search bar the Search Tab shows up. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-T6Gdwscoh7A/TjmYXaHth3I/AAAAAAAABD8/gQ6cdllMVIw/s1600-h/image%25255B10%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://lh3.ggpht.com/-8NHRXQC2N_o/TjmYYD5pu3I/AAAAAAAABEA/xcXqcadouow/image_thumb%25255B6%25255D.png?imgmax=800" width="840" height="302" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Microsoft highlights it in &lt;font style="background-color: #f79646"&gt;orange&lt;/font&gt; so you can't miss it (although I still did the first several times I searched, I don't know why, I guess I just don't expect critically useful tabs to hide themselves). It's also important to note that this tab's content will change based on which type of object you are searching for. The above image is for mail. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-PCa3BkL-cUs/TjmYYeHsIOI/AAAAAAAABEE/fVdsrJ27DIs/s1600-h/SNAGHTML453a62%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML453a62" border="0" alt="SNAGHTML453a62" align="left" src="http://lh6.ggpht.com/-mpcinqErVdA/TjmYZMIwDrI/AAAAAAAABEI/XBCbCB3rqGA/SNAGHTML453a62_thumb%25255B1%25255D.png?imgmax=800" width="420" height="214" /&gt;&lt;/a&gt;The one at left is for contacts. It's the &lt;em&gt;All Mail Items&lt;/em&gt; and &lt;em&gt;All Contact Items&lt;/em&gt; that I find the most useful. So useful in fact that I don't want them on a ribbon tab that doesn't show up. Luckily there is a solution. &lt;strong&gt;Right click&lt;/strong&gt; on any item you find useful and select the &lt;em&gt;Add to Quick Access Toolbar&lt;/em&gt;. I've already done that in the image so that option is grayed out for me, however if you look up above in the quick access bar (see the blue arrow), you can see the icon button for searching all contact items. Now whenever I want to search contacts, mail or the calendar I click the appropriate icon, Outlook automatically puts me in the search box and I start typing.&lt;/p&gt;  &lt;p&gt;In an attempt to keep a feature for Outlook 2013, Microsoft only enables the search icon for the current section of Outlook. If you're in the contacts, you can search contacts, if you're in mail you can search mail. There appears to be no technical reason for this other than to annoy you. However, you can work around it by adding the &amp;quot;All Outlook Items&amp;quot; to the quick access bar. This works from all areas of Outlook. Happy hunting, keep an eye out for grues.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-6716436994308732445?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/6716436994308732445/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=6716436994308732445" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/6716436994308732445?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/6716436994308732445?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/2IzZRrCO81Q/how-to-find-anything-in-outlook-2010.html" title="How to Find Anything in Outlook 2010" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-Tvy0nZ_0OEA/TjmYV4fLb7I/AAAAAAAABDw/q3fx90IfT58/s72-c/SNAGHTML26bcaa_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/08/how-to-find-anything-in-outlook-2010.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQDQH4_eCp7ImA9WhdaGU8.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-4905973888508364609</id><published>2011-07-28T23:31:00.001-07:00</published><updated>2011-10-29T14:39:31.040-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-29T14:39:31.040-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>WPF Data Binding Booleans: To Be or !To Be</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tPmlOzCu-EgYQJNIsbB6VtcLK98/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tPmlOzCu-EgYQJNIsbB6VtcLK98/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tPmlOzCu-EgYQJNIsbB6VtcLK98/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tPmlOzCu-EgYQJNIsbB6VtcLK98/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The road leading towards WPF mastery hit a small bump when it came to data binding and Booleans. I wasn't surprised when my first attempt didn't work, I wasn't even sure what I expected to happen. Normally Boolean fields have some automated behavior. When they are grouped, clicking one button true sets the others in the group false. How does this play with data binding where the value for the field is supposed to be set by the binding?&amp;#160; It's enough to make me think if Scott Meyers's were writing a book on this he would have an item titled &lt;strong&gt;&lt;em&gt;Prefer CheckBoxes&lt;/em&gt;&lt;/strong&gt;. Checkboxes work with simple Binding to IsChecked just like you'd expect. I do have customers though that insist on Booleans because they like to see both options explicitly shown, so here's one solution: &lt;/p&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;&lt;strike&gt;Command Binding&lt;/strike&gt;&lt;/h2&gt;  &lt;p&gt;Edit: Turns out you don't really need the command binding.&amp;#160; Just using two properties as described below is sufficient. I'm leaving the code snapshots as they are both you don't need to bind to Command and you don't need to write the two commands. &lt;/p&gt;  &lt;p&gt;&lt;strike&gt;One way to get Booleans to behave with data binding is to bind not just IsChecked but also bind the Command as shown below. This XAML creates two radio buttons labeled &lt;em&gt;To Be&lt;/em&gt; and &lt;em&gt;Not To Be&lt;/em&gt;. In my final code I added&lt;/strike&gt; a &lt;strike&gt;&lt;em&gt;Mode=OneWay&lt;/em&gt; to the binding, but it appeared to work no differently with the default binding.&lt;/strike&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c7cda56-70c4-4004-a990-3ea5b4074b0c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;XAML Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;RadioButton&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Content&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;To Be&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;IsChecked&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; ToBe}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Command&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; ToBeCommand}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#6300c6"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#4044e3"&gt;RadioButton&lt;/span&gt;&lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Content&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Not To Be&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;IsChecked&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; NotToBe}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#ff0000"&gt; &lt;/span&gt;&lt;span style="color:#0080c0"&gt;Command&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#4044e3"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; NotToBeCommand}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The ToBe Property is pretty standard except it also sets the property and raises the event for NotToBe. NotToBe is just an automatic property. Both commands will be implemented, but they will both set the ToBe property, one will set it to true and the other will set it to false. Here's the full code example:&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:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2a826eb0-a360-437b-9b2f-205a2816648a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Properties and ICommands&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_toBe&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#0080c0"&gt;ToBe&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_toBe&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008b8b"&gt;set&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0080c0"&gt;_toBe&lt;/span&gt; = &lt;span style="color:#000080"&gt;value&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0080c0"&gt;NotToBe&lt;/span&gt; = !&lt;span style="color:#000080"&gt;value&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#008b8b"&gt;RaisePropertyChanged&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;ToBe&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#008b8b"&gt;RaisePropertyChanged&lt;/span&gt;(&lt;span style="color:#6300c6"&gt;&amp;quot;NotToBe&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#000080"&gt;bool&lt;/span&gt; &lt;span style="color:#0080c0"&gt;NotToBe&lt;/span&gt; { &lt;span style="color:#008b8b"&gt;get&lt;/span&gt;; &lt;span style="color:#008b8b"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#4044e3"&gt;RelayCommand&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_toBeCommand&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#4044e3"&gt;RelayCommand&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_notToBeCommand&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#078398"&gt;ICommand&lt;/span&gt; &lt;span style="color:#0080c0"&gt;ToBeCommand&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_toBeCommand&lt;/span&gt; ?? (&lt;span style="color:#0080c0"&gt;_toBeCommand&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;RelayCommand&lt;/span&gt;(x =&amp;gt; &lt;span style="color:#008b8b"&gt;ToBeExecute&lt;/span&gt;())); }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;void&lt;/span&gt; &lt;span style="color:#008b8b"&gt;ToBeExecute&lt;/span&gt;()&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0080c0"&gt;ToBe&lt;/span&gt; = &lt;span style="color:#000080"&gt;true&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#000080"&gt;public&lt;/span&gt; &lt;span style="color:#078398"&gt;ICommand&lt;/span&gt; &lt;span style="color:#0080c0"&gt;NotToBeCommand&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008b8b"&gt;get&lt;/span&gt; { &lt;span style="color:#000080"&gt;return&lt;/span&gt; &lt;span style="color:#0080c0"&gt;_notToBeCommand&lt;/span&gt; ?? (&lt;span style="color:#0080c0"&gt;_notToBeCommand&lt;/span&gt; = &lt;span style="color:#000080"&gt;new&lt;/span&gt; &lt;span style="color:#4044e3"&gt;RelayCommand&lt;/span&gt;(x =&amp;gt; &lt;span style="color:#008b8b"&gt;NotToBeExecute&lt;/span&gt;())); }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#000080"&gt;private&lt;/span&gt; &lt;span style="color:#000080"&gt;void&lt;/span&gt; &lt;span style="color:#008b8b"&gt;NotToBeExecute&lt;/span&gt;()&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0080c0"&gt;ToBe&lt;/span&gt; = &lt;span style="color:#000080"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-4905973888508364609?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/4905973888508364609/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=4905973888508364609" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/4905973888508364609?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/4905973888508364609?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/qBdnmkaHdb4/wpf-data-binding-booleans-to-be-or-to.html" title="WPF Data Binding Booleans: To Be or !To Be" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/wpf-data-binding-booleans-to-be-or-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUMQXk7fCp7ImA9WhdSFUQ.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-8004299915338887253</id><published>2011-07-25T04:28:00.000-07:00</published><updated>2011-07-25T04:28:00.704-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-25T04:28:00.704-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Dependency Walker</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/X_cdyYzxiwVVcJzZh1ZHEBi_LWo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/X_cdyYzxiwVVcJzZh1ZHEBi_LWo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/X_cdyYzxiwVVcJzZh1ZHEBi_LWo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/X_cdyYzxiwVVcJzZh1ZHEBi_LWo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Conjures up images of ice planet Hoth doesn't it. While it may not be as fearsome as an Imperial Walker the you'll find &lt;a href="http://www.dependencywalker.com/" target="_blank"&gt;Dependency Walker&lt;/a&gt; to be much more deadly in killing off .DLL problems. If you've ever built an application on your development &lt;a href="http://lh5.ggpht.com/-MgDgFxydnZU/TinQKghBeQI/AAAAAAAABDk/4hE7D1PoIO0/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh4.ggpht.com/-iScOcLN2Dic/TinQLIbmx7I/AAAAAAAABDo/wLiHv_KLWS4/image_thumb%25255B1%25255D.png?imgmax=800" width="572" height="423" /&gt;&lt;/a&gt;machine and then had it not run on a target machine, this app needs to be in your arsenal. It's also indispensable for troubleshooting remote debugging and 64/32 bit &lt;a href="http://syncor.blogspot.com/search?q=BadImageFormatException" target="_blank"&gt;BadImageFormatExceptions&lt;/a&gt;.&amp;#160;&amp;#160; There are 32 and 64 bit versions of Dependency Walker available. If you develop on a 64 bit machine download both. If you target anything to a 32 bit machine you'll want to run the 32 bit version against the .exe or .dlls you deploy on the 32 bit machine. &lt;/p&gt;  &lt;p&gt;The image shows a few key features. When you load an .exe use the Profile menu and run Start Profiling to check out your delay loaded .DLLs. &lt;/p&gt;  &lt;p&gt;Also you'll probably want to run it directly on any .DLLs that are giving you problems. When a .&lt;em&gt;dll not found exception&lt;/em&gt; occurs you'll notice the message says either the .DLL or one of its dependencies can't be found. In my experience it's those dependencies that cause all the problems.&amp;#160; You can see from the blue arrow in the image that two .DLLs have yellow icons. In this particular case those two .DLLs aren't a problem, but usually others that show up in yellow very may well be. &lt;/p&gt;  &lt;p&gt;Finding 32/64 bit problems is even easier, you can click on the CPU column (shown by the lower green arrow) and then scroll down and if you are trying to deploy on a 32 bit machine and the column has x64 instead of x32 you've found the problem causing .DLL. &lt;/p&gt;  &lt;p&gt;You'll probably get some false positives from DW but a few quick web searches will usually let you identify those and focus in quickly on the .DLLs that are causing you grief. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-8004299915338887253?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/8004299915338887253/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=8004299915338887253" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/8004299915338887253?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/8004299915338887253?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/VFqUgWBSQPw/dependency-walker.html" title="Dependency Walker" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-iScOcLN2Dic/TinQLIbmx7I/AAAAAAAABDo/wLiHv_KLWS4/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/dependency-walker.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIMRXs-eip7ImA9WhdSE0g.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-8050433620191950424</id><published>2011-07-22T10:09:00.001-07:00</published><updated>2011-07-22T10:09:44.552-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-22T10:09:44.552-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Mac" /><title>Mac Users - Check Your Lion Compatibility</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/l1xOzbl4uP6q_MBElLSmBqunZZY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/l1xOzbl4uP6q_MBElLSmBqunZZY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/l1xOzbl4uP6q_MBElLSmBqunZZY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/l1xOzbl4uP6q_MBElLSmBqunZZY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I've seen some complicated methods involving the Terminal for finding existing applications on your Mac that won't run with &lt;a href="http://www.apple.com/macosx/" target="_blank"&gt;Lion&lt;/a&gt;, the latest OS from Apple.&amp;#160; In case you don't know Apple is dumping support for &amp;quot;Rosetta&amp;quot;, the technology that allows applications written for PowerPC-based computers to run on the newer Intel-based Macs. There are some notable casualties of this, including Quicken 2007 and Office 2004. You might want to know before you upgrade which of your applications aren't going to work anymore. &lt;/p&gt;  &lt;h2&gt;The GUI Way To Find PowerPC Apps&lt;/h2&gt;  &lt;p&gt;Apple being Apple you know there had to be a non-terminal way to do this right?&amp;#160; Use the Finder’s Apple menu and select &lt;em&gt;About this Mac&lt;/em&gt;. In the resulting dialog click the &lt;em&gt;“More Info…”&lt;/em&gt; button. Wait a minute or two for the list to populate. Widen the window if necessary to show the “Kind” column. You can click on this column to sort by Kind. Then you can scroll to the “&lt;em&gt;PowerPC&lt;/em&gt;” applications to see all your applications that won’t run under Lion. &lt;/p&gt;  &lt;p&gt;I have about 400! applications that will no longer work. To be fair, most of these are in a folder that contains the contents of an old hard disk I copied over. Out of the entire list there were a only a few that I think might affect most people,&amp;#160; couple of games, Quicken 2007 and Microsoft Office X. Your list will almost certainly be shorter and easier to review than mine. However, it's still worth doing to make sure you don't have any applications you can't live without. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-8050433620191950424?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/8050433620191950424/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=8050433620191950424" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/8050433620191950424?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/8050433620191950424?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/VnLdRuBpxTI/mac-users-check-your-lion-compatibility.html" title="Mac Users - Check Your Lion Compatibility" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/mac-users-check-your-lion-compatibility.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQCQ3kycCp7ImA9WhdSEko.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-2221962372056208877</id><published>2011-07-21T12:02:00.001-07:00</published><updated>2011-07-21T12:26:02.798-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-21T12:26:02.798-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>BadImageFormatException When 64 meets 32</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/AAlLEaLqncCC6TQIT8XtrEFByL0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AAlLEaLqncCC6TQIT8XtrEFByL0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/AAlLEaLqncCC6TQIT8XtrEFByL0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AAlLEaLqncCC6TQIT8XtrEFByL0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;&lt;font color="#4f81bd"&gt;What the Exception Said&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;It said &amp;quot;BadImageFormatException&amp;quot; Obvious right? Nice clear use of the term &amp;quot;Image&amp;quot; as you go off looking for a bad. jpg, .png. or gif file.&lt;/p&gt;  &lt;h2&gt;&lt;font color="#4f81bd"&gt;What the Exception Should Have said&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;Expected64BitDllGot32BitDllException – OK you can probably get a BadImageFormatException for other reasons, but every time I've seen it, this is why.&lt;/p&gt;  &lt;h2&gt;When Any CPU Doesn't Help&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-kaBWcaRdL1I/Tih3omJ2JnI/AAAAAAAABDM/nverylmCSgg/s1600-h/SNAGHTML5f60f5%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 10px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML5f60f5" border="0" alt="SNAGHTML5f60f5" align="left" src="http://lh6.ggpht.com/-oFSwS3ylRrk/Tih3o6y-GUI/AAAAAAAABDQ/1RJitGQ1FJ4/SNAGHTML5f60f5_thumb%25255B1%25255D.png?imgmax=800" width="441" height="243" /&gt;&lt;/a&gt;If you stick to the managed world of C# you'll probably never see this exception. If you write a .DLL in C++/CLI with common language runtime support set to /clr (under Project Properties as shown in the image), you'll almost certainly see it. &lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;    &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-3YvEQi9hhVU/Tih3pal8nCI/AAAAAAAABDU/EslgEp3m3kM/s1600-h/SNAGHTML528650%25255B6%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML528650" border="0" alt="SNAGHTML528650" align="left" src="http://lh5.ggpht.com/-DYSjdOCqeNM/Tih3qKJUK9I/AAAAAAAABDY/olYoWpAcILI/SNAGHTML528650_thumb%25255B3%25255D.png?imgmax=800" width="434" height="295" /&gt;&lt;/a&gt;I was wrapping an unmanaged C++ DLL in a managed /clr wrapper when I ran across it. What happens is that the compiler will create either a 64 bit or 32 bit version of your .DLL. The advanced linker settings as shown in the image allow you to set the target machine. &lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;    &lt;h2&gt;When Worlds Collide&lt;/h2&gt;  &lt;p&gt;The problem occurs when you host the .DLL in a managed application that supports Any CPU (or specifically a 64 bit model). If you test on a 32 bit machine you won't see a problem. Your hosting managed application will run in 32 bit mode and it will load the 32 bit .DLL without issue. When you run on a 64 bit platform your hosting application will run in 64 bit mode and when it goes to load the DLL (remember it's dynamically linked) it will throw the BadFormatImageException&amp;#160; because it can't find a 64 bit version of the .DLL.&lt;/p&gt;  &lt;h2&gt;One Love One Heart&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-0cB1qjYPhTQ/Tih3qf-Z1_I/AAAAAAAABDc/N6F4xzsXW8k/s1600-h/SNAGHTML5acb5b%25255B6%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 9px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML5acb5b" border="0" alt="SNAGHTML5acb5b" align="left" src="http://lh4.ggpht.com/-Ky3F03p1UZs/Tih3q2ycMFI/AAAAAAAABDg/JDM5MlwPcoE/SNAGHTML5acb5b_thumb%25255B3%25255D.png?imgmax=800" width="415" height="217" /&gt;&lt;/a&gt;The easy solution is to have one world. Use the properties dialog of your managed application as shown in the image and force the hosting application to be 32 bit. Since 32 bit applications will run on a 64 bit machine under WOW your problem will be solved. If for performance reasons you want to have your application run in 64 bit mode under 64 bit machines, I suspect you will have to build your .DLL twice. Once for each target machine. I've never done this but I suspect you just create distribution folders with the proper .DLL and it will work. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-2221962372056208877?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/2221962372056208877/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=2221962372056208877" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/2221962372056208877?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/2221962372056208877?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/lXqg_FGQae8/badimageformatexception-when-64-meets.html" title="BadImageFormatException When 64 meets 32" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-oFSwS3ylRrk/Tih3o6y-GUI/AAAAAAAABDQ/1RJitGQ1FJ4/s72-c/SNAGHTML5f60f5_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/badimageformatexception-when-64-meets.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkAHSXc5fSp7ImA9WhdRFUo.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-1114072344513083532</id><published>2011-07-14T11:45:00.001-07:00</published><updated>2011-08-05T13:05:38.925-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-05T13:05:38.925-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="WPF" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>WPF Validation on calculated fields</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qDTxbjMw8rUDi8mMvogN2YrPeiI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qDTxbjMw8rUDi8mMvogN2YrPeiI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qDTxbjMw8rUDi8mMvogN2YrPeiI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qDTxbjMw8rUDi8mMvogN2YrPeiI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I'm working on a WPF application that uses a WCF service. The service communicates the GUI changes to a radar that runs on a separate computer. The WCF service also runs the parameters through a radar equation. The system parameters are such that at extreme values for all the fields the system can generate an invalid state. Typically the sampling rate becomes faster than the allowed. Since it's unclear which parameter the user will want to back-off, a good solution is to just show the calculated values and indicate when one of them is in error. Of course I also disable the Run button so there's no chance they actually try to command the system into an invalid state. &lt;/p&gt;  &lt;h2&gt;WPF Validation via IDataErrorInfo&lt;/h2&gt;  &lt;p&gt;There are many ways to achieve validation using WPF, including custom properties, XAML that checks for exceptions and the method I ended up using; implementing the IDataErrorInfo interface. This interface only has two members and only the indexer property &lt;em&gt;this[string]&lt;/em&gt; needs an actual implementation, since you don't have to use the &lt;em&gt;Error&lt;/em&gt; property. Given that the property bound to the displayed sampling rate widget is called &lt;strong&gt;SamplingRate&lt;/strong&gt; here's a simple validator:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public string this&lt;/span&gt;[&lt;span style="color: blue"&gt;string &lt;/span&gt;columnName]
{
    &lt;span style="color: blue"&gt;get
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;switch &lt;/span&gt;(columnName)
        {
            &lt;span style="color: blue"&gt;case &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;SamplingRate&amp;quot;&lt;/span&gt;:
                &lt;span style="color: blue"&gt;if &lt;/span&gt;(_samplingRate &amp;gt; MAX_SAMPLING_RATE_MHZ)
                {
                    &lt;span style="color: blue"&gt;return String.Format(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;Sampling Rate may not exceed {0} MHz.&amp;quot;,MAX_SAMPLING_RATE_MHZ)&lt;/span&gt;;
                }
                &lt;span style="color: blue"&gt;break&lt;/span&gt;;
        }
        &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;

    }
}&lt;/pre&gt;

&lt;p&gt;Returning a non-empty string for any property that matches columnName indicates a validation failure returning an empty string indicates the validation passed.&lt;/p&gt;

&lt;p&gt;Now in my xaml&amp;#160; I just turn on the validation by adding the ValidatesOnDataErrors like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;SamplingRate&lt;/span&gt;&lt;span style="color: blue"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;Mode&lt;/span&gt;&lt;span style="color: blue"&gt;=OneWay, &lt;/span&gt;&lt;span style="color: red"&gt;ValidatesOnDataErrors&lt;/span&gt;&lt;span style="color: blue"&gt;=True}&amp;quot; 
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now when the validation is violated a red border appears around the text box with this attribute. This is the default handling for validation errors. Unfortunately, the nice message I returned is nowhere to be seen.&lt;/p&gt;

&lt;h2&gt;Showing your Validation Message&lt;/h2&gt;

&lt;p&gt;I'm not sure why the default behavior is to not show your message. It seems quite reasonable to have the message show up as a ToolTip by default. My solution was to to create a Style that retrieved the message and put it in a tool tip as shown:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ValidationHandler&amp;quot; &lt;/span&gt;&lt;span style="color: blue"&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Trigger &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Validation.HasError&amp;quot;
                 &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;True&amp;quot;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;TextBox.ToolTip&amp;quot;
                    &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;RelativeSource&lt;/span&gt;&lt;span style="color: blue"&gt;={&lt;/span&gt;&lt;span style="color: #a31515"&gt;RelativeSource &lt;/span&gt;&lt;span style="color: red"&gt;Self&lt;/span&gt;&lt;span style="color: blue"&gt;}, &lt;br /&gt;                             &lt;/span&gt;&lt;span style="color: red"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;=(Validation.Errors)[&lt;/span&gt;0&lt;span style="color: blue"&gt;].ErrorContent}&amp;quot; /&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Trigger&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;    
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;h2&gt;&amp;#160;&lt;/h2&gt;

&lt;h2&gt;The Problem with IsEnabled&lt;/h2&gt;

&lt;p&gt;Only one problem, it didn't work. When showing calculated fields I typically set the &lt;strong&gt;IsEnabled&lt;/strong&gt; flag to false. The user not only can't make changes but they get a pretty decent visual indicator that changes aren't allowed.&amp;#160; Turns out that when a TextBox (and maybe all controls) are disabled the tool tips don't show up.&amp;#160; I'm not sure why and there may be a better work-around but since I already had the style, I did my best to fake the disabled behavior. Here's the new xaml for the control: &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox &lt;/span&gt;&lt;span style="color: red"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;StaticResource &lt;/span&gt;&lt;span style="color: red"&gt;ValidationHandler&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;
          &lt;/span&gt;&lt;span style="color: red"&gt;IsReadOnly&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;True&amp;quot;
         &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;SamplingRate&lt;/span&gt;&lt;span style="color: blue"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;Mode&lt;/span&gt;&lt;span style="color: blue"&gt;=OneWay, &lt;/span&gt;&lt;span style="color: red"&gt;ValidatesOnDataErrors&lt;/span&gt;&lt;span style="color: blue"&gt;=True}&amp;quot;  /&amp;gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;I've set the IsReadOnly flag and removed the IsEnabled flag in the xaml for the control itself. You can also see how the ValidationHandler is hooked in. The new Style will take care of the IsEnabled flag. When no error is found IsEnabled will be false. If an error is found it will set IsEnabled to true and set the background gray (IsReadOnly is left set to True in both cases). The downside is the&amp;#160; user will still be able to click in the read-only box and highlight the value, but the TextBox will look like the disabled version and the user still can't make any changes.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ValidationHandler&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;BasedOn&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;StaticResource &lt;/span&gt;&lt;span style="color: red"&gt;nudSpacing&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Control.IsEnabled&amp;quot;
            &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;False&amp;quot; /&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Control.Background&amp;quot;
            &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;#F3F3F3&amp;quot;/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Trigger &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Validation.HasError&amp;quot;
                 &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;True&amp;quot;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;TextBox.ToolTip&amp;quot;
                    &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;RelativeSource&lt;/span&gt;&lt;span style="color: blue"&gt;={&lt;/span&gt;&lt;span style="color: #a31515"&gt;RelativeSource &lt;/span&gt;&lt;span style="color: red"&gt;Self&lt;/span&gt;&lt;span style="color: blue"&gt;}, &lt;br /&gt;                          &lt;/span&gt;&lt;span style="color: red"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;=(Validation.Errors)[&lt;/span&gt;0&lt;span style="color: blue"&gt;].ErrorContent}&amp;quot; /&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;TextBox.IsEnabled&amp;quot;
                    &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;True&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Trigger&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;           
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now when the user violates the validation and puts the cursor over the field they see:&lt;a href="http://lh6.ggpht.com/-CB4fhqha8-U/Th85XyDLfSI/AAAAAAAABDE/F1qkR1xrovE/s1600-h/SNAGHTML46718a5%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML46718a5" border="0" alt="SNAGHTML46718a5" src="http://lh4.ggpht.com/-t4vfz-BmDFI/Th85YI80AMI/AAAAAAAABDI/XP60cjlMuD8/SNAGHTML46718a5_thumb%25255B1%25255D.png?imgmax=800" width="481" height="85" /&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/7714188728416201038-1114072344513083532?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/1114072344513083532/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=1114072344513083532" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/1114072344513083532?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/1114072344513083532?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/8qXVRHS5n6s/wpf-validation-on-calculated-fields.html" title="WPF Validation on calculated fields" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-t4vfz-BmDFI/Th85YI80AMI/AAAAAAAABDI/XP60cjlMuD8/s72-c/SNAGHTML46718a5_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/wpf-validation-on-calculated-fields.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8AQXk6fyp7ImA9WhdTFEQ.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-6617489423620347667</id><published>2011-07-12T11:54:00.000-07:00</published><updated>2011-07-12T11:54:00.717-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-12T11:54:00.717-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><title>Treating XML files as Content</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GJHidK3r2Xvcee-ZLISbC86vKv8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GJHidK3r2Xvcee-ZLISbC86vKv8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GJHidK3r2Xvcee-ZLISbC86vKv8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GJHidK3r2Xvcee-ZLISbC86vKv8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I like keeping a lot of my application settings in a plain old XML data file. I've found the way Visual Studio treats it &lt;a href="http://syncor.blogspot.com/2008/12/reasons-to-avoid-visual-studios.html" target="_blank"&gt;Properties.Settings file to be more complicated than I like&lt;/a&gt;. The only thing I store there is the name of my xml application settings file. I mentioned in a previous post on using the MSI installer in Visual Studio that I keep my xml files set as content and this generated some feedback about exactly how do to that, prompting this blog.&lt;/p&gt;  &lt;h2&gt;The Solution Explorer is the place to be.&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-TJ2cNstvLVk/ThtHYiqqgrI/AAAAAAAABC8/YwhfZknTunM/s1600-h/SNAGHTML1493aa6d%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML1493aa6d" border="0" alt="SNAGHTML1493aa6d" align="left" src="http://lh3.ggpht.com/-e6Np9jkv4Tc/ThtHZBf3VPI/AAAAAAAABDA/Fu1eEJTu_vA/SNAGHTML1493aa6d_thumb%25255B1%25255D.png?imgmax=800" width="360" height="264" /&gt;&lt;/a&gt;The easiest thing to overlook is that the properties on a particular file can vary depending on where you click on it. For instance if you open an XML file and click on its tab or inside its content you will see a property dialog similar to the one shown at the left. You be justifiably confused about not being able to find the property for setting the file as content. &lt;/p&gt;  &lt;p&gt;   &lt;div style="clear: both"&gt;&lt;/div&gt;   &lt;a href="http://lh6.ggpht.com/-Nym6bpmMles/ThtG2B8K0nI/AAAAAAAABC0/U5oQzV0YRs0/s1600-h/SNAGHTML148f0587%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML148f0587" border="0" alt="SNAGHTML148f0587" align="left" src="http://lh4.ggpht.com/-cAdQSCZwoCc/ThtG2kqusRI/AAAAAAAABC4/IlL4tVXcxa8/SNAGHTML148f0587_thumb%25255B1%25255D.png?imgmax=800" width="375" height="276" /&gt;&lt;/a&gt;Instead you need to use the Solution Explorer and click on the .xml file there.&amp;#160; You'll notice the Property dialog changes and now you have a &lt;em&gt;Build Action&lt;/em&gt; property which you can set to &lt;em&gt;Content &lt;/em&gt;and a &lt;em&gt;Copy to Output Directory&lt;/em&gt; property to control how and when the copy happens. Most of the time I keep this set to Copy always because I want changes I make in the design environment to propagate to the application I run while Debugging. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-6617489423620347667?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/6617489423620347667/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=6617489423620347667" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/6617489423620347667?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/6617489423620347667?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/GyW4ovu5i74/treating-xml-files-as-content.html" title="Treating XML files as Content" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-e6Np9jkv4Tc/ThtHZBf3VPI/AAAAAAAABDA/Fu1eEJTu_vA/s72-c/SNAGHTML1493aa6d_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/treating-xml-files-as-content.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QCSXk9fCp7ImA9WhdTEkk.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-3204380941685368009</id><published>2011-07-09T12:56:00.001-07:00</published><updated>2011-07-09T12:56:08.764-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-09T12:56:08.764-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="MatLab" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Embedded" /><category scheme="http://www.blogger.com/atom/ns#" term="WCF" /><title>Signal Processing on Windows in Real Time</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-pGC9hrFaZJSUagxuOdMlwoGgyo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-pGC9hrFaZJSUagxuOdMlwoGgyo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-pGC9hrFaZJSUagxuOdMlwoGgyo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-pGC9hrFaZJSUagxuOdMlwoGgyo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You don't typically see &lt;em&gt;Windows&lt;/em&gt; and &lt;em&gt;Real Time&lt;/em&gt; in the same sentence. However, there can be some significant advantages to doing real time signal processing under Windows. This post was inspired by several questions posted on &lt;a href="http://www.stackoverflow.com" target="_blank"&gt;StackOverflow&lt;/a&gt; that got closed. I think they were good questions but they don't allow for succinct answers and that seems to violate the monitors sensibilities so I thought a longer form blog post might help some of those questioners.&lt;/p&gt;  &lt;h2&gt;You say Tomato I say That's not Real Time&lt;/h2&gt;  &lt;p&gt;So the first question is what's real time? It's a surprisingly hard thing to meaningfully define for the uninitiated but I'm going to try.&amp;#160; The primary requirement is that the system exhibit a certain amount of deterministic behavior. This means, that if you need say micro second level responses, that the system reliably and repeatedly will give you microsecond level responses. It can't honor microsecond level timing &amp;quot;most&amp;quot; of the time but every now and then go off to service a daemon or a garbage collector and be gone for 50-100 milliseconds. So at the microsecond level it would appear Windows doesn't cut it, but in fact there are hardware ways around this problem.&amp;#160; On the other hand if your real time requirement is hundreds of milliseconds Windows may be suitable without assistance. You might have to disable a lot of services (ala gamers) and you might need to take care with some garbage collected languages but it could easily work. If you need response time in the tens of milliseconds but the occasional hiccup isn't a problem, then I don't think of that as real-time, but again unadorned Windows may suffice. What follows is addressing the solution to the microsecond level deterministic requirement.&lt;/p&gt;  &lt;h2&gt;The Hardware Solution&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-0WhPz-UjU_0/ThiyUtBsIPI/AAAAAAAABCc/Qlv47z9n3gM/s1600-h/image%25255B2%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/-rly3VdaTk3Q/ThiyVBOdMBI/AAAAAAAABCg/fxpdTIfmKr8/image_thumb.png?imgmax=800" width="244" height="124" /&gt;&lt;/a&gt;The solutions I'm most familiar with are offered by &lt;a href="http://www.innovative-dsp.com/" target="_blank"&gt;Innovative Integration&lt;/a&gt;.&amp;#160; II has a series of cards that plug into the PCI backplane that can do a variety of functions and contain FPGAs so you can extend them to do exactly what you want. The cards contain enough buffering that even if the hosting OS is busy for hundreds of milliseconds (or possibly even longer) no data will be lost. This is critical in many of the radar applications I have written. In those applications I&amp;#160; will know where the data starts and keeping track of things like the elevation and azimuth angles is done simply by counting the data. A dropped packet would invalidate the entire run. The systems I 've worked on using the Innovative Integration cards have never dropped data and proven to be extremely reliable.&amp;#160; The most recent systems I've developed have used their ePC solution. The signal processing happens on a separate computer running Windows XP (the box comes with XP embedded but limitations on .NET and XP Embedded led us to upgrade the OS).&lt;/p&gt;  &lt;h2&gt;Integrating With Windows&lt;/h2&gt;  &lt;p&gt;The real-time stuff is being handled by PCI cards or a separate Windows computer with similar hardware. How does one solve the impedance mismatch between Windows timing and the real-time performance of the hardware? A lot depends on the problem you are trying to solve. If as in my case you are collecting radar data, it is the collection of the data, not the display of the data that is critical. I design my systems to make the first priority to store all the data to the hard drive. The next priority is to stream the data out the TCP port for display or additional processing. At this point I can tag the data with elevation and azimuth information so dropping chunks of data is not catastrophic. In fact the typical system collects way more data than a human can analyze in real time so there often is no problem in decimating the data stream being sent to the display. &lt;/p&gt;  &lt;h2&gt;C++/CLI to the rescue&lt;/h2&gt;  &lt;p&gt;The biggest problem can be the tools you use. The libraries for a real time system are typically going to be written in a systems level language (a language that compiles to the metal)&amp;#160; like C++. Writing your control software in C# can provide some interesting challenges when talking to those libraries. A particular pain point can be the handling of events. I found it impossible to wire up C# event handlers to the C++ events. However, writing thin wrappers in C++/CLI proved to be extremely beneficial. C++/CLI has a lot of facilities for bridging the gap between the managed world of .NET and the unmanaged world happening in the C++ libraries. Originally, I wrote a lot of code in C++/CLI but as grateful as I am for the language and its features I found the code I wrote in C++/CLI required more knowledge and sophistication to maintain properly. Eventually I migrated as much code as I could to C# and left the C++/CLI as the minimal wrapper. In the end this solution worked very well. &lt;/p&gt;  &lt;p&gt;There are alternate solutions as well. In fact II provides example solutions written for three environments, Visual Studio (straight VC++), Borland C++ Builder (again straight VC++) but BCB has C# like form designers (I should really say that C# has BCB like tools).&amp;#160; They also have examples using the Qt framework.&lt;/p&gt;  &lt;h2&gt;WCF also Helps&lt;/h2&gt;  &lt;p&gt;In the case of the ePC where all the processing is happening on a separate computer (usually headless and rack-mounted), I found that a simple WCF service was quite helpful. My GUI was written in C# on a remote computer on the LAN. Every change on the GUI was sent to the WCF service. The service also ran through a series of radar equations and modified dependent parameters. The dependent parameters were then updated on the GUI. It turns out that connecting to the WCF and making the first call is slow, but every call thereafter is quite fast. I made sure the first call happened during the boot phase. After that, users of the system had no idea a remote service was involved. The updating of the screen appeared in &amp;quot;real time&amp;quot; to the user (note that humans aren't microsecond sensitive creatures for the most part). &lt;/p&gt;  &lt;h2&gt;Plotting the Results&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-CFOAkahMIcA/ThiyVl8LuFI/AAAAAAAABCk/Vzcpogc_aSQ/s1600-h/RfBumpPic5%25255B3%25255D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="RfBumpPic5" border="0" alt="RfBumpPic5" align="left" src="http://lh5.ggpht.com/-9ph7dG5lDCE/ThiyVxhFS5I/AAAAAAAABCo/rfa9zxYQo4U/RfBumpPic5_thumb%25255B1%25255D.jpg?imgmax=800" width="454" height="293" /&gt;&lt;/a&gt;While the .NET world offers a lot of plotting packages, I had trouble finding any that bill themselves as &amp;quot;real time&amp;quot;, or even near real time or anything but static. I needed a fast dynamic PPI (polar) plotting capability. We were already using &lt;a href="http://www.mathworks.com/products/matlab/" target="_blank"&gt;MatLab&lt;/a&gt; for the FPGA programming and it turns out MatLab plotting is very fast and proved to be capable of sustaining the frame rates needed by the system. Again, I wrote the low-level code in MatLab's native language (using the object oriented variant helped). I then wrote wrappers to all the MatLab calls in C# and integrated the plotting window into my main C# GUI.&amp;#160; Both the GUI and a plot of some synthetically generated data can be seen in the figure to the left.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-3204380941685368009?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/3204380941685368009/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=3204380941685368009" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/3204380941685368009?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/3204380941685368009?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/ov1Bq644qYo/signal-processing-on-windows-in-real.html" title="Signal Processing on Windows in Real Time" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-rly3VdaTk3Q/ThiyVBOdMBI/AAAAAAAABCg/fxpdTIfmKr8/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/signal-processing-on-windows-in-real.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QESXkzcCp7ImA9WhdTEUk.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-3845723961240627861</id><published>2011-07-06T17:31:00.001-07:00</published><updated>2011-07-08T11:21:48.788-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-08T11:21:48.788-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="D" /><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><title>D Programming Language–First Steps</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Mve90qd7G9lSBEFHFVH3VK2eJdI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Mve90qd7G9lSBEFHFVH3VK2eJdI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Mve90qd7G9lSBEFHFVH3VK2eJdI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Mve90qd7G9lSBEFHFVH3VK2eJdI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I recently purchased &lt;a href="http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361/ref=sr_1_1?ie=UTF8&amp;amp;qid=1309998538&amp;amp;sr=8-1" target="_blank"&gt;Andrei Alexandrescu's&amp;#160; The D Programming Language&lt;/a&gt;&lt;em&gt;&lt;/em&gt;. I don't have an actual need to learn D but I know Andrei is an engaging writer and I wanted to know more about D. Of course, books on new programming languages are more fun to read if you can take the language out for a test drive. I didn't have a D Compiler so I decided I should try and find one. Turns out this isn't very hard to do. The author of the language Walter Bright has a free D compiler available &lt;a href="http://www.digitalmars.com/" target="_blank"&gt;on his web site&lt;/a&gt;. Of course it's even more fun to use a programming language inside an IDE and it turns out there are plug-ins for both Eclipse and Visual Studio readily available (and possibly others but these are the two I use). The Eclipse project I tried is called &lt;a href="http://code.google.com/a/eclipselabs.org/p/ddt/" target="_blank"&gt;DDT, and you can find it on the google code site&lt;/a&gt;. The project I used for Visual Studio 2010 is called &lt;a href="http://www.dsource.org/projects/visuald" target="_blank"&gt;Visual D&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;I made a screencast on taking those first steps of installing the compiler and IDE plug-ins. I then broke the screencast up into three pieces so you can just watch the pieces that interest you. Part 1 is on the DMD compiler itself, part 2 tackles the Eclipse &lt;a href="http://www.eclipse.org/helios/"&gt;Helios&lt;/a&gt; install and part 3 walks through the install for Visual Studio 2010. I make a mistake while locating the DMD folder for Visual Studio as it wants a different folder than Eclipse. This installation error results in a compile time problem. I annotated the screencast with my mistake so you won't make the same one, but I also show you how to fix the problem inside Visual Studio.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I also found a couple of other interesting sites if you're interested in writing Widows Forms (GUI) applications. Check out the &lt;a href="http://www.dprogramming.com/dfl.php" target="_blank"&gt;D Forms Library&lt;/a&gt;&amp;#160; and &lt;a href="http://www.dprogramming.com/entice.php" target="_blank"&gt;Entice&lt;/a&gt; the related GUI builder (drag and drop form creation similar to what you do in Visual Studio WinForm apps). &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Part I – Installing a D Compiler&lt;/h2&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c457fd23-85d3-4796-9910-e18b3b564e27" class="wlWriterEditableSmartContent"&gt;&lt;div id="763d7c17-da00-4392-9120-e3c529fc1f78" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=AaSBma22gNA&amp;amp;feature=youtube_gdata_player" target="_new"&gt;&lt;img src="http://lh3.ggpht.com/-jP_PSDoD6pA/ThdKuZ2Wr9I/AAAAAAAABCQ/C7VT3FPLIJQ/video882916acaae7%25255B9%25255D.jpg?imgmax=800" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('763d7c17-da00-4392-9120-e3c529fc1f78'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;938\&amp;quot; height=\&amp;quot;525\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/AaSBma22gNA?hl=en&amp;amp;hd=1\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/AaSBma22gNA?hl=en&amp;amp;hd=1\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;938\&amp;quot; height=\&amp;quot;525\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="width:938px;clear:both;font-size:.8em"&gt;Getting and Installing a D Compiler&lt;/div&gt;&lt;/div&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Part II - Eclipse&lt;/h2&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:35d0afa5-ae8e-482b-9171-4668b33bc007" class="wlWriterEditableSmartContent"&gt;&lt;div id="42f82222-bf2e-4964-9691-b41a8b90c6b7" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=cUutSv431Jg&amp;amp;feature=youtube_gdata_player" target="_new"&gt;&lt;img src="http://lh6.ggpht.com/-0CSNL9kvDTw/ThT-eBCF63I/AAAAAAAABCU/A6H209c_ZRk/video303708a24fad%25255B9%25255D.jpg?imgmax=800" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('42f82222-bf2e-4964-9691-b41a8b90c6b7'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;927\&amp;quot; height=\&amp;quot;519\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/cUutSv431Jg?hl=en&amp;amp;hd=1\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/cUutSv431Jg?hl=en&amp;amp;hd=1\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;927\&amp;quot; height=\&amp;quot;519\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="width:927px;clear:both;font-size:.8em"&gt;Getting and Installing the D Language Support in Eclipse&lt;/div&gt;&lt;/div&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Part III - Visual Studio&lt;/h2&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:7b7b5d06-7cb7-49a5-a908-1c9d2557750d" class="wlWriterEditableSmartContent"&gt;&lt;div id="824ce2a5-acb0-49b9-a3d6-67c30c1f1dbf" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=sbEbQbBgEsI&amp;amp;feature=youtube_gdata_player" target="_new"&gt;&lt;img src="http://lh6.ggpht.com/-HJe-WOHcbNI/ThT-eAC9Q_I/AAAAAAAABCY/JM8nyi3sXjo/videob7a104578d44%25255B9%25255D.jpg?imgmax=800" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('824ce2a5-acb0-49b9-a3d6-67c30c1f1dbf'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;913\&amp;quot; height=\&amp;quot;512\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/sbEbQbBgEsI?hl=en&amp;amp;hd=1\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/sbEbQbBgEsI?hl=en&amp;amp;hd=1\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;913\&amp;quot; height=\&amp;quot;512\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="width:913px;clear:both;font-size:.8em"&gt;Getting and Installing D Language Support in Visual Studio&lt;/div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-3845723961240627861?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/3845723961240627861/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=3845723961240627861" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/3845723961240627861?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/3845723961240627861?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/iyV3Znm5nUw/d-programming-languagefirst-steps.html" title="D Programming Language–First Steps" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-jP_PSDoD6pA/ThdKuZ2Wr9I/AAAAAAAABCQ/C7VT3FPLIJQ/s72-c/video882916acaae7%25255B9%25255D.jpg?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/d-programming-languagefirst-steps.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQMQXs_cCp7ImA9WhZaFk4.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-5667735187845798592</id><published>2011-07-02T12:03:00.000-07:00</published><updated>2011-07-02T12:03:00.548-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-02T12:03:00.548-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Windows 7" /><title>System File Checker</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wxnZBlvkGCVnZLUHTIn2C7BonGU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wxnZBlvkGCVnZLUHTIn2C7BonGU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wxnZBlvkGCVnZLUHTIn2C7BonGU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wxnZBlvkGCVnZLUHTIn2C7BonGU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I've railed against Microsoft before for how they seem to &lt;a href="http://syncor.blogspot.com/2010/09/anti-discoverability-windows-7-still.html" target="_blank"&gt;specialize in anti-discoverability&lt;/a&gt; of features in their programs. This also applies to utilities that come with the operating system. There's a nifty little tool called &lt;em&gt;System File Checker.&lt;/em&gt; SFC is designed to scan your system files and replace any incorrect versions. Doesn't this sound like either something you should know about or something that should run automatically?&amp;#160; Isn't this just as important as system updates? Why would I want to keep around incorrect versions? Couldn't it at least run automatically in &lt;em&gt;VerifyOnly&lt;/em&gt; mode?&amp;#160; I was having an issue where the Windows Desktop Manager kept quitting on me. This would hang up my mouse keyboard and monitor for over a minute. It would only happen a couple of times a day but it was still a nuisance. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-QXfyY3VY4YQ/Tg4a7WU5jzI/AAAAAAAABBo/QPZMmqGlNgs/s1600-h/image%25255B6%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/-iBAxsasWmow/Tg4a73rg0FI/AAAAAAAABBs/mDZP3J9_Ejw/image_thumb%25255B2%25255D.png?imgmax=800" width="342" height="258" /&gt;&lt;/a&gt;I lived with it for it for quite a while before I discovered sfc.&amp;#160; I ran sfc from a command prompt. Under Vista and Windows 7 you want to right-click on your Command Prompt shortcut and select Run as Administrator.&lt;/p&gt;  &lt;p&gt;Just typing sfc in the command prompt will give you some information on the various options for the tool. Pick your poison and let loose the dogs of cleanup.&amp;#160; This solved most of my desktop manager issues, since it identified some files that needed to be updated. Now the desktop manager only goes on strike about once a week or so.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-0-st2ZNqtZE/Tg4a8aPFsdI/AAAAAAAABBw/Zj3VWLR0lRU/s1600-h/image%25255B12%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://lh4.ggpht.com/-_gmSvRTGUvo/Tg4a9b6E-YI/AAAAAAAABB0/QVpcKRcac8s/image_thumb%25255B6%25255D.png?imgmax=800" width="847" height="592" /&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/7714188728416201038-5667735187845798592?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/5667735187845798592/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=5667735187845798592" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5667735187845798592?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/5667735187845798592?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/l68KMJbqMbw/system-file-checker.html" title="System File Checker" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-iBAxsasWmow/Tg4a73rg0FI/AAAAAAAABBs/mDZP3J9_Ejw/s72-c/image_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/system-file-checker.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMAQXY6cSp7ImA9WhZaFUk.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-1077678866992113682</id><published>2011-07-01T11:54:00.001-07:00</published><updated>2011-07-01T11:54:00.819-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-01T11:54:00.819-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vista" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 7" /><title>Cleaning up Floating Widgets on your Screen</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4v7kGBnS1egF89tA7OsFzAnlQ9k/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4v7kGBnS1egF89tA7OsFzAnlQ9k/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4v7kGBnS1egF89tA7OsFzAnlQ9k/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4v7kGBnS1egF89tA7OsFzAnlQ9k/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I'm running Windows 7 and every now and then I end up with an item from a menu or combo box floating on my screen. It's like a little lost puppy that can't find its way home, only way more annoying. The left over drek typically clutters my screen until I restart. I found an easier way for the widget to find its way back home:&lt;/p&gt;  &lt;p&gt;Under Control-&amp;gt;Panels –&amp;gt;Performance Information and Tools-&amp;gt;Adjust Visual Effects&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-jljn-VzwAIA/Tg4XxSwtR5I/AAAAAAAABBg/-ce5zUTHDZ4/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 13px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh4.ggpht.com/-DXKPM5p0PWo/Tg4Xx1h-VUI/AAAAAAAABBk/THBi9u2kuKg/image_thumb%25255B1%25255D.png?imgmax=800" width="620" height="535" /&gt;&lt;/a&gt;Turn off the checkbox for Use Visual Styles on Windows and Buttons. It takes a minute or more to reconfigure your display, be patient. I then turn it back on. In the meantime the floating widget found its rightful place and is no longer hanging around on my screen.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-1077678866992113682?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/1077678866992113682/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=1077678866992113682" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/1077678866992113682?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/1077678866992113682?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/E2JWQhpkflM/cleaning-up-floating-widgets-on-your.html" title="Cleaning up Floating Widgets on your Screen" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-DXKPM5p0PWo/Tg4Xx1h-VUI/AAAAAAAABBk/THBi9u2kuKg/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/07/cleaning-up-floating-widgets-on-your.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcDRHw8cSp7ImA9WhZaEk0.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-2291136514577136007</id><published>2011-06-27T12:14:00.001-07:00</published><updated>2011-06-27T12:14:35.279-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-27T12:14:35.279-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Nontechnical" /><title>Counting Characters in Outlook</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/LERou8ooV8ZuY07B16zb7enJgA0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LERou8ooV8ZuY07B16zb7enJgA0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/LERou8ooV8ZuY07B16zb7enJgA0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LERou8ooV8ZuY07B16zb7enJgA0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I hate texting. I've been touch typing since my Mom brought home that Olivetti back when I was in middle school. That's long enough ago that my brain and fingers no longer have a direct connection. My fingers know how to type all by themselves. The problem is when I go to text (with one of those little teeny-tiny keyboards on a phone – I become the world's slowest hunt and pecker, I have to pretend to touch type every time I want to find &amp;quot;b&amp;quot;.&amp;#160; So my solution is to just send texts via email . As far as I can tell every cell provider has an email suffix for this. You type the persons phone number followed by the proper email domain suffix. &lt;/p&gt;  &lt;h2&gt;Can you count to 160?&lt;/h2&gt;  &lt;p&gt;The point of this post is the problem with using email to respond to text. Unless you tweet, it's hard to gauge just how short 160 characters is. If you exceed that length your message might just get truncated or split into multiple text messages. So the key is to know just how many characters you've typed. You can do this in Outlook 2007, but it's far from obvious how. Ideally you would want something showing you the count as you type (like even the most dimwitted text editors do). I haven't found this in Outlook yet but at least there is way to do it on demand. Spell check. Yep, that's right. The feature you always use but never invoke manually. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-zby6v8F6PDE/TgjWiF3oAZI/AAAAAAAABA0/DsaykSTjHro/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://lh3.ggpht.com/-SDI2NZoSbSA/TgjWi23vfrI/AAAAAAAABA4/itjchoINDlQ/image_thumb%25255B1%25255D.png?imgmax=800" width="967" height="305" /&gt;&lt;/a&gt;    &lt;div style="clear: both"&gt;&lt;/div&gt;   &lt;a href="http://lh5.ggpht.com/-EJ_RthojWpE/TgjWjIckSuI/AAAAAAAABBA/38a5rL74jn4/s1600-h/SNAGHTML90b42e8%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML90b42e8" border="0" alt="SNAGHTML90b42e8" align="left" src="http://lh6.ggpht.com/-TuzkNjgvfec/TgjWjUN4H4I/AAAAAAAABBE/dg-U3qSbG-Y/SNAGHTML90b42e8_thumb.png?imgmax=800" width="244" height="211" /&gt;&lt;/a&gt;Hiding right there at the bottom is &lt;em&gt;Word Count…,&lt;/em&gt; type your message and click it and you'll get a dialog similar to that shown at the left. Now if you look carefully at the first image above, you'll notice the &lt;em&gt;Word Count…&lt;/em&gt; icon in the quick launch toolbar at the top of the window.&amp;#160; That's not there by default, but you can easily add it.&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt; &lt;a href="http://lh5.ggpht.com/-zRN-SccDv9U/TgjWj2-NGGI/AAAAAAAABBI/HdJzADUhuMQ/s1600-h/SNAGHTML91ca7d2%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML91ca7d2" border="0" alt="SNAGHTML91ca7d2" align="left" src="http://lh6.ggpht.com/-y4Kq5vRPWLY/TgjWkYNA3CI/AAAAAAAABBM/ZCQRo2uybDI/SNAGHTML91ca7d2_thumb%25255B2%25255D.png?imgmax=800" width="310" height="315" /&gt;&lt;/a&gt;            &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-o-7rlh4KmOQ/TgjWkw1z3hI/AAAAAAAABBQ/nazSi8xS19E/s1600-h/SNAGHTML9212367%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML9212367" border="0" alt="SNAGHTML9212367" align="right" src="http://lh4.ggpht.com/-OmNSqkjE-XA/TgjWlRMGtDI/AAAAAAAABBU/QLC6KhPv_as/SNAGHTML9212367_thumb%25255B2%25255D.png?imgmax=800" width="359" height="278" /&gt;&lt;/a&gt;Click the little drop down arrow on the right of the quick launch bar and select the &lt;em&gt;More Commands…&lt;/em&gt; option as shown in the image at the left. You'll get the dialog shown in the image on the right. In that dialog follow the green arrows, choose the &lt;em&gt;Message Tab&lt;/em&gt;, scroll to the bottom and choose the &lt;em&gt;Word Count…&lt;/em&gt; command, click the &lt;strong&gt;Add&amp;gt;&amp;gt;&lt;/strong&gt; button and &lt;em&gt;Word Count…&lt;/em&gt; will show up in the right pane. Click &lt;strong&gt;OK&lt;/strong&gt; and the command should now be in your quick launch bar. One final tip.    &lt;div style="clear: both"&gt;&amp;#160;&lt;/div&gt;    &lt;div style="clear: both"&gt;&lt;a href="http://lh5.ggpht.com/-XsL3I1DjKFg/TgjWl9uts6I/AAAAAAAABBY/VQeRcyqzKDg/s1600-h/SNAGHTML931dc2b%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML931dc2b" border="0" alt="SNAGHTML931dc2b" align="left" src="http://lh5.ggpht.com/-jpLI_NKs6ho/TgjWmoTm5cI/AAAAAAAABBc/nC8YWSyD0AA/SNAGHTML931dc2b_thumb%25255B1%25255D.png?imgmax=800" width="321" height="173" /&gt;&lt;/a&gt;Hold down the Alt key. A series of characters will litter your screen. You'll notice on mine that 6, corresponds to the word count. That means I can hit Alt-6 and the word count dialog will appear on my screen. Now if I could just curb my verbose writing style I might like texting.&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/7714188728416201038-2291136514577136007?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/2291136514577136007/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=2291136514577136007" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/2291136514577136007?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/2291136514577136007?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/yP8C5Joj8hQ/counting-characters-in-outlook.html" title="Counting Characters in Outlook" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-SDI2NZoSbSA/TgjWi23vfrI/AAAAAAAABA4/itjchoINDlQ/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/06/counting-characters-in-outlook.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UCQX06fyp7ImA9WhZaEUw.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-2348163450749163975</id><published>2011-06-26T11:01:00.000-07:00</published><updated>2011-06-26T11:01:00.317-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-26T11:01:00.317-07:00</app:edited><title>Project Locker No Space Left on Device</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/j-dSX10eRC5g-jfnTduQi2mCaRw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j-dSX10eRC5g-jfnTduQi2mCaRw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/j-dSX10eRC5g-jfnTduQi2mCaRw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j-dSX10eRC5g-jfnTduQi2mCaRw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The other day I tried to commit my changes and received the error message that's the title for this post. Nothing strikes fear into the heart of a coder faster than a failure on the source code management system. At first I thought maybe I had just exceeded my limit and had to pay for more storage, but when I went to the site I was under 50%. I was perplexed but luckily for me, too busy to worry about it right then. I tried a few things but nothing worked. Later in the day I came back to the problem and unlike a programming error, this problem magically disappeared. I suspect the server hosting my database actually ran out of disk space and it took &lt;a href="http://www.projectlocker.com/"&gt;ProjectLocker&lt;/a&gt; a couple of hours to rectify the situation. So if you come across this error your best bet may be to just be patient and wait for the tech gurus to swap in a new petra-byte hard drive. Luckily in all the time I've been using ProjectLocker this is the first time this has happened. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-2348163450749163975?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/2348163450749163975/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=2348163450749163975" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/2348163450749163975?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/2348163450749163975?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/gEFSGH8tw30/project-locker-no-space-left-on-device.html" title="Project Locker No Space Left on Device" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/06/project-locker-no-space-left-on-device.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UERX4_fSp7ImA9WhZbGU4.&quot;"><id>tag:blogger.com,1999:blog-7714188728416201038.post-7185021363145680452</id><published>2011-06-24T05:00:00.000-07:00</published><updated>2011-06-24T11:13:24.045-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-24T11:13:24.045-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><title>The Visual Studio MSI Installer</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/FaK3NoZ3OK2tTjFja_GGyqLysZA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FaK3NoZ3OK2tTjFja_GGyqLysZA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/FaK3NoZ3OK2tTjFja_GGyqLysZA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FaK3NoZ3OK2tTjFja_GGyqLysZA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The Click Once installer in Visual Studio is very discoverable and I've known about it and used it for years. I don't like it but I've used it, especially when a project has multiple dependencies. Much less discoverable is the fact that a more standard MSI installer is also included in Visual Studio. Why am I always the last to find out?&amp;#160; Here are some step by step instructions for creating an MSI installer from inside Visual Studio 2010.&lt;/p&gt;  &lt;h2&gt;Step 1.&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-gY6geDY7RTM/TgQmG7O7S3I/AAAAAAAAA_E/zd9YVGMoeRk/s1600-h/SNAGHTML6ee87d8%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML6ee87d8" border="0" alt="SNAGHTML6ee87d8" align="left" src="http://lh4.ggpht.com/-ajWTNJlJTIM/TgQmHedSKqI/AAAAAAAAA_I/P-rx_LvrMwg/SNAGHTML6ee87d8_thumb%25255B2%25255D.png?imgmax=800" width="673" height="313" /&gt;&lt;/a&gt;Right-click on your solution and choose Add-&amp;gt; New Project…&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;  &lt;h2&gt;Step 2. &lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-ye0LyjupfgE/TgTTucexg-I/AAAAAAAABAk/7ETS9VEIgKw/s1600-h/SNAGHTML6f264ee%25255B1%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 9px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML6f264ee" border="0" alt="SNAGHTML6f264ee" align="left" src="http://lh6.ggpht.com/-lp9XJr37laE/TgQmIHelL8I/AAAAAAAABAo/Pqz_A54aQE4/SNAGHTML6f264ee_thumb.png?imgmax=800" width="637" height="377" /&gt;&lt;/a&gt;Open up the Other Project Types-&amp;gt;Setup and Deployment-&amp;gt;Visual Studio Installer (OK it wasn't that hard to discover but I seldom get past the Visual C# option. ) Enter a name and hit OK.&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;  &lt;h2&gt;Step 3.&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-jeJSsc0usCY/TgQmIearo-I/AAAAAAAAA_U/ZocEhZte0UU/s1600-h/SNAGHTML6f5c555%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML6f5c555" border="0" alt="SNAGHTML6f5c555" align="left" src="http://lh4.ggpht.com/-4adOxpuBOSg/TgQmI5w40GI/AAAAAAAAA_Y/20tLMwR62Mw/SNAGHTML6f5c555_thumb%25255B2%25255D.png?imgmax=800" width="551" height="441" /&gt;&lt;/a&gt;Walk through the wizard. In my case when selecting files I only needed to select the Content Files and Primary Output. I have an xml file that resides in a XmlData folder that must get created but since I marked its build property as &lt;em&gt;content&lt;/em&gt; the wizard will take care of that automatically.&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-S5tieosfQzs/TgQmJfMplZI/AAAAAAAAA_c/CfTkM3clv5o/s1600-h/SNAGHTML6f67321%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML6f67321" border="0" alt="SNAGHTML6f67321" src="http://lh6.ggpht.com/-EawHKfW48RM/TgQmJ5OSY2I/AAAAAAAAA_g/jnh__iyM1ug/SNAGHTML6f67321_thumb%25255B2%25255D.png?imgmax=800" width="552" height="440" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Step 4. &lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-NAhA2snBrMU/TgQmKY1qT6I/AAAAAAAAA_k/QzzwRXW98yw/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/-BQTh_aQHNN0/TgQmP52m5cI/AAAAAAAAA_o/iPpXsq2RfGU/image_thumb%25255B1%25255D.png?imgmax=800" width="498" height="311" /&gt;&lt;/a&gt;When the wizard is done you should have a new project and a new pane called File System should be open. If it's not you can right-click on your new project and select the View menu and select the File System option. You'll notice there are several other interesting options that deserve further exploration in the future.&lt;/p&gt;  &lt;p style="clear: both"&gt;&lt;/p&gt;  &lt;h2&gt;Step 5.&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-HfwNZPzSDws/TgQmQr54U_I/AAAAAAAABAs/mnqYCOWujVI/s1600-h/SNAGHTML7931607%25255B1%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="SNAGHTML7931607" border="0" alt="SNAGHTML7931607" align="left" src="http://lh5.ggpht.com/-uQd3DGRCk5U/TgQmSTDzRcI/AAAAAAAABAw/WAqbX0oVmMA/SNAGHTML7931607_thumb.png?imgmax=800" width="754" height="342" /&gt;&lt;/a&gt;If you want shortcuts to your application put in the Start menu and on the desktop, you have a couple of steps left. Also, I want my shortcuts to have the proper icons, so I'll include the steps for that. In the File System pane click on the Application folder and then in the right pane right click on the Primary output as shown and select the option for creating a shortcut as shown. &lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;    &lt;h2&gt;Step 6.&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-7-OAYV_68oc/TgQmSyYxcdI/AAAAAAAAA_0/gB-OegIGcBY/s1600-h/image%25255B8%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh3.ggpht.com/-Q5Cq78krwAM/TgQmTG62icI/AAAAAAAAA_4/-bjutVGNkbw/image_thumb%25255B4%25255D.png?imgmax=800" width="769" height="270" /&gt;&lt;/a&gt;Click on the created shortcut and give it a&amp;#160; better name. Then in the properties pane locate the Icon option and from the drop down select &lt;em&gt;(Browse…)&lt;/em&gt; as shown at left.&lt;/p&gt;  &lt;p&gt;Then in the dialog click the &lt;em&gt;Browse…&lt;/em&gt; button (see the figure below). In the &lt;strong&gt;Select Item in Project&lt;/strong&gt; dialog select the &lt;em&gt;Application Folder&lt;/em&gt; at the top, select &lt;em&gt;Executable Files (*.exe)&lt;/em&gt; from the &lt;strong&gt;Files of Type&lt;/strong&gt; drop down and click on your primary output (as shown below) to pick the icon you associated with your application. This will result in the second dialog shown below where a small version of your icon is shown. Don't worry the appropriate size will be shown for the shortcut. Click OK and then drag the shortcut file into the User's Desktop folder. You can repeat this process again and drag the second copy into the User's Programs folder. In the User's Programs menu if you want to group your choices under your company name you can add a folder like I did in the above dialog for ITS-9202 and drag the shortcut into that folder. As you can tell I dragged the shortcut there before I set the icon. The order you perform these steps is not important.&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt; &lt;a href="http://lh4.ggpht.com/-eXAjZdol2pI/TgQmUIl7kaI/AAAAAAAAA_8/sb8P3hUHL0Y/s1600-h/SNAGHTML796fd2a%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML796fd2a" border="0" alt="SNAGHTML796fd2a" src="http://lh5.ggpht.com/-zkWuBV6OQbo/TgQmUkC-u6I/AAAAAAAABAA/JC3JxJL25eQ/SNAGHTML796fd2a_thumb%25255B2%25255D.png?imgmax=800" width="693" height="491" /&gt;&lt;/a&gt;   &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-3nYKU3ripsM/TgQmU28wkgI/AAAAAAAABAE/m-9lnF1m330/s1600-h/SNAGHTML798d984%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML798d984" border="0" alt="SNAGHTML798d984" src="http://lh5.ggpht.com/-ed1zEcjpGl0/TgQmVaS_scI/AAAAAAAABAI/TwD4c20Wzeo/SNAGHTML798d984_thumb%25255B1%25255D.png?imgmax=800" width="506" height="399" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Step 7 (The Final Step)&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-NrXupkplDB4/TgQmVpV6zZI/AAAAAAAABAM/KlGYuzMxrKQ/s1600-h/image%25255B12%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh3.ggpht.com/-t_H0kx445oE/TgQmWO3W0WI/AAAAAAAABAQ/1NFqcA6sZdc/image_thumb%25255B6%25255D.png?imgmax=800" width="515" height="366" /&gt;&lt;/a&gt;In the Solution Explorer right-click on your new install project and select Build. When the build finishes you can right-click again and select &lt;em&gt;Open Folder in Windows Explorer&lt;/em&gt; and go try out your new installer. There are separate folders for your Release and Debug configurations so be sure to build both. Each folder should contain a setup.exe and the associated .msi file. I only ever use the Release version for the copy sent to the final client.&lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt;  &lt;h2&gt;More Optional Steps&lt;/h2&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-nV4E2A5NlQY/TgQmWr51JHI/AAAAAAAABAU/ZaHzaN_UZu4/s1600-h/image%25255B22%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/-HL0XBeZDfCw/TgQmXcXcriI/AAAAAAAABAY/fixx1pDa_SU/image_thumb%25255B12%25255D.png?imgmax=800" width="659" height="448" /&gt;&lt;/a&gt;You can click on the installer project and then check out the properties panel to see many other options that can be set. There are also option panels for each of the folders in your project. Examples of both property panes are shown to the left and&amp;#160; below. I've marked a few of the items in the project properties that I usually change. Your choices for customization aren't limited to what I've shown here, but this is as far as my experience has taken me. &lt;/p&gt;  &lt;div style="clear: both"&gt;&lt;/div&gt; &lt;a href="http://lh3.ggpht.com/-kzgMY4tLwME/TgQmbHBO4oI/AAAAAAAABAc/5sBtAHEHRqc/s1600-h/image%25255B26%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-Hk8ufLiGFvo/TgQmbvjqNTI/AAAAAAAABAg/A8NsJccQm9k/image_thumb%25255B14%25255D.png?imgmax=800" width="680" height="272" /&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7714188728416201038-7185021363145680452?l=syncor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://syncor.blogspot.com/feeds/7185021363145680452/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7714188728416201038&amp;postID=7185021363145680452" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/7185021363145680452?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7714188728416201038/posts/default/7185021363145680452?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TodsTomes/~3/uEXcyKBJTlE/visual-studio-msi-installer.html" title="The Visual Studio MSI Installer" /><author><name>Tod</name><uri>http://www.blogger.com/profile/17212382407893076905</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/_8WbLM5HMd2A/SueU28pDCEI/AAAAAAAAAPU/nkuyB-isgko/S220/TodFullKit.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-ajWTNJlJTIM/TgQmHedSKqI/AAAAAAAAA_I/P-rx_LvrMwg/s72-c/SNAGHTML6ee87d8_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://syncor.blogspot.com/2011/06/visual-studio-msi-installer.html</feedburner:origLink></entry></feed>

