<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Mad Props!</title><link>http://www.madprops.org/</link><description>Omniscience is just a Google-search away.</description><generator>Graffiti CMS 1.2 (build 1.2.0.1451)</generator><lastBuildDate>Tue, 09 Jun 2009 00:35:00 GMT</lastBuildDate><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/mabster" type="application/rss+xml" /><item><title>Name this [Anti-]Pattern</title><link>http://feedproxy.google.com/~r/mabster/~3/-0Cs6_mui8U/</link><pubDate>Tue, 09 Jun 2009 00:35:00 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/name-this-anti-pattern/</guid><dc:creator>mabster</dc:creator><slash:comments>2</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;Over the long weekend I managed to do a little bit more work on the next version of &lt;a href="http://comicster.net/"&gt;Comicster&lt;/a&gt;. I don&amp;rsquo;t know when this version will ever see the light of day because I seem to be spending as much time ripping code out and rewriting it as I do adding new features! Still, it&amp;rsquo;s a fun and educational way to pass the time.&lt;/p&gt;
&lt;p&gt;In this latest batch of work I have been trying to extract the &amp;ldquo;online database&amp;rdquo; functionality out of the core executable and turn it into a &lt;a href="http://mef.codeplex.com/"&gt;MEF extension&lt;/a&gt;. That way I can introduce other online databases (such as the new &lt;a href="http://www.madprops.org/blog/comicster-comicvine-wcf-and-rest-apis/"&gt;ComicVine API&lt;/a&gt;) by copying a DLL into a known folder. In doing so, I&amp;rsquo;ve employed a pattern (or possibly an anti-pattern) which is working quite well. If you know what its name is, please tell me!&lt;/p&gt;
&lt;p&gt;I start by defining an interface which will be the contract that any online database extensions will have to fulfil:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IServiceExtension
&lt;/span&gt;{
    &lt;span style="color: #2b91af"&gt;Character&lt;/span&gt; GetCharacter(&lt;span style="color: blue"&gt;string &lt;/span&gt;id);
    &lt;span style="color: #2b91af"&gt;Creator&lt;/span&gt; GetCreator(&lt;span style="color: blue"&gt;string &lt;/span&gt;id);
    &lt;span style="color: #2b91af"&gt;Publisher&lt;/span&gt; GetPublisher(&lt;span style="color: blue"&gt;string &lt;/span&gt;id);
    &lt;span style="color: #2b91af"&gt;Trade&lt;/span&gt; GetTrade(&lt;span style="color: blue"&gt;string &lt;/span&gt;id);
    &lt;span style="color: #2b91af"&gt;Title&lt;/span&gt; GetTitle(&lt;span style="color: blue"&gt;string &lt;/span&gt;id);
    &lt;span style="color: #2b91af"&gt;Issue&lt;/span&gt; GetIssue(&lt;span style="color: blue"&gt;string &lt;/span&gt;id);
}&lt;/pre&gt;
&lt;p&gt;That&amp;rsquo;s not the complete interface, but this snippet at least gives us the ability to download the details for all the items that Comicster can track online.&lt;/p&gt;
&lt;p&gt;However, to use this interface in a program would be quite clunky. I&amp;rsquo;d have to do a switch on the currently-selected item&amp;rsquo;s type, calling the appropriate &amp;ldquo;Get*&amp;rdquo; method on the interface. Something like:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(SelectedItem &lt;span style="color: blue"&gt;is &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Issue&lt;/span&gt;)
{
    onlineItem = GetIssue(((&lt;span style="color: #2b91af"&gt;Issue&lt;/span&gt;)SelectedItem).Id);
}
&lt;span style="color: blue"&gt;else if &lt;/span&gt;(SelectedItem &lt;span style="color: blue"&gt;is &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Title&lt;/span&gt;) ...&lt;/pre&gt;
&lt;p&gt;That&amp;rsquo;s &lt;em&gt;ugly&lt;/em&gt; code, and I know it must be possible to refactor it to take advantage of the fact that all the known types in Comicster derive from a common class (Comicster.Item). So I plan to add a new abstract method to Comicster.Item, like this (I&amp;rsquo;ll think of a better name eventually):&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;abstract class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Item&lt;/span&gt;
{
    &lt;span style="color: blue"&gt;abstract &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Item&lt;/span&gt; GetById(&lt;span style="color: #2b91af"&gt;IServiceExtension&lt;/span&gt; service);
}&lt;/pre&gt;
&lt;p&gt;This method, then, would have overrides in classes that descend from Item, like this:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Issue&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;Item&lt;/span&gt;
{
    &lt;span style="color: blue"&gt;override &lt;/span&gt;Item GetById(&lt;span style="color: #2b91af"&gt;IServiceExtension&lt;/span&gt; service)
    {
        &lt;span style="color: blue"&gt;return &lt;/span&gt;service.GetIssue(&lt;span style="color: blue"&gt;this&lt;/span&gt;.Id);
    }
}

&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Title&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;Item&lt;/span&gt;
{
    &lt;span style="color: blue"&gt;override &lt;/span&gt;Item GetById(&lt;span style="color: #2b91af"&gt;IServiceExtension&lt;/span&gt; service)
    {
        &lt;span style="color: blue"&gt;return &lt;/span&gt;service.GetTitle(&lt;span style="color: blue"&gt;this&lt;/span&gt;.Id);
    }
}&lt;/pre&gt;
&lt;p&gt;So each class knows which method to call on IServiceExtension to get a copy of its own &amp;ldquo;online&amp;rdquo; version. The program code to download the online item becomes much simpler now:&lt;/p&gt;
&lt;pre class="code"&gt;
onlineItem = SelectedItem.GetById(service);&lt;/pre&gt;
&lt;p&gt;This means that no matter what type the selected item is, it will &amp;ldquo;know&amp;rdquo; how to download a copy of itself from the online database service. It&amp;rsquo;s a little bit like the Strategy Pattern, I suppose, except that each derived class knows how to use the given service in its own way. Is there a name for this pattern? Or is it an anti-pattern? Will it work? What do you think?&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/name-this-anti-pattern/</feedburner:origLink></item><item><title>The Not-So-Hidden Cost of Censorship</title><link>http://feedproxy.google.com/~r/mabster/~3/PFmX_lWQAUY/</link><pubDate>Tue, 02 Jun 2009 22:41:56 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/the-not-so-hidden-cost-of-censorship/</guid><dc:creator>mabster</dc:creator><slash:comments>0</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;With permission, I’d like to reproduce this forum post by industry insider Mark Newton about the Labor government’s plan for Internet censorship:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The Govt claims to be budgeting $44.5m for this scheme.&lt;/p&gt;    &lt;p&gt;In &lt;a href="http://www.aph.gov.au/hansard/senate/commttee/S12031.pdf"&gt;Estimates on May 25th&lt;/a&gt; we see Ms. O'Loughlin telling Senator Birmingham about the ACMA blacklist:&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Ms O’Loughlin&lt;/strong&gt;—At 30 April ACMA’s blacklist contained 977 URLs.&lt;/p&gt;    &lt;p&gt;Then, addressing Senator Ludlam:&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Ms O’Loughlin&lt;/strong&gt;—With the current breakdown at 30 April, 51 per cent were refused classification and around 32 per cent were child abuse material and child sexual abuse material. &lt;/p&gt;    &lt;p&gt;According to my superhuman math skills, 51% of 977 is 499 URLs.&lt;/p&gt;    &lt;p&gt;If we are to believe Conroy's expression of the Policy Of The Week for the week ending Friday 5th June 2009, those 499 URLs are the only ones that will be blocked.&lt;/p&gt;    &lt;p&gt;... at a cost of $44.5m. That's nearly $90,000 per URL.&lt;/p&gt;    &lt;p&gt;If 32 per cent of the list was &amp;quot;child abuse material and child sexual abuse material,&amp;quot; and assuming that ACMA is actually qualified to make that kind of judgment, that means 313 URLs were in that category.&lt;/p&gt;    &lt;p&gt;At $142,173 of Commonwealth expenditure per URL, I reckon I could employ a police officer for an entire year, tell him that his only mission for the year is to track down the pedophile who published that URL, and pay whatever travel expenses are required to track the pedophile down to his house anywhere in the world and arrest him personally.&lt;/p&gt;    &lt;p&gt;But no, the Conroy/Rudd plan is to leave that material online where everyone in the world who happens to be interested in it can still find it, and spend all the money on Conroy's List instead — Which will inevitably be published, &lt;em&gt;again&lt;/em&gt;. Senator Stephen Conroy will be spending Commonwealth funds on making it easier for people who are turned on by child abuse to find child abuse imagery.&lt;/p&gt;    &lt;p&gt;I guess in these trying times, our Government figures that pedophiles need economic stimulus too. :-)&lt;/p&gt;    &lt;p&gt;The only saving grace that such a scheme will have is that everyone knows that ACMA's content assessment process is so woefully compromised that it's highly unlikely that the list will be comprised of child abuse imagery, so leaking it will probably prove to be harmless. Refused Classification is a pretty broad brush, and almost all of it is legal, so who cares if it gets out?&lt;/p&gt;    &lt;p&gt;Is that part of Conroy's political calculation here?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Mark’s posts on the &lt;a href="http://forums.whirlpool.net.au/forum/100?g=175"&gt;Whirlpool Forum threads&lt;/a&gt; about Labor’s censorship plans are of consistently high quality, but this one was pure gold, and I had to put it out there for others to read.&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/the-not-so-hidden-cost-of-censorship/</feedburner:origLink></item><item><title>ClickOnce and Desktop Shortcuts</title><link>http://feedproxy.google.com/~r/mabster/~3/HMKz1c7lHPE/</link><pubDate>Tue, 02 Jun 2009 04:11:55 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/clickonce-and-desktop-shortcuts/</guid><dc:creator>mabster</dc:creator><slash:comments>0</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;Ok, this was a weird one. This post isn’t a solution, merely a description of the problem and a workaround. I’m putting it out there for Google-juice just in case someone else has the same issue and has an idea of a proper solution.&lt;/p&gt;  &lt;p&gt;We have a couple of applications internally that are ClickOnce deployed. They date back to Visual Studio 2005 so they’re .NET 2.0 applications, and they’ve had plenty of updates over the years which get pulled down automatically by the clients. It works a treat.&lt;/p&gt;  &lt;p&gt;Now, if you remember all the way back to the days of yore before there was such thing as .NET 3.5 SP1, you’ll know that ClickOnce originally didn’t give you the option of creating a desktop shortcut. The only thing you could do as part of the deployment was to create an icon in the Start menu. That was fine for us – our users would install the application and then drag the Start menu icon onto their desktop manually.&lt;/p&gt;  &lt;p&gt;3.5 SP1 introduced the ability to create a desktop shortcut as part of the ClickOnce installation, and I think it has caused a bit of a problem for us.&lt;/p&gt;  &lt;p&gt;You see, just recently our IT department pushed out .NET 3.5 SP1 via a group policy. That’s awesome for us, because every PC in the company now has it installed. Our applications, though, are still .NET 2.0, and thus don’t have the “create desktop icon” setting in their ClickOnce options.&lt;/p&gt;  &lt;p&gt;With the latest updates to our applications, it seems that the client PCs are looking at the update, noticing that it doesn’t have an option to create a desktop shortcut, and &lt;strong&gt;removing&lt;/strong&gt; the existing desktop icon for the app! So everybody who updates to the latest (.NET 2.0) version of our app is calling us, complaining that their desktop icons have disappeared!&lt;/p&gt;  &lt;p&gt;The only workaround we have right now is to update the apps themselves to .NET 3.5 SP1 apps, and check the “Create desktop icon” checkbox in the ClickOnce options dialog. It’s not much of a solution, and it’s a drag for those clients who &lt;em&gt;don’t &lt;/em&gt;want a desktop icon, because it gets re-created with every update. Still, it’s all we can do right now.&lt;/p&gt;  &lt;p&gt;If you’ve seen this behaviour, leave us a comment! It’s a shame that ClickOnce couldn’t just leave the icon there if the update tells it not to create one.&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/clickonce-and-desktop-shortcuts/</feedburner:origLink></item><item><title>Playing with ViewModel in WPF</title><link>http://feedproxy.google.com/~r/mabster/~3/Md0_m6NDxeM/</link><pubDate>Thu, 28 May 2009 04:11:30 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/playing-with-viewmodel-in-wpf/</guid><dc:creator>mabster</dc:creator><slash:comments>3</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;Please don’t read this post as some sort of lesson in best-practice for WPF. It’s purely about my (mis)adventures with the Model-View-ViewModel (MVVM) pattern so far, in which I totally misuse and abuse the pattern to get something working.&lt;/p&gt;  &lt;p&gt;We’ve been working on a WPF navigation-style application that’s essentially a big load of CRUD. It has a bunch of pages, and they all have a very similar layout:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.madprops.org/files/media/image/WindowsLiveWriter/PlayingwithViewModelinWPF_C78F/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="A common page in my app" border="0" alt="A common page in my app" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/PlayingwithViewModelinWPF_C78F/image_thumb.png" width="391" height="272" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After creating the seventh or eighth version of this page, I started wondering whether we couldn’t just have one “view” page with this layout, and a bunch of “ViewModel” classes that provide the page with its logic. We could use WPF’s DataTemplate system to customize what the list displayed, and its Command system for the buttons and “extra” commands.&lt;/p&gt;  &lt;p&gt;I found &lt;a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx"&gt;this article by Josh Smith on MSDN&lt;/a&gt; and gave it a quick skim. My one big take-away from it was his RelayCommand class, which is a lightweight, lambda-based ICommand implementation. So I stole that and started spiking.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.madprops.org/files/media/image/WindowsLiveWriter/PlayingwithViewModelinWPF_C78F/image_8.png"&gt;&lt;img style="border-right-width: 0px; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ViewModel&amp;lt;T&amp;gt;" border="0" alt="ViewModel&amp;lt;T&amp;gt;" align="left" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/PlayingwithViewModelinWPF_C78F/image_thumb_3.png" width="130" height="320" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So here’s my ViewModel class in all its glory. As you can see, it has a command for each button (Find, New, Edit and Delete). They’re instances of RelayCommand which are tied to some virtual methods on the class. When I want a new ViewModel I simply derive from this class and override the methods like CanDelete(object item) or CreateNew().&lt;/p&gt;  &lt;p&gt;Notice that the class has a property called SearchCriteriaControl. This is of type UserControl, and represents the “Search criteria” section in my sketched-out page above. That way a ViewModel can customize how the user searches for its items.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The other thing I’ve done here is given my ViewModel SelectedValue and SelectedValuePath properties. These are dependency properties, and are created with FrameworkPropertyMetadata.Journal = true, so when you navigate away from the page and then back again, it remembers which item you last selected in the ListBox.&lt;/p&gt;  &lt;p&gt;Along the way I have also added two properties to RelayCommand. One is “Text” so that I can customize what the buttons show (certain objects might show “Disable” rather than “Delete”, for example). The other is a boolean “IsAvailable” property which I set to false if I want the button to disappear completely. Certain objects can be created and deleted but never edited, and it would be frustrating for a user to see an Edit button that’s always disabled.&lt;/p&gt;  &lt;p&gt;Here’s a snippet of XAML from my view page:&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;StackPanel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ContentControl
        &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;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;searchCriteriaControl&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;Content&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;SearchCriteriaControl&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;Margin&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0,0,0,5&amp;quot;
        &lt;/span&gt;&lt;span style="color: red"&gt;TabIndex&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;
        &lt;/span&gt;&lt;span style="color: red"&gt;IsTabStop&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;False&amp;quot;
        &lt;/span&gt;&lt;span style="color: red"&gt;Keyboard.PreviewKeyDown&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;searchCriteriaControl_PreviewKeyDown&amp;quot;
        /&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button 
        &lt;/span&gt;&lt;span style="color: red"&gt;Command&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;FindCommand&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;Width&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;75&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Right&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;Content&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;_Find&amp;quot;
        &lt;/span&gt;&lt;span style="color: red"&gt;TabIndex&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;1&amp;quot; /&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;So you can see that I’m presenting the user with the customized Search Criteria UI, and a “Find” button that tells the ViewModel to perform the search. The PreviewKeyDown event handler is so the user can always press Enter to perform the search. Here’s the strip of buttons along the bottom:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DockPanel &lt;/span&gt;&lt;span style="color: red"&gt;DockPanel.Dock&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Bottom&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;LastChildFill&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;False&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Margin&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;10&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DockPanel.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;BooleanToVisibilityConverter &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;b2v&amp;quot;/&amp;gt;

        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Button&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;DockPanel.Dock&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Right&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;Margin&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;5,0,0,0&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;Width&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;75&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;Content&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;                    &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;Command&lt;/span&gt;&lt;span style="color: blue"&gt;.&lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;,&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;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Static &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: red"&gt;Self&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;Visibility&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;                    &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;Command&lt;/span&gt;&lt;span style="color: blue"&gt;.&lt;/span&gt;&lt;span style="color: red"&gt;IsAvailable&lt;/span&gt;&lt;span style="color: blue"&gt;,&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;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Static &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: red"&gt;Self&lt;/span&gt;&lt;span style="color: blue"&gt;},&lt;/span&gt;&lt;span style="color: red"&gt;Converter&lt;/span&gt;&lt;span style="color: blue"&gt;={&lt;/span&gt;&lt;span style="color: #a31515"&gt;StaticResource &lt;/span&gt;&lt;span style="color: red"&gt;b2v&lt;/span&gt;&lt;span style="color: blue"&gt;}}&amp;quot; /&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;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DockPanel.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;

    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button 
        &lt;/span&gt;&lt;span style="color: red"&gt;Command&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;DeleteCommand&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;CommandParameter&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;SelectedItem&lt;/span&gt;&lt;span style="color: blue"&gt;,&lt;/span&gt;&lt;span style="color: red"&gt;ElementName&lt;/span&gt;&lt;span style="color: blue"&gt;=listBox1}&amp;quot;
        &lt;/span&gt;&lt;span style="color: red"&gt;TabIndex&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;5&amp;quot;/&amp;gt;

    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button 
        &lt;/span&gt;&lt;span style="color: red"&gt;Command&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;EditCommand&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;CommandParameter&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;SelectedItem&lt;/span&gt;&lt;span style="color: blue"&gt;,&lt;/span&gt;&lt;span style="color: red"&gt;ElementName&lt;/span&gt;&lt;span style="color: blue"&gt;=listBox1}&amp;quot; 
        &lt;/span&gt;&lt;span style="color: red"&gt;TabIndex&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;4&amp;quot;
        /&amp;gt;

    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button 
        &lt;/span&gt;&lt;span style="color: red"&gt;Command&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;NewCommand&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;
        &lt;/span&gt;&lt;span style="color: red"&gt;TabIndex&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;3&amp;quot; /&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DockPanel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;So each button is bound back to its corresponding command, and also pulls its visibility and content from the command’s IsAvailable and Text properties, respectively.&lt;/p&gt;

&lt;p&gt;Lastly, here’s the list of “extra” commands at the bottom-left of the page:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GroupBox &lt;/span&gt;&lt;span style="color: red"&gt;DockPanel.Dock&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Bottom&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Header&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Extras&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Padding&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;5&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GroupBox.Style&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: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Type &lt;/span&gt;&lt;span style="color: red"&gt;GroupBox&lt;/span&gt;&lt;span style="color: blue"&gt;}&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;DataTrigger &lt;/span&gt;&lt;span style="color: red"&gt;Binding&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;ExtraCommands&lt;/span&gt;&lt;span style="color: blue"&gt;.&lt;/span&gt;&lt;span style="color: red"&gt;Count&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&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;Visibility&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Collapsed&amp;quot;/&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTrigger&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;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;GroupBox.Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;

    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ItemsControl &lt;/span&gt;&lt;span style="color: red"&gt;DockPanel.Dock&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Bottom&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;ItemsSource&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;ExtraCommands&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock &lt;/span&gt;&lt;span style="color: red"&gt;Margin&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0,3&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Hyperlink &lt;/span&gt;&lt;span style="color: red"&gt;Command&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: blue"&gt;}&amp;quot;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock &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;Text&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Hyperlink&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ItemsControl&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;GroupBox&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;So we simply display the extra commands as a list of hyperlinks inside a GroupBox, and hide the entire thing if there aren’t any extra commands.&lt;/p&gt;

&lt;p&gt;Now the big reveal. Here’s what my page looks like with a derived ViewModel driving it:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.madprops.org/files/media/image/WindowsLiveWriter/PlayingwithViewModelinWPF_C78F/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The working view page with an &amp;quot;Entries&amp;quot; ViewModel" border="0" alt="The working view page with an &amp;quot;Entries&amp;quot; ViewModel" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/PlayingwithViewModelinWPF_C78F/image_thumb_4.png" width="537" height="388" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So the “Edit” and “Delete” buttons are disabled because the selected item is read-only (a property on the model). You can see that I’ve provided my own Search Criteria control (a label and a date TextBox). The big “Entries” label at the top is bound to the “Title” property on the ViewModel so it changes depending on what type you’re dealing with.&lt;/p&gt;

&lt;p&gt;This is working pretty well in my spike. I haven’t yet hit any major stumbling blocks, and I’ve managed to get a few different view models working, including one that swaps out the search criteria for a simple CheckBox (“active only”).&lt;/p&gt;

&lt;p&gt;One thing that’s still fuzzy right now is how much the ViewModels should know about my application. For example, when the user clicks the “New” button, the ViewModel will have to navigate to another page; but should it know which page it needs to navigate to, or should I be “injecting” that into the ViewModel with a Func&amp;lt;Page&amp;gt; or something?&lt;/p&gt;

&lt;p&gt;More to come! Leave me a comment and tell me where you think I’m going wrong!&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/playing-with-viewmodel-in-wpf/</feedburner:origLink></item><item><title>Internet Celebrity Power</title><link>http://feedproxy.google.com/~r/mabster/~3/XirSZMmyIAE/</link><pubDate>Sun, 24 May 2009 22:27:14 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/internet-celebrity-power/</guid><dc:creator>mabster</dc:creator><slash:comments>0</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;On Saturday, &lt;a href="http://www.hanselman.com"&gt;Scott Hanselman&lt;/a&gt; tweeted about the new &lt;a href="http://blog.stackoverflow.com/2009/05/nowearn-valuable-flair/"&gt;Stack Overflow “flair” feature&lt;/a&gt;, and I directed him here to Mad Props so he could check out my “Xbox GamerCard” version (you can see it over there in the sidebar on the top-right). Subsequently he posted &lt;a href="http://twitter.com/shanselman/status/1880686556"&gt;this tweet&lt;/a&gt;, linking to my blog post about the Windows 7 logo.&lt;/p&gt;  &lt;p&gt;Witness the power of an Internet celebrity. Here’s what happened to my daily hit rate when Scott linked to me:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Views per day" border="0" alt="Views per day" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/InternetCelebrityPower_76E2/image_3.png" width="317" height="193" /&gt; &lt;/p&gt;  &lt;p&gt;That post quickly jumped to #4 on my &lt;em&gt;most viewed posts of all time&lt;/em&gt; chart. Not bad for a single link on Twitter!&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/internet-celebrity-power/</feedburner:origLink></item><item><title>WPF Killed the RadioButton Star</title><link>http://feedproxy.google.com/~r/mabster/~3/iBn0fNaJkNk/</link><pubDate>Fri, 22 May 2009 02:13:41 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/wpf-killed-the-radiobutton-star/</guid><dc:creator>mabster</dc:creator><slash:comments>0</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;Ok, it’s a really dumb title for a blog post, but this is just a little love for WPF and its ability to completely restyle a standard control.&lt;/p&gt;  &lt;p&gt;In our most recent project, we have a list of groups of pigs that we show the user so they can choose one to work with. The groups might be male, female, castrates or mixed, and we need to let the user filter the list by sex so that there’s not as many to choose from.&lt;/p&gt;  &lt;p&gt;We ended up using RadioButtons, one for each sex. As an example, here’s the XAML for the “Females” option:&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;RadioButton &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;2&amp;quot; 
                 &lt;/span&gt;&lt;span style="color: red"&gt;Tag&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Static &lt;/span&gt;&lt;span style="color: red"&gt;qfp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;ProgenySex&lt;/span&gt;&lt;span style="color: blue"&gt;.Female}&amp;quot;
                 &lt;/span&gt;&lt;span style="color: red"&gt;ToolTip&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Show only female groups&amp;quot;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Label&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;_Females&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Label&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;RadioButton&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;However, we knew that the filtering options in the finished product shouldn’t &lt;em&gt;look&lt;/em&gt; like radio buttons. In fact, the effect I wanted was closer to the FlatButtons appearance on the TabControl in Windows Forms:&lt;/p&gt;

&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/WPFKilledtheRadioButtonStar_ABF6/image_3.png" width="300" height="146" /&gt; &lt;/p&gt;

&lt;p&gt;In the end, with a little bit of XAML templating, I was able to achieve exactly the look I wanted. It’s even better than the TabControl! Here’s a screenshot:&lt;/p&gt;

&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/WPFKilledtheRadioButtonStar_ABF6/image_6.png" width="340" height="147" /&gt; &lt;/p&gt;

&lt;p&gt;So the “buttons” at the top of the list are actually RadioButtons (using the XAML above), and in this screenshot the user has selected “Females”. Below is a part of the XAML we used to restyle the radio buttons (I’ve omitted the icon setters etc). It just goes to show how powerful WPF is!&lt;/p&gt;

&lt;pre class="code"&gt;&lt;p&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;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Type &lt;/span&gt;&lt;span style="color: red"&gt;RadioButton&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;EventSetter &lt;/span&gt;&lt;span style="color: red"&gt;Event&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ToggleButton.Checked&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Handler&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;SetProgenySexFilter&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;Focusable&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;GroupName&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;filter&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;IsTabStop&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;Template&amp;quot;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ControlTemplate &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Type &lt;/span&gt;&lt;span style="color: red"&gt;RadioButton&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ControlTemplate.Resources&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: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Type &lt;/span&gt;&lt;span style="color: red"&gt;Image&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;Height&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;16&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;Width&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;16&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;VerticalAlignment&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Center&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;Margin&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0,0,2,0&amp;quot; /&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;

                        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Type &lt;/span&gt;&lt;span style="color: red"&gt;TextBlock&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;VerticalAlignment&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Center&amp;quot;/&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;

                        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Type &lt;/span&gt;&lt;span style="color: red"&gt;Label&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;Padding&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;/&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;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ControlTemplate.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Border
                        &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;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;PART_border&amp;quot; 
                        &lt;/span&gt;&lt;span style="color: red"&gt;CornerRadius&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;2&amp;quot; 
                        &lt;/span&gt;&lt;span style="color: red"&gt;Padding&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;3px&amp;quot; 
                        &lt;/span&gt;&lt;span style="color: red"&gt;Margin&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;2px&amp;quot; 
                        &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Transparent&amp;quot; 
                        &lt;/span&gt;&lt;span style="color: red"&gt;BorderThickness&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;1&amp;quot; 
                        &lt;/span&gt;&lt;span style="color: red"&gt;BorderBrush&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Static &lt;/span&gt;&lt;span style="color: red"&gt;SystemColors&lt;/span&gt;&lt;span style="color: blue"&gt;.&lt;/span&gt;&lt;span style="color: red"&gt;ControlDarkBrush&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;
                        &lt;/span&gt;&lt;span style="color: red"&gt;SnapsToDevicePixels&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;StackPanel &lt;/span&gt;&lt;span style="color: red"&gt;Orientation&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Horizontal&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Center&amp;quot;&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Image &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;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;PART_icon&amp;quot; /&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ContentPresenter &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;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;PART_content&amp;quot; /&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Border&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ControlTemplate.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;IsChecked&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;TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;PART_content&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;TextBlock.FontWeight&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Bold&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;TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;PART_border&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Background&amp;quot;&amp;gt;
                                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0,0&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0,1&amp;quot;&amp;gt;
                                        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Static &lt;/span&gt;&lt;span style="color: red"&gt;SystemColors&lt;/span&gt;&lt;span style="color: blue"&gt;.&lt;/span&gt;&lt;span style="color: red"&gt;ControlLightColor&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;                                                      &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;/&amp;gt;
                                        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Static &lt;/span&gt;&lt;span style="color: red"&gt;SystemColors&lt;/span&gt;&lt;span style="color: blue"&gt;.&lt;/span&gt;&lt;span style="color: red"&gt;ControlColor&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: blue"&gt;                                                      &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;1&amp;quot;/&amp;gt;
                                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&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;
&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;</description><feedburner:origLink>http://www.madprops.org/blog/wpf-killed-the-radiobutton-star/</feedburner:origLink></item><item><title>Windows 7 Doubles My RAM (Sort Of)</title><link>http://feedproxy.google.com/~r/mabster/~3/4391SFPiun0/</link><pubDate>Mon, 18 May 2009 09:14:01 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/windows-7-doubles-my-ram-sort-of/</guid><dc:creator>mabster</dc:creator><slash:comments>2</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;Here’s a strange little quirk I discovered after installing the Windows 7 Release Candidate on my old home PC (whose original specs you can see &lt;a href="http://www.madprops.org/blog/my-new-pc"&gt;here&lt;/a&gt;):&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Installed memory (RAM): 2.00 GB (1.00 GB usable)" border="0" alt="Installed memory (RAM): 2.00 GB (1.00 GB usable)" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/Windows7DoublesMyRAMSortOf_10E86/image_3.png" width="452" height="157" /&gt; &lt;/p&gt;  &lt;p&gt;Now, I have this PC open, and I can guarantee that there’s only 1GB of RAM installed. I don’t have anything else plugged in that would account for the “2.00 GB” that’s being reported.&lt;/p&gt;  &lt;p&gt;I’ve read others on the net complaining that Windows 7 reports that it’s only using a subset of their installed RAM, but this is reporting that it’s using all of the installed RAM, and letting me know that in some alternate reality (perhaps a future date?) I will actually have a whole ’nother gigabyte to use!&lt;/p&gt;  &lt;p&gt;So there you go – Windows 7 is so powerful it can actually see RAM from alternate timelines. Perhaps Windows 8 will be able to use it!&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/windows-7-doubles-my-ram-sort-of/</feedburner:origLink></item><item><title>Windows 7 Logo and the Windows Flag</title><link>http://feedproxy.google.com/~r/mabster/~3/O7rne42nyes/</link><pubDate>Wed, 13 May 2009 05:44:50 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/windows-7-logo-and-the-windows-flag/</guid><dc:creator>mabster</dc:creator><slash:comments>7</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;Did you know that the new “7” logo is actually the top-right corner of the “Windows flag”? Check out this image:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.madprops.org/files/media/image/WindowsLiveWriter/Windows7LogoandtheWindowsFlag_DD6D/image_3.png" width="199" height="170" /&gt; &lt;/p&gt;  &lt;p&gt;I’ve superimposed the “7” from &lt;a href="http://www.windowslounge.net/"&gt;this site&lt;/a&gt; (after rotating it counter-clockwise slightly) onto a Windows Flag image I found in a Google Search. I’m sure I’m not the first to realise this, but I thought it was worth posting the combined image.&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/windows-7-logo-and-the-windows-flag/</feedburner:origLink></item><item><title>Comicster, ComicVine, WCF and REST APIs</title><link>http://feedproxy.google.com/~r/mabster/~3/dcZi9OxilL0/</link><pubDate>Mon, 11 May 2009 22:54:00 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/comicster-comicvine-wcf-and-rest-apis/</guid><dc:creator>mabster</dc:creator><slash:comments>0</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;I&amp;rsquo;m a little late to the party, but &lt;a href="http://api.comicvine.com/"&gt;ComicVine have released an API&lt;/a&gt; for their online database of comics, characters, publishers, creators etc. It&amp;rsquo;s a fairly comprehensive REST API that lets you pull down details for just about anything in XML format. For example, to search for any character with &amp;ldquo;silver&amp;rdquo; in their name, you&amp;rsquo;d visit a URL like this (with your own API key):&lt;/p&gt;
&lt;p&gt;&lt;a title="http://api.comicvine.com/search/?api_key=..&amp;amp;resources=character&amp;amp;query=silver" href="http://api.comicvine.com/search/?api_key=..&amp;amp;resources=character&amp;amp;query=silver"&gt;http://api.comicvine.com/search/?api_key=&amp;hellip;&amp;amp;resources=character&amp;amp;query=silver&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I definitely want to build this into my next version of &lt;a href="http://comicster.net/"&gt;Comicster&lt;/a&gt;, and I want to do so in such a way that the user will be able to choose which online database they pull their information from (or upload to, if the database they select supports it).&lt;/p&gt;
&lt;p&gt;My first thought when I saw the way this worked was that I&amp;rsquo;d need to use &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx"&gt;System.Net.WebClient&lt;/a&gt; to pull down the results, and then parse the XML somehow. Then I remembered a blog post from NathanA that I&amp;rsquo;d bookmarked on del.icio.us a while ago: &lt;a href="http://blogs.msdn.com/nathana/archive/2007/09/13/wcf-web-programming-or-how-i-learned-to-stop-worrying-and-love-uri-templates.aspx"&gt;WCF Web Programming or: How I Learned to Stop Worrying and Love Uri Templates&lt;/a&gt;. This post outlines a &lt;em&gt;very&lt;/em&gt; cool way to access REST APIs using WCF, with the Flickr API as an example.&lt;/p&gt;
&lt;p&gt;So here&amp;rsquo;s how I&amp;rsquo;ve started my ComicVine WCF client. First, an interface that gives me access to some of the more common search functions:&lt;/p&gt;
&lt;pre class="code"&gt;
[&lt;span style="color: #2b91af"&gt;ServiceContract&lt;/span&gt;]
&lt;span style="color: blue"&gt;internal interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IComicVineApi
&lt;/span&gt;{
    [&lt;span style="color: #2b91af"&gt;WebGet&lt;/span&gt;(UriTemplate = &lt;span style="color: #a31515"&gt;&amp;quot;search/?api_key={key}&amp;amp;resources=character&amp;amp;query={query}&amp;amp;field_list=id,name,aliases,deck,image&amp;quot;&lt;/span&gt;)]
    [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]
    &lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;FindCharacters(&lt;span style="color: blue"&gt;string &lt;/span&gt;key, &lt;span style="color: blue"&gt;string &lt;/span&gt;query);

    [&lt;span style="color: #2b91af"&gt;WebGet&lt;/span&gt;(UriTemplate = &lt;span style="color: #a31515"&gt;&amp;quot;search/?api_key={key}&amp;amp;resources=person&amp;amp;query={query}&amp;amp;field_list=id,name,aliases,deck,image,site_detail_url&amp;quot;&lt;/span&gt;)]
    [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]
    &lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;FindCreators(&lt;span style="color: blue"&gt;string &lt;/span&gt;key, &lt;span style="color: blue"&gt;string &lt;/span&gt;query);

    [&lt;span style="color: #2b91af"&gt;WebGet&lt;/span&gt;(UriTemplate = &lt;span style="color: #a31515"&gt;&amp;quot;search/?api_key={key}&amp;amp;resources=publisher&amp;amp;query={query}&amp;amp;field_list=id,name,deck,site_detail_url&amp;quot;&lt;/span&gt;)]
    [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]
    &lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;FindPublishers(&lt;span style="color: blue"&gt;string &lt;/span&gt;key, &lt;span style="color: blue"&gt;string &lt;/span&gt;query);

    [&lt;span style="color: #2b91af"&gt;WebGet&lt;/span&gt;(UriTemplate = &lt;span style="color: #a31515"&gt;&amp;quot;search/?api_key={key}&amp;amp;resources=volume&amp;amp;query={query}&amp;amp;field_list=id,name,description,image,start_year&amp;quot;&lt;/span&gt;)]
    [&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]
    &lt;span style="color: #2b91af"&gt;XElement &lt;/span&gt;FindTitles(&lt;span style="color: blue"&gt;string &lt;/span&gt;key, &lt;span style="color: blue"&gt;string &lt;/span&gt;query);
}&lt;/pre&gt;
&lt;p&gt;As you can see, we simply map the parameters of each method to parameters in the corresponding URL. Each method returns an XElement which I can easily parse using Linq to XML.&lt;/p&gt;
&lt;p&gt;To use this interface we spin it up using WCF, like this:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;IComicVineApi &lt;/span&gt;_channel = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;WebChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;IComicVineApi&lt;/span&gt;&amp;gt;(
    &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;http://api.comicvine.com&amp;quot;&lt;/span&gt;)).CreateChannel();&lt;/pre&gt;
&lt;p&gt;Pretty neat, huh? We just pass the base URL into a &lt;a href="http://msdn.microsoft.com/en-us/library/bb908674.aspx"&gt;WebChannelFactory&lt;/a&gt; and call the CreateChannel method to get an implementation of the interface!&lt;/p&gt;
&lt;p&gt;All that&amp;rsquo;s left, then, is to provide a way to search for characters and return them as proper Comicster.Character objects:&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Character&lt;/span&gt;&amp;gt; FindCharacters(&lt;span style="color: blue"&gt;string &lt;/span&gt;query)
{
    &lt;span style="color: blue"&gt;return from &lt;/span&gt;x &lt;span style="color: blue"&gt;in &lt;/span&gt;_channel.FindCharacters(key, query).Elements(&lt;span style="color: #a31515"&gt;&amp;quot;results&amp;quot;&lt;/span&gt;).Elements(&lt;span style="color: #a31515"&gt;&amp;quot;character&amp;quot;&lt;/span&gt;)
           &lt;span style="color: blue"&gt;let &lt;/span&gt;icon = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)x.Element(&lt;span style="color: #a31515"&gt;&amp;quot;image&amp;quot;&lt;/span&gt;).Element(&lt;span style="color: #a31515"&gt;&amp;quot;icon_url&amp;quot;&lt;/span&gt;)
           &lt;span style="color: blue"&gt;select new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Character
           &lt;/span&gt;{
               Name = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)x.Element(&lt;span style="color: #a31515"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;),
               Details = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)x.Element(&lt;span style="color: #a31515"&gt;&amp;quot;deck&amp;quot;&lt;/span&gt;),
               OnlineId = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)x.Element(&lt;span style="color: #a31515"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;),
               Aliases = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)x.Element(&lt;span style="color: #a31515"&gt;&amp;quot;aliases&amp;quot;&lt;/span&gt;),
               Image = icon == &lt;span style="color: blue"&gt;null &lt;/span&gt;? &lt;span style="color: blue"&gt;null &lt;/span&gt;: &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;(icon),
           };
}&lt;/pre&gt;
&lt;p&gt;As you see, it&amp;rsquo;s a simple Linq to XML query that walks over the returned XElement and instantiates a character for each search result. This particular query does some funky stuff with the &amp;ldquo;let&amp;rdquo; keyword so I can &amp;ldquo;drill into&amp;rdquo; the &amp;lt;image&amp;gt;&amp;lt;icon_url&amp;gt; nested elements and pull out an image URL or leave it null if neither XML tag is present.&lt;/p&gt;
&lt;p&gt;No doubt it&amp;rsquo;ll be a while before I get everything working the way I want (particularly making the online functionality extensible via &lt;a href="http://mef.codeplex.com/"&gt;MEF&lt;/a&gt;), but this is a good first step. Kudos to the ComicVine guys for making their data available in such a flexible way!&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/comicster-comicvine-wcf-and-rest-apis/</feedburner:origLink></item><item><title>Windows 7’s XP Mode Considered Harmful</title><link>http://feedproxy.google.com/~r/mabster/~3/hc5wsFmoj_0/</link><pubDate>Tue, 05 May 2009 04:42:46 GMT</pubDate><guid isPermaLink="false">http://www.madprops.org/blog/windows-7-rsquo-s-xp-mode-considered-harmful/</guid><dc:creator>mabster</dc:creator><slash:comments>2</slash:comments><category domain="http://www.madprops.org/blog/">Blog</category><description>&lt;p&gt;In the news recently was the new “XP Mode” feature of Windows 7. You can read &lt;a href="http://www.codinghorror.com/blog/archives/001258.html"&gt;Jeff Atwood’s rundown of it here&lt;/a&gt;, and &lt;a href="http://www.winsupersite.com/win7/xp_mode_preview.asp"&gt;Paul Thurrot’s preview of it here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Essentially, XP Mode is an instance of Virtual PC that runs applications in their own little Windows XP environment, but does so in such a way that they look like they’re running on your normal Windows 7 desktop. It’s all very funky, and reminiscent of OS/2 Warp’s “seamless” support for Windows 3.x applications.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.winsupersite.com/images/win7/vxp_17.jpg"&gt;&lt;img style="margin: 0px 10px 0px 0px; display: inline" title="Windows 7 XP Mode" alt="Windows 7 XP Mode" align="left" src="http://www.winsupersite.com/images/win7/vxp_17.jpg" width="240" height="186" /&gt;&lt;/a&gt;It wasn’t until I had read the Coding Horror post that I realised why this is important. After all, Windows 7 can run any old application – even DOS applications. Why would I need a full-blown VM just to run Windows XP applications? The truth is that this feature will become much more important in future versions of Windows. It’s no secret that Windows is embarrassingly backwards-compatible, but having to keep all that cruft around so that 16-bit applications can still run doesn’t do it any favours. XP Mode is the beginning of the end for native backwards-compatibility. Some future version of Windows could drop support for old applications altogether, but as long as it could run a virtual machine you’d still be able to fire up Comicster and add that latest issue of Fantastic Four.&lt;/p&gt;  &lt;p&gt;Having said all that, I’m not sure XP Mode is good news. It’s great that the feature exists, and it opens up a whole new world of Windows versions free of the shackles of backwards-compatibility, but here’s the rub: &lt;em&gt;People read about XP Mode and immediately assume that it’s there because Windows 7 won’t run their Windows XP applications without it.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;It’s true! I’ve already spoken to a few people who have read about XP Mode on the web and, while technical enough to know what Windows 7 is, aren’t technical enough to grasp the reasons behind the existence of the feature. Heck – like I said, I didn’t even fully grasp them before reading that blog post.&lt;/p&gt;  &lt;p&gt;What do you think? Should Microsoft have kept quiet on XP Mode, except for maybe a mention on an MSDN or TechNet page somewhere? Do you think it’s damaging to Windows 7’s compatibility reputation?&lt;/p&gt;</description><feedburner:origLink>http://www.madprops.org/blog/windows-7-rsquo-s-xp-mode-considered-harmful/</feedburner:origLink></item></channel></rss>
