<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Blog</title><link>http://www.robertmclaws.com:80/</link><description>Blog</description><item><title>An Open Letter to the Microsoft Data Teams About Enums</title><link>http://www.robertmclaws.com:80/an-open-letter-to-the-microsoft-data-teams-about-enums</link><description>Dear Microsoft Data Teams,&lt;br /&gt;
&lt;br /&gt;
First off, I just want to say that I think the work you guys have done over the last&amp;nbsp;6 years&amp;nbsp;has been&amp;nbsp;awesome. Seriously. It has never been easier to get information into an out of a database, and throw it over a service. And the work with EF 5.0 on .NET 4.5 has brought with it some outstanding work in performance, usability, and especially support for Enums.&lt;br /&gt;
&lt;br /&gt;
But this improvement has come at a price. Because OData does not officially support the concept of a first-class Enum type, if you are using any of the methods of leveraging OData (WCF Data Services or the new WebApi OData support, specifically) your code will break without any kind of warning. Why? Because&amp;nbsp;&amp;quot;Enum&amp;quot; is itself a new enumeration entry in the EdmTypeKind, and there is not a build of WCF Data Services explicitly for .NET 4.5 that filters this type out while initializing entities. In WCF Data Services, the metadata startup code only checks for one value in the EdmTypeKind enumeration, and assumes all others will work on the &amp;quot;Else&amp;quot; codepath... which is not true for Enums.&lt;br /&gt;
&lt;br /&gt;
So if you update a project running EF5 + WCF Data Services to .NET 4.5, you will be greeted with a low-level failure on your services that cannot be overridden without hundreds of lines of reflection code (believe me, I&amp;#39;ve tried).&lt;br /&gt;
&lt;br /&gt;
It is amazing to me that you guys at Microsoft can even get away with this kind of breakage without repercussions.&amp;nbsp;The downloads for EF5 or WCF Data Services do not explicitly state that you cannot add Enums to your model if you want to still be able to run WCF Data Services. I guess you guys just assume that it won&amp;#39;t be an issue, because Enums are new and people won&amp;#39;t try to build services that support them.&lt;br /&gt;
&lt;br /&gt;
If you assumed that, you were wrong.&lt;br /&gt;
&lt;br /&gt;
But it doesn&amp;#39;t have to be this way. I&amp;#39;ve asked those among you several times why there is no support, and the answer I keep getting back is somewhere along the lins of &amp;quot;we&amp;#39;ll have first-class support someday&amp;quot;. But there is a big gap between &amp;quot;first-class support&amp;quot; and &amp;quot;fail at a level so low our built-in method of excluding or mapping types hasn&amp;#39;t even kicked in yet&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Enums are backed by CLR primitive types: Int32, Int64, Byte, just to name a few. So why are you so worried about being able to represent the enumeration type fully in the $metadata document? Services like &lt;a href="http://www.twilio.com/docs/api/rest/conference"&gt;Twilio&lt;/a&gt; (see the Status field) use either the string or integer representation of the Enum, and force the developer to know what the integer values are. Either way, it is the developer&amp;#39;s responsibility to enter them correctly. If you don&amp;#39;t, they fail.&lt;br /&gt;
&lt;br /&gt;
So why can&amp;#39;t you do it this way? Why can&amp;#39;t you do what your previous design forced thousands of EF developers to do: have an internal&amp;nbsp;backing property that represented the integer version of the Enum, and then convert back and forth to the Enum at runtime? The answer is, of course you can. You guys just had other priorities. Which I understand. But not shipping bits that break in existing applications should have been a priority too. Or at the very least, having clear documentation that warns them of the problem before they spend time implementing it, identifying the problem, and trying to work around it.&lt;br /&gt;
&lt;br /&gt;
This is easily fixable, especially in the new WebApi formatters. Just make it work like every other property, serialize the number for the underlying type, and let us developers work out the details of how to get the value into and out of the system the way we want to.&lt;br /&gt;
&lt;br /&gt;
And please do it fast. I&amp;#39;d really like to ship this API I&amp;#39;ve been working on for the last few months.&lt;br /&gt;
&lt;br /&gt;
Respectfully,&lt;br /&gt;
&lt;br /&gt;
Robert McLaws&lt;br /&gt;
Entity Framework Enthusiast &amp;amp; .NET Developer</description><pubDate>Mon, 20 Aug 2012 03:45:55 GMT</pubDate><guid isPermaLink="true">http://www.robertmclaws.com:80/an-open-letter-to-the-microsoft-data-teams-about-enums</guid></item><item><title>Pre-generating Views to Improve Performance in EF5</title><link>http://www.robertmclaws.com:80/pre-generating-views-to-improve-performance-in-ef5</link><description>The other day, the EF Team posted guidance on how to &lt;a href="http://msdn.microsoft.com/en-us/data/hh949853"&gt;improve performance for Entity Framework 5.0&lt;/a&gt;. Their very first recommendation was to pre-generate the Views that EF uses to run its queries. Typically these views are automatically generated the first time the application is executed, but this can dramatically increase the execution time on the first query.&lt;br /&gt;
&lt;br /&gt;
Their solution was to pre-generate the code using EdmGen.exe, and in 2008 &lt;a href="http://blogs.msdn.com/b/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx"&gt;the team provided a T4 template&lt;/a&gt; to automate that process for Database First and Model First scenarios. However, the latest guidance provided incomplete information on how to update that template to run in Visual Studio 2011. Since I&amp;#39;m getting ready to release several other tools for EF5, I thought it would be a good time to learn the ins and outs of publishing a template to the Visual Studio Gallery.&lt;br /&gt;
&lt;br /&gt;
Using the latest DbContext genrators Microsoft put out as a guide, I was able to figure out how to have the template show up as a Code Generation Item in the Entity Designer. Just right-click anywhere in the designer, select &amp;quot;Add Code Generation Item&amp;quot;, and then select &amp;quot;EF 5.x Views Generator&amp;quot;. The views will automatically be added to your project, all you need to do is hit &amp;quot;Compile&amp;quot;, and watch your first query execute just as quickly as all the others.&lt;br /&gt;
&lt;br /&gt;
Though I will not be providing any &amp;quot;official&amp;quot; support, if you have any issues, please let me know. Oh, and you can &lt;strong&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/cae64fbf-0dd0-45ba-8e33-58ff7a5c90ae"&gt;download the template here&lt;/a&gt;&lt;/strong&gt;, or by searching for &amp;quot;views generation&amp;quot; in the Visual Studio 11 Extension Manager.</description><pubDate>Sun, 08 Apr 2012 18:52:21 GMT</pubDate><guid isPermaLink="true">http://www.robertmclaws.com:80/pre-generating-views-to-improve-performance-in-ef5</guid></item><item><title>Updating Your Windows Phone to 8107</title><link>http://www.robertmclaws.com:80/updating-your-windows-phone-to-8107</link><description>&lt;strike&gt;&lt;span style="color: rgb(255,0,0)"&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/span&gt; If you have the Trophy, you can use these instructions to upgrade to 7740, but not 8107. There is apparently a driver mismatch or something that is causing the phone dialer to crash.&lt;/strike&gt;&lt;br /&gt;
&lt;span style="color: rgb(255,0,0)"&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt;&lt;/span&gt; So apparently, this update has an ENGLISH language pack as well. Not sure why. On the Verizon HTC Trophy, you need both the English and Spanish language packs. Check your phone before you update. Additional instructions are below.&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #ff0000"&gt;UPDATE 3:&lt;/span&gt;&lt;/strong&gt; I just received the &amp;quot;HTC Update for Windows Phone&amp;quot; from Verizon with this update already installed, so it appears that if you follow these directions, you should be able to update safely (at least with the Verizon HTC Trophy). I have also added additional language packs (see #7, thanks Plaffo.com!)&lt;br /&gt;
&lt;br /&gt;
So I&amp;#39;m pretty fed up with cell carriers (&lt;a href="http://windowsteamblog.com/windows_phone/b/windowsphone/archive/2012/01/06/new-maintenance-release-for-windows-phone.aspx"&gt;and now Microsoft&lt;/a&gt;) and their update nonsense. I have the HTC Trophy on Verizon, and I doubt they will ever pick up any new interim updates to the phone. In fact, if they don&amp;#39;t announce a new Windows Phone at CES next week, I am finally jumping ship to AT&amp;amp;T.&lt;br /&gt;
&lt;br /&gt;
So instead of waiting for an update that will probably never come, I decided to update my phone myself. Fortunately,&amp;nbsp;Italy&amp;#39;s&amp;nbsp;premier Windows Phone community &amp;quot;Plaffo&amp;quot; has instructions on how to do so. Here is &lt;a href="http://translate.google.com/translate?sl=auto&amp;amp;tl=en&amp;amp;js=n&amp;amp;prev=_t&amp;amp;hl=en&amp;amp;ie=UTF-8&amp;amp;layout=2&amp;amp;eotf=1&amp;amp;u=http%3A%2F%2Fwww.plaffo.com%2F2012%2F01%2Fguida-ecco-come-installare-laggiornamento-8107-manualmente-su-tutti-i-terminali-windows-phone%2F"&gt;the English version of the post&lt;/a&gt;, but I&amp;#39;ll summarize the instructions below to keep it simple. &lt;strong&gt;FOLLOW THEM AT YOUR OWN RISK.&lt;/strong&gt;&lt;br /&gt;
&lt;ol&gt;
	&lt;li&gt;
		Make sure your phone is charged to at least 50%. Plug your phone into your computer, and then close Zune.&lt;/li&gt;
	&lt;li&gt;
		On your phone, go to Settings | Region + Language | Display Language and make note of the available languages.&lt;/li&gt;
	&lt;li&gt;
		Download&amp;nbsp;a tool from xb0xm0d (&lt;a href="http://www.megaupload.com/?d=3ZOHDYC5"&gt;WP7 CAB Update Sender&lt;/a&gt;) that allows you to connect to the phone, back it up, and pass CAB files as updates.&lt;/li&gt;
	&lt;li&gt;
		Extract the tool to any folder.&lt;/li&gt;
	&lt;li&gt;
		Download the &lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/10/diff-7.10.7720.68-7.10.7740.16-armv7-retail-microsoft.pks_2cb1bfdd82133914239b8ee1a78e61e9000d124a.cab"&gt;7740 update CAB file&lt;/a&gt; to the same place you extracted the CAB Update Sender (this is from an official Microsoft download server).&lt;/li&gt;
	&lt;li&gt;
		Download the &lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.pks_c9b7f3bc5bb340ba30473b566b4557de0cf3322e.cab"&gt;8107 update CAB file&lt;/a&gt; to the same place you extracted the CAB Update Sender (also from an official Microsoft download server).&lt;/li&gt;
	&lt;li&gt;
		Download the &lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0409.pks_bfd9c047a7b27c28208c8a717f8d7511fb2586f1.cab"&gt;English (US)&amp;nbsp;language pack&lt;/a&gt;, as well as any of the following additional packs: &lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0404.pks_14f5fe7f4a13691af0836c66b24609a7cc4d91bf.cab"&gt;Chinese (traditional),&lt;/a&gt; &lt;span&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0804.pks_f72389ae04c3dadd144cffa0c4951c4c7970f7eb.cab"&gt;Chinese (simplified)&lt;/a&gt;&lt;/span&gt;, &lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0407.pks_b50019ef50d52090d408d854c0708ddbf520706c.cab"&gt;German&lt;/a&gt;,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0405.pks_39e23349a19a6a22080ef7a2feb92e392bf760d4.cab"&gt;Czech&lt;/a&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_040c.pks_2d74e8c5f6a835f1fe4c62b488c96ac2d7f01c29.cab"&gt;French&lt;/a&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0809.pks_2666da3127f526b23b492f293983ccce1d28f375.cab"&gt;English &amp;ndash; UK,&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0c0a.pks_97df86b81a40df06bb2b15c6739e2ee772e53bbf.cab"&gt;Spanish&lt;/a&gt;, &lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0406.pks_405c4cea1c731f7e162bb22e856bb581bb2a487b.cab"&gt;Danish&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0408.pks_03d24647cd9678f10b7bb59aed3527312ea165e9.cab"&gt;Greek&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_040b.pks_398799fcdc32f92bced716dcd7606916d9c6a02d.cab"&gt;Finnish&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_040e.pks_bb52bdd5424ec4921a80a5e70b280ff021613b0f.cab"&gt;Hungarian&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0411.pks_02108a1813a8f3ddfaba98f21d72ad0942e696a9.cab"&gt;Japanese&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0412.pks_94f886dab44851ddfc1481f6ce183930d58625c7.cab"&gt;Korean&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0413.pks_8fb73a926d0b157da33edde9e6332a68a4ee2fb2.cab"&gt;Dutch&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0414.pks_b79d55444fefc11af29ddb3abab85c255f9bbb8b.cab"&gt;Norwegian&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0415.pks_53749601c866e4521044b02fe4a03625fbb8a31f.cab"&gt;Polish&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0416.pks_4cadd6d75bd962d8e0d25cf3fa85cd71b011a750.cab"&gt;Portuguese &amp;ndash; (Brazil&lt;/a&gt;&lt;/span&gt;), &lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0419.pks_8d8f924349f1f1e98c2677380ca38b73b6ef245f.cab"&gt;Russian&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_041d.pks_7be1f542160ac7088439c273b1d40469569a32b4.cab"&gt;Swedish&lt;/a&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="google-src-text" style="direction: ltr; text-align: left"&gt;&lt;a href="http://download.windowsupdate.com/msdownload/update/software/dflt/2011/12/diff-7.10.7740.16-7.10.8107.79-armv7-retail-microsoft.lang_0816.pks_c595c2d27f7d43a6357ea17adde815e9495274c7.cab"&gt;Portuguese &amp;ndash; (Portugal&lt;/a&gt;&lt;/span&gt;)&lt;/span&gt; &lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;
		&lt;span style="color: rgb(255,0,0)"&gt;&lt;strong&gt;WARNING: If your phone has more languages than listed above, STOP NOW. You will put your phone in a &amp;quot;Walshed&amp;quot; state if you choose to continue.&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;
		Go to the folder &amp;quot;if needed install this tool&amp;quot;, and then open the x86 or x64 folder, depending on your system architecture.&lt;/li&gt;
	&lt;li&gt;
		Run &amp;quot;Setup-UpdateWP-{x86|x64}.exe&amp;quot;&lt;/li&gt;
	&lt;li&gt;
		Navigate back to the root folder for the tool and double-click &amp;quot;WP7 Update Sender.bat&amp;quot;&lt;/li&gt;
	&lt;li&gt;
		When prompted, select &amp;quot;B&amp;quot;. This will create a backup of your phone and then update it.&lt;/li&gt;
&lt;/ol&gt;
If you follow these instructions, you should have a backup of your phone, and be updated to 8107, in about 10-15 minutes. If you find out later that there is an official update for your phone, you can sync your content with Zune, then restore your previous backup using the same tool, and run the legitimate update.</description><pubDate>Sun, 22 Jan 2012 03:31:44 GMT</pubDate><guid isPermaLink="true">http://www.robertmclaws.com:80/updating-your-windows-phone-to-8107</guid></item><item><title>Making Your Code Pretty on Orchard with SyntaxHighlighter</title><link>http://www.robertmclaws.com:80/making-your-code-pretty-on-orchard-with-syntaxhighlighter</link><description>This site is powered by Orchard CMS, and I&amp;#39;m a huge fan of the design. I&amp;#39;m not the biggest fan of the documentation tho, and many of the plugins suffer from the same lack of documentation. While I was working on my last post, I needed a way to be able to post code. I really like the version of SyntaxHighlighter that used to have the &amp;quot;copy to clipboard | raw view&amp;quot; toolbar in the corner, but apparently that used Flash, and the new version does not.&lt;br /&gt;
&lt;br /&gt;
At any rate, I wanted to write about how to how to configure SyntaxHighlighter with Orchard, as the documentation isn&amp;#39;t exactly clear, and the built-in editor doesn&amp;#39;t like it very much.&lt;br /&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;strong&gt;Step 1:&lt;/strong&gt; In the Admin console, go to &amp;quot;Modules | Gallery&amp;quot;, search for &amp;quot;SyntaxHighlighter&amp;quot;, and install and activate&amp;nbsp;&amp;quot;SyntaxHighlighter for Orchard&amp;quot;.&lt;/li&gt;
	&lt;li&gt;
		&lt;strong&gt;Step 2: &lt;/strong&gt;Go back to the Modules Gallery, search for &amp;quot;CKEditor&amp;quot;, and install it.&lt;/li&gt;
	&lt;li&gt;
		&lt;strong&gt;Step 3:&lt;/strong&gt; Go to Modules, and under the &amp;quot;Input Editor&amp;quot; section, disable &amp;quot;TinyMCE&amp;quot;.&lt;/li&gt;
&lt;/ul&gt;
Now, when you go to post, wrap your code in &amp;lt;pre class=&amp;quot;brush: csharp&amp;quot;&amp;gt;Your code here&amp;lt;/pre&amp;gt;, and you&amp;#39;ll be good to go.</description><pubDate>Mon, 05 Sep 2011 02:40:16 GMT</pubDate><guid isPermaLink="true">http://www.robertmclaws.com:80/making-your-code-pretty-on-orchard-with-syntaxhighlighter</guid></item><item><title>Simplify your WPF Converters with the ConvertibleMarkupExtension</title><link>http://www.robertmclaws.com:80/simplify-your-wpf-converters-with-the-convertiblemarkupextension</link><description>&lt;p&gt;
	You can&amp;#39;t get away with coding in XAML without using IValueConverters.&amp;nbsp;If by some miracle you&amp;#39;ve figured out how, then please, do share :). In the meantime, there is a way to keep you from having to declare each converter you use as a named resource, through MarkupExtensions.&amp;nbsp;Some great examples of this technique can be found &lt;a href="http://www.thejoyofcode.com/WPF_Quick_Tip_Converters_as_MarkupExtensions.aspx" target="_blank"&gt;here&lt;/a&gt;&amp;nbsp;and &lt;a href="http://drwpf.com/blog/2009/03/17/tips-and-tricks-making-value-converters-more-accessible-in-markup/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
	This technique originated from &lt;a href="http://www.codeproject.com/Articles/69528/Quick-WPF-tip-Generic-Converter-MarkupExtension.aspx" target="_blank"&gt;Robert Sonnino&lt;/a&gt;, but I refactored it a teeny bit. What he wrote is a fantasic piece of code, and I&amp;#39;m not sure why it isn&amp;#39;t used more often. It should be the basis for every BindingConverter that anyone ships. It uses Generics to keep you from having to write the same MarkupExtension implementation over and over again. I wish&amp;nbsp;I had thought of it :).&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;
    /// &lt;summary&gt;
    /// A base class used to make awesome Converters with.
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;
    /// The type implementing IValueConverter to make awesome.
    /// &lt;/typeparam&gt;
    [MarkupExtensionReturnType(typeof(IValueConverter))]
    public abstract class ConvertibleMarkupExtension&amp;lt;T&amp;gt; : MarkupExtension
        where T : class, IValueConverter, new()
    {

        #region Private Members

        private static T _converter;

        #endregion

        #region MarkupExtension Implementation

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return _converter ?? (_converter = new T());
        }

        #endregion

    }
&lt;/pre&gt;
&lt;p&gt;
	Then you have your converters inherit from it, like this:&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;
    /// &lt;summary&gt;
    /// Converts an Integer Value into a Visibility Enumeration based on the passed-in parameter. 
    /// &lt;/summary&gt;
    public class IntEqualToVisibilityConverter : 
        ConvertibleMarkupExtension&amp;lt;IntEqualToVisibilityConverter&amp;gt;, IValueConverter
    {

        #region IValueConverter Implementation

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null || parameter == null) return Visibility.Collapsed;
            if (value == DependencyProperty.UnsetValue) return Visibility.Collapsed;

            int valueToCompare = (int)value;
            int referenceValue = int.Parse((string)parameter);

            return valueToCompare == referenceValue ? Visibility.Visible : Visibility.Collapsed;

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return ((value is Visibility) &amp;amp;&amp;amp; (((Visibility)value) == Visibility.Visible));
        }

        #endregion

    }
&lt;/pre&gt;
&lt;p&gt;
	Which will let you craft your XAML code like this:&lt;/p&gt;
&lt;pre class="brush: xml"&gt;
    &amp;lt;Label Content=&amp;quot;Served As&amp;quot; Visibility=&amp;quot;{Binding Path=GeneralInfoState, 
        Converter={converters:IntGreaterOrEqualToVisibilityConverter}, ConverterParameter=2}&amp;quot; /&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
	You can even use it to make the built in converters even more awesome:&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;
    public class BooleanToVisibilityConverter : 
        ConvertibleMarkupExtension&amp;lt;System.Windows.Controls.BooleanToVisibilityConverter&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
	So thanks a bunch, &lt;a href="http://virtualdreams.com.br/blog/" target="_blank"&gt;Robert Sonnino&lt;/a&gt;, you&amp;#39;re the man. The ConvertibleMarkupExtension, as well as all of the Converters I&amp;#39;ve written, will be posted to a new NuGet package I&amp;#39;m working on in a few days. Until then, happy coding!&lt;/p&gt;
</description><pubDate>Mon, 05 Sep 2011 02:18:10 GMT</pubDate><guid isPermaLink="true">http://www.robertmclaws.com:80/simplify-your-wpf-converters-with-the-convertiblemarkupextension</guid></item><item><title>Welcome to the new site!</title><link>http://www.robertmclaws.com:80/welcome-to-the-new-site</link><description>&lt;p&gt;It has been far too long since I've had a personal blog, so it's time to fire this sucker up again. I've been working on a lot of WP7 apps and different NuGet projects lately, and each of those projects needed a home to talk about them. So now they live here. The site is pretty self-explanatory, so there is no need to go through each section. So have a look around, and please feel free to leave me feedback. Thanks!&lt;/p&gt;</description><pubDate>Sat, 03 Sep 2011 20:59:27 GMT</pubDate><guid isPermaLink="true">http://www.robertmclaws.com:80/welcome-to-the-new-site</guid></item></channel></rss>