<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Wilcox &#187; Software Development</title>
	<atom:link href="http://www.jeff.wilcox.name/topics/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeff.wilcox.name</link>
	<description>Silverlight, rich client apps and web development</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:42:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Displaying static maps on the Windows Phone for performance and scenario wins</title>
		<link>http://www.jeff.wilcox.name/2012/01/jeffwilcox-maps/</link>
		<comments>http://www.jeff.wilcox.name/2012/01/jeffwilcox-maps/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 00:36:45 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Control Development]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=903</guid>
		<description><![CDATA[One of the nice visuals of 4th &#38; Mayor is the animation and display of a simple area map whenever you view a place in the app. Unfortunately, most map controls, such as the Bing Maps control included with the platform, are highly sophisticated: they let you have a bunch of pushpins, gather information about [...]]]></description>
			<content:encoded><![CDATA[<p>One of the nice visuals of 4th &amp; Mayor is the animation and display of a simple area map whenever you view a place in the app.</p>
<p>Unfortunately, most map controls, such as the Bing Maps control included with the platform, are highly sophisticated: they let you have a bunch of pushpins, gather information about bounding boxes, etc. This awesome feature set can have a negative effect on performance.</p>
<blockquote><p>2/1/2012 Update: Thanks to <a href="http://timheuer.com/blog/">Tim Heuer</a>, who just provided a pull request that adds an OpenStreetMap provider, MapQuest provider, offers the ability to add an authentication key optionally as a property on the control, and to specify the type of maps. I’ve updated NuGet to 1.1 with these contributions, thanks!</p>
</blockquote>
<p>My static map control is simple but nice because it’s an easy replacement, can be used in Panorama/Pivots, and overall still has a great, high-speed experience that your users will enjoy.</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/SampleMap.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SampleMap" border="0" alt="SampleMap" src="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/SampleMap_thumb.png" width="341" height="346" /></a>     <br /><em>A sample static Bing Map from 4th &amp; Mayor: touching the map takes you to an interactive map view page allow for directions, panning, etc.</em></p>
<h3>“JeffWilcox.Maps” Component</h3>
<p>I’ve refactored one of the libraries used in my app to be general enough for others to use: it offers simple static map code in the form of a “StaticMap” control: just drop it into your XAML page and you’re mostly good to go.</p>
<p>The <strong>MapCenter</strong> property takes a GeoCoordinate, either data bind it or set the property as the page is navigated to.</p>
<p>Over time I’ll consider adding more of the functionality I’ve had to the library, including the interactive libraries.</p>
<h3>Get the library</h3>
<p>I’m using my favorite pair of deployment places for this library: GitHub for source, NuGet for binaries.</p>
<h4>NuGet</h4>
<p>The library is <a href="http://nuget.org/packages/JeffWilcox.Maps">JeffWilcox.Maps</a></p>
<h4>Source on GitHub</h4>
<p>Fork the repo, <a href="https://github.com/jeffwilcox/wp-maps">wp-maps</a></p>
<h3>Offering an interactive experience</h3>
<p>To optimize the maps experience, I instead decided to use the static map REST APIs from Bing Maps for my mobile application: this lets me perform a HTTP request, grab the image, and data bind it into my display.</p>
<p>I then place it inside a borderless, retemplated Button control, so that touching the map takes you to a new page: an experience where I can show the real Bing Maps control, your current position, as well as the location of the place you are trying to go. By moving this to a separate assembly, I get great performance wins: the Bing Maps control and other code needed to offer the rich interactive experience is delay loaded and only there when needed.</p>
<h3>Properties on the control</h3>
<p>These properties are on the initial version of the control:</p>
<p><strong>Foreground</strong> is supported and used for the implicit, centered point: it’s Black by default to match the Windows Phone’s “Maps” app, but I find that using {StaticResource PhoneAccentBrush} looks great in my opinion.</p>
<p><strong>MapCenter</strong> takes a GeoCoordinate, this is a key property.</p>
<p><strong>ZoomLevel</strong> sets the zoom level (default of 15 I think) for the map. 1 effectively shows a bunch of the world, and 21 shows street level sizes. The zoom levels for Goog and Bing are pretty similar.</p>
<p><strong>MapCenterVisibility</strong> defaults to Visible, and if you decide you don’t want the center point to be on the view, just set this to Collapsed.</p>
<p><strong>IsSensorCoordinate</strong> should be data bound, some APIs (like Google’s) require that the API call identify whether it’s a position from a sensor, or a database. In my case, sensor is used for any GeoCoordinateWatcher/LocationService code, while I set it to False for data from the Foursquare venues database where I get info about a place.</p>
<p><strong>Provider</strong> sets the static map provider to use.</p>
<p>The height and width are automatically identified by the system, but many APIs limit the width and height to small numbers (typically &lt;= 640 pixels in any direction), FYI.</p>
<h3>Bing Maps API Key</h3>
<p>If you’re using Bing Maps, you’ll need a <a href="http://www.microsoft.com/maps/developers/web.aspx">Bing Maps API key</a> and to make sure that your app is compliant with the requirements of its terms and conditions. This is the same key you use with the Bing Maps control.</p>
<p>For this first version you have to set the API key as a string resource inside your App.xaml file.</p>
<p>Here’s how you would go about this: add the namespace and set the string – I’ve put a comment where your key should go in App.xaml:</p>
<pre class="xml" name="code">&lt;Application
    x:Class=&quot;StaticMapSample.App&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:phone=&quot;clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone&quot;
    xmlns:shell=&quot;clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone&quot;
    xmlns:core=&quot;clr-namespace:System;assembly=mscorlib&quot;&gt;

    &lt;!--Application Resources--&gt;
    &lt;Application.Resources&gt;
        &lt;core:String x:Key=&quot;BingMapsKey&quot;&gt;&lt;!-- Place your Bing Maps API key here--&gt;&lt;/core:String&gt;
    &lt;/Application.Resources&gt;

    &lt;Application.ApplicationLifetimeObjects&gt;
        &lt;!--Required object that handles lifetime events for the application--&gt;
        &lt;shell:PhoneApplicationService
            Launching=&quot;Application_Launching&quot; Closing=&quot;Application_Closing&quot;
            Activated=&quot;Application_Activated&quot; Deactivated=&quot;Application_Deactivated&quot;/&gt;
    &lt;/Application.ApplicationLifetimeObjects&gt;

&lt;/Application&gt;</pre>
<p>I haven’t decided if this is better or worse than just exposing an API key property for you to bind or set on the page, but I really like just having one central place in an app to put the key.</p>
<h3>Static map providers</h3>
<p>The initial implementation has a simple enum for chosing between two provider choices, Bing Maps and Google Maps. I’ve decided to include Google Maps because it turns out that in some parts of the world, Google Maps are much better, and I’ve had hundreds of app users ask for a setting to instead use Google Maps. There are slightly different requirements for its API, such as exposing an “open in web browser” function so that the user could decide to open the same map view in the browser on the phone.</p>
<p>Just set the <strong>Provider</strong> property on the StaticMap to either Bing or Google. The default is Bing, as it should be!</p>
<p>Here’s a screenshot of the sample app I’ve included in the GitHub repo (though if you use it, remember to put your Bing Maps API key inside of the App.xaml file first!) – it has both Bing and Google Maps, and the application bar is hooked up to events to open the Maps app on the phone <em>or</em> to open the browser with the appropriate map page. Take a look.</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/SampleApp.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SampleApp" border="0" alt="SampleApp" src="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/SampleApp_thumb.png" width="680" height="567" /></a></p>
<p><em>On the right, the expanded app bar: your app may need to expose the “open in browser” option to comply with the terms and conditions that you interpret on the maps API of your choice. Also, the “open in maps app” is a nice function to provide users who want to open the location in the main OS’s Maps app.</em></p>
<h3>Design note: flush maps</h3>
<p>One design technique that I use in my app, as does the “Local Scout” app in Mango, is having a “flush” map experience: the map extends to the edge of the phone, instead of the standard spacing with margins from the edges of the phone.</p>
<p>This visual effect looks great, and can in general be created by setting the Margin of the control to “-12,0,-12,0”.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2012/01/jeffwilcox-maps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Phone apps, built out of &#8220;the 3 P&#8217;s&#8221;: Panoramas, Pivots, and Pages</title>
		<link>http://www.jeff.wilcox.name/2012/01/windows-phone-apps-built-out-of-the-3-ps-panoramas-pivots-and-pages/</link>
		<comments>http://www.jeff.wilcox.name/2012/01/windows-phone-apps-built-out-of-the-3-ps-panoramas-pivots-and-pages/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 03:46:33 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=897</guid>
		<description><![CDATA[I can’t post a new component or library every day, but I can point you at other great blogs and folks on Twitter that would be super useful to app devs and teams building on the Microsoft stack. This afternoon I read another of Arturo Toledo’s amazing series on Windows Phone Design – and it’s [...]]]></description>
			<content:encoded><![CDATA[<p>I can’t post a new component or library every day, but I can point you at other great blogs and folks on Twitter that would be super useful to app devs and teams building on the Microsoft stack.</p>
<p>This afternoon I read another of Arturo Toledo’s amazing series on Windows Phone Design – and it’s a simple but important point: apps are <em>not</em> just a choice between a Page, a Panorama, or a Pivot: many apps have aspects of all of these. The Music+Videos hub on the phone is built of all 3, and your app can pull that off, too: just understand the ideal content and purposes of these different types of core experiences.</p>
<blockquote><p><font size="4"><a href="http://ux.artu.tv/?p=234">31 Weeks of Windows Phone Metro Design | #5 Choosing between Panoramas, Pivots and/or Pages</a>        <br /></font><a href="http://ux.artu.tv/">Arturo Toledo</a>      <br />Senior User Experience Designer – Windows Phone Team at Microsoft</p>
</blockquote>
<p><a href="http://ux.artu.tv/?p=234"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ScreenVSContentType" border="0" alt="ScreenVSContentType" src="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/ScreenVSContentType.png" width="339" height="210" /></a>    <br /><em>I “borrowed” this image <a href="http://ux.artu.tv/?p=234">from Arturo’s post</a>.</em></p>
<p>He’s had other great posts in the past, too, and expect great content to come.</p>
<p><strong>Do follow Arturo: </strong><a href="https://twitter.com/#!/arturot"><strong>@arturot</strong></a><strong>, </strong><a href="http://ux.artu.tv/"><strong>Blog here</strong></a>, <a href="http://ux.artu.tv/?feed=rss2">RSS</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2012/01/windows-phone-apps-built-out-of-the-3-ps-panoramas-pivots-and-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PhoneThemeManager: allow your app to have the Light, Dark, or Inverted theme with 1 line of code</title>
		<link>http://www.jeff.wilcox.name/2012/01/phonethememanager/</link>
		<comments>http://www.jeff.wilcox.name/2012/01/phonethememanager/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 03:43:08 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=890</guid>
		<description><![CDATA[Set your Windows Phone Mango app to have the Light, Dark, or inverted theme with just one line of code and this helper library, PhoneThemeManager.]]></description>
			<content:encoded><![CDATA[<p>I’ve just pushed a small library that I created this evening to the world and wanted to share details on the short project in this post. (<a href="http://nuget.org/packages/PhoneThemeManager">NuGet assembly</a>, <a href="http://nuget.org/packages/PhoneThemeManager.Source">NuGet source</a>, <a href="https://github.com/jeffwilcox/wp-thememanager">project on GitHub</a>)</p>
<p>One of the most common feature requests that I receive for 4th &amp; Mayor is a setting in the app to force it to always use the “Light” theme, overriding the dark/light theme that the user’s set for their theme.</p>
<p>Having a light background is a nice contrasting design look for the phone, and the Mail application always does this. I personally always submit mostly light theme screen shots for my applications to the Windows Phone Marketplace, it just looks better and nice to me – but I rarely use all-light themed apps other than Mail.</p>
<p><img src="http://d2bk44826ux9xe.cloudfront.net/NewMenus.png" /></p>
<p>In preparing for the next update of my app, v3.3, I’ve coded up this capability and I’m sharing it ahead of time.</p>
<h3>Technical Overview</h3>
<p>In 7.0 there were a few ways to do theme overriding, sometimes through a few silly platform bugs that we left in there – but it’s actually not an easy thing to do, and many people end up overriding every single style in their app to get the effect that they are going for.</p>
<p>This helper library is designed for altering the entire application’s running instance, <em>not</em> for providing per-page theme overriding.</p>
<p>In researching possible ways to solve this, I did come across <a href="http://windowsphonegeek.com/articles/Windows-Phone-Mango-Custom-application-Theme-Step-by-Step">this page on windowsphonegeek</a> that talks about ways to merge in styles or to programmatically override resources that are brushes.</p>
<p>I decided to create a system to walk through the known values and names for all the core theme resources of colors, brushes, plus the light/dark theme visibility and opacity properties.</p>
<p>In your app, you simply call `ThemeManager.ToLightTheme()`, `ThemeManager.ToDarkTheme()`, `ThemeManager.InvertTheme`, to force this. You need to have this call happen inside your <strong>App.xaml.cs </strong>file, in the constructor, after the Initialize calls.</p>
<p>You cannot change or call this more than once, so if you offer a setting for users to “Force Light”, use a MessageBox to inform them that their setting will be used the next time they start the app. You will have to read their setting right away when they start up the app. Once styles start applying the values, you could start to get inconsistent results.</p>
<p>The code walks and updates the Color instances, then walks the Brush resources and sets their Colors to be the original Color instances, just in case.</p>
<p>I have placed the ThemeManager class within the Microsoft.Phone.Controls namespace for this to be easy to add to your App.xaml.cs file.</p>
<p>You should have an App constructor like this:</p>
<pre class="csharp" name="code">/// &lt;summary&gt;
/// Constructor for the Application object.
/// &lt;/summary&gt;
public App()
{
    // Global handler for uncaught exceptions.
    UnhandledException += Application_UnhandledException;

    // Standard Silverlight initialization
    InitializeComponent();

    // Phone-specific initialization
    InitializePhoneApplication();

    ThemeManager.ToLightTheme();

    // Other code that might be here already...
}</pre>
<h3>What’s themed</h3>
<p>By default this is what happens:</p>
<ul>
<li>The <strong>resources</strong> for foreground, background, all the contrast/chrome/etc. colors and brushes are updated</li>
<li>The light and dark theme visibility and opacity resources are updated</li>
<li>The background brush of the Frame is set explicitly to the color (may have a negative performance impact!)</li>
<li>The <strong>System Tray </strong>whenever a page navigation completes</li>
<li>The <strong>ApplicationBar</strong> of a page if set immediately</li>
</ul>
<p>I’ve added a simple OverrideOptions enum (static) to the ThemeManager that can be used to disable the auto-behaviors I’ve added.</p>
<h4>Newing up AppBars</h4>
<p>If you have code in your app like “var ab = new ApplicationBar”, beware that that application bar will take on the system’s actual theme colors by default, and not the overridden light/dark coloring that happens with the app.</p>
<p>If you need to new up an ApplicationBar, you should use the convenience method of `ThemeManager.CreateApplicationBar()` <em>or</em> use the extension method on app bar that I added, `MatchOverriddenTheme`, to set the color values.</p>
<h3>What’s not themed</h3>
<p>Unfortunately this cannot theme <strong>MessageBox</strong> at all.</p>
<h3>Talking about fill rate performance</h3>
<p>I’ve designed the system so that resources are <em>only overridden when needed</em>.</p>
<p>If your app uses ToLightTheme to force the light theme, and the user is running the Light theme already, nothing happens – it’s a no-op.</p>
<p>Although updating resources has no negative effect really on the app’s performance, the trouble is setting the Background color of the phone application’s frame.</p>
<p>The frame is always present and may add a fill count of 1.0 to every single page in your app.</p>
<p>Anything above a fill rate of 2-3 is not a good thing, so you may notice a degraded experience. Might want to inform your users of that when providing the option to force the light theme, for example.</p>
<h3>A note about your battery</h3>
<p>Many Windows Phones use AMOLED or similar technology where bright colors, such as the background color used in the Light theme, will use a lot of power. Please respect your users and realize that long-running apps probably should not force the Light option.</p>
<p>Consider only making such a “Force Light Theme” option as a setting that users opt-in to, as opposed to always overriding the theme.</p>
<h3>About custom themes</h3>
<p>When I designed this library, I thought about offering a ton of capability in it for using “branding” colors, modifying the accent brush, etc., but instead decided to tackle just one thing. So the name ThemeManager is a little overkill maybe, but it’s where we are for now.</p>
<h2>Get the bits</h2>
<p><strong>NuGet Binary</strong></p>
<p>The binary is super easy to use. With NuGet just add the <a href="http://nuget.org/packages/PhoneThemeManager">PhoneThemeManager</a> package reference.</p>
<p><strong>NuGet Source File</strong></p>
<p>Instead of adding yet another assembly to your project, just add the single source file (or add it to your existing shared library, etc.) by using the <a href="http://nuget.org/packages/PhoneThemeManager.Source">PhoneThemeManager.Source</a> package.</p>
<p><strong>GitHub Repo</strong></p>
<p>Fork and enjoy <a href="https://github.com/jeffwilcox/wp-thememanager">https://github.com/jeffwilcox/wp-thememanager</a></p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2012/01/phonethememanager/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Please ship your next Windows Phone app with GZip: speed requests 50-80%</title>
		<link>http://www.jeff.wilcox.name/2012/01/windows-phone-gzip-support-by-morten/</link>
		<comments>http://www.jeff.wilcox.name/2012/01/windows-phone-gzip-support-by-morten/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 01:04:23 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=887</guid>
		<description><![CDATA[Please ship your next Windows Phone app or app update using this awesome GZipWebClient library by Morten Nielsen (NuGet, blog post, source) – it’s been out there since August and we should all be using this now for HTTP-heavy apps! The next update of my app is in the works and performance is significantly improved [...]]]></description>
			<content:encoded><![CDATA[<p>Please ship your next Windows Phone app or app update using this awesome GZipWebClient library by Morten Nielsen (<a href="http://nuget.org/packages/SharpGIS.GZipWebClient">NuGet</a>, <a href="http://www.sharpgis.net/post/2011/08/28/GZIP-Compressed-Web-Requests-in-WP7-Take-2.aspx">blog post</a>, <a href="http://www.sharpgis.net/www.sharpgis.net/file.axd?file=2011%2f8%2fSharpGIS.GZipWebClient.zip">source</a>) – it’s been out there since August and we should all be using this now for HTTP-heavy apps!</p>
<p>The next update of my app is in the works and performance is significantly improved by this library. I used both generation 1 and gen 2 devices to gather a ton of data and am loving the results. Can’t wait to submit the update to the marketplace. I’ve been seeing requests speed up 50%-80%, it’s amazing – but I should note, these are unofficial numbers, I’m just grabbing these from my app that is JSON-heavy.</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="GZipChart" border="0" alt="GZipChart" src="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/GZipChart.png" width="680" height="310" /></p>
<p><em>Some sample data: a large set of averaged requests of a very large JSON request to the Foursquare web services used in my app, 4th &amp; Mayor for Windows Phone 7.5.</em></p>
<p>These numbers aren’t official or anything like that, just what I was observing using my 3G data connection here in Seattle or home WiFi. Also interesting are the fastest times for the content – I often found that once a data connection was open, I would get as low as 100ms for some GZip requests. Just amazing.</p>
<p>One of the awesome modern web server features that nearly every browser happily supports today is <a href="http://en.wikipedia.org/wiki/Gzip">Gzip</a> compression of its output. Text and JSON beautifully compress, often by more than half, resulting in quick content downloads. It’s a simple and awesome way to improve the performance and responsiveness of your applications.</p>
<p>This isn’t a new technology, but unfortunately it isn’t just a default, built-in option for you to use in your Windows Phone apps, and you can expect that competing apps on other platforms (and even on Windows Phone) will be using Gzip to improve the performance. Hopefully we fix this in the future.</p>
<p>Frankly it isn’t a default in most mobile platforms, either, and you need to opt-in. However, some, like iOS, seem to automatically deflate incoming streams as long as you opt-in by setting the content encoding headers; in an iOS app, you just addValue “gzip” forHTTPHeaderField before your request and you’re good from there. Android is similar but you do need to check for gzip in responses and manually new up a deflating stream with GZipInputStream.</p>
<h3>HTTP Gzip and Windows Phone apps</h3>
<p>So Morten Nielsen created a wrapping WebClient library over 6 months ago and through a few iterations has made it great.</p>
<p>So now it’s super easy to get this perf win. To make this work:</p>
<ul>
<li>Add the library to your project via <a href="http://nuget.org/packages/SharpGIS.GZipWebClient">NuGet</a> [SharpGIS.GZipWebClient]</li>
<li>Replace your WebClient code to use GZipWebClient instead – yes, just rename! (GZipWebClient is in Morten’s `SharpGIS` namespace)</li>
<li>Test and ship your app!</li>
</ul>
<p>Now I’m not considering the server-side, but if you’re rolling your own web services, you might need to do some work to make sure that you’ll serve GZip content when the capability is ready on the client. Check with the documentation for your server-side app platform, cloud provider or web server technology.</p>
<p>I can totally see myself adding this to my core libraries for all future projects. Hope this helps. <strong>Thanks Morten for providing this to the community!</strong> You can follow Morten on Twitter (<a href="https://twitter.com/#!/dotMorten">@dotMorten</a>) or check out his blog (<a href="http://www.sharpgis.net/">http://www.sharpgis.net/</a>).</p>
<p>(And on the performance side: the smaller payload means networking rocks and is fast; it is worth noting that GZip adds a small amount of CPU load – hopefully in your background thread – but I haven’t detected anything negative from this yet)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2012/01/windows-phone-gzip-support-by-morten/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>A quick look at MetroRadio: quick spacing, margin, and icon tips for Windows Phone devs</title>
		<link>http://www.jeff.wilcox.name/2012/01/metroradio-design/</link>
		<comments>http://www.jeff.wilcox.name/2012/01/metroradio-design/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 05:56:07 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2012/01/metroradio-design/</guid>
		<description><![CDATA[I’ve harped on this one a few times before in my Windows Phone Metro Design Guidelines post for devs. But it’s time for another helping! Metro Radio is a slick and functional Pandora application for the Windows Phone. Like many apps, there are plenty of small little UX things that could make it even better. [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve harped on this one a few times before in my <a href="http://www.jeff.wilcox.name/2011/03/metro-design-guide-v1/">Windows Phone Metro Design Guidelines</a> post for devs. But it’s time for another helping!</p>
<p><a href="http://www.windowsphone.com/en-US/apps/0caac4aa-962f-483b-9c26-76a3d8a1fd10">Metro Radio</a> is a slick and functional Pandora application for the Windows Phone. Like many apps, there are plenty of small little UX things that could make it even better. I saw the app recently and really like it, but as a stickler on design things, I’d love to make a few small tweaks if I could!</p>
<p>I briefly spoke with the application’s developer, Mustafa Taleb, and obtained his OK to me to write a little post just pointing out a few things. The app really does rock, but it’s also probably a place that in the next update a few visual blemishes could be fixed to yield an even better app.</p>
<p>So I’m going to point out simple things to think about when building out your UI. I have 9 points about simple spacing/design/margin things, and then a quick comment on the icon.</p>
<h2>Margin Issues and other easy XAML Fixes</h2>
<p>It’s pretty easy to overlook margins while developing applications. Between having controls like TextBlock that expect an associated Style, and most controls like Button that have an integrated margin and touch area, it&#160; can be tough to either notice OR spend the time to fine-tune these things.</p>
<p>I don’t have the source to the app, so I am going to be overlaying yellow lines on top of the marketplace screen shots to help show potential issues with margins.</p>
<h3>Text blocks: when to case plus the classic 12px left margin issue when not using styles</h3>
<p><img src="http://media.jeff.wilcox.name/blog/2012/AboutPage.png" /></p>
<p>So here we have a few basics.</p>
<p>1. Consider all uppercase for the small font app title (very top visual in a page’s default template), unless you have branding or other reasons for that change.</p>
<p>2. Consider all lowercase for the larger page title.</p>
<p>Now these two aren’t hard-and-fast. I’m inconsistent in my apps, too. But I believe that you should be consistent: if you choose one, choose both.</p>
<p>3. Use the PhoneTextNormalStyle or other provided textblock styles OR hard-code at least a 12px left margin for text blocks. That way you align with other default visuals.</p>
<p>In this screen capture I overlaid a yellow block over the 12px space – really all the text should be to the right of that block, not under.</p>
<p><img src="http://media.jeff.wilcox.name/blog/2012/LoginPage.png" /></p>
<p>Here’s a super classic login page experience. And actually it is affected by the same issue of not using Style={StaticResource PhoneTextNormalStyle} in those TextBlocks, I’m guessing.</p>
<p>4. 12px issues create jagged forms often.</p>
<p><strong>Recommended fix: </strong>Use the styles that are provided. The left of the text <em>and</em> the other controls should be aligned flush, not jagged like in this form.</p>
<p>Again this is because the default Margin of all TextBlocks is 0, but on the phone the styles set a left margin of 12px to allow for flush alignment.</p>
<h3>Looking into Pivot specifics</h3>
<p><img src="http://media.jeff.wilcox.name/blog/2012/SmallPivotThings.png" /></p>
<p>Now on this one, there are just a few simple things when using pivots.</p>
<p>5. Consider lowercase pivot item headers.</p>
<p>It’s consistent with what you’ll find throughout the official phone user interface. This can either be accomplished through hard-coding lowercase in your XAML, using a string converter that goes lowercase with binding, or by doing it on the model/data side of your app.</p>
<p>6. Everything in a Pivot control should usually align left flush.</p>
<p>This page seems to have the actual item content off by 12-to-24 pixels, instead of allowing all things on the left to be flush.</p>
<p>Additionally, the space between the Pivot header and item is off by maybe just 2- or 4- pixels.</p>
<h3>Look into spacing and alignment a lot on list pages</h3>
<p><img src="http://media.jeff.wilcox.name/blog/2012/SongsPage.png" /></p>
<p>This is one of the screen captures of the list results when searching for the text ‘today’, one of the marketplace example screen shots. It could use some alignment and cleanup and could probably be cleaned up in a good 10 minutes of XAML hacking</p>
<p>7. Visually check for alignment consistency.</p>
<p>I’ve drawn a yellow line to try and show that many items here are not aligned: images, group headers, the top search controls, etc. This could be fixed in Blend through some movements or just in XAML by slowly adjusting by 2-, 4-, 8-, however many pixels until things are nicely aligned.</p>
<p>8. Try spacing list items by the same value on the top and bottom.</p>
<p>It looks pretty inconsistent when a list item (like the first here) has 2- or 4- pixels on the top, but then what looks to be 18 pixels or so on the bottom.</p>
<p>Instead using a consistent value for the top and bottom will let all items look natural regardless of whether they are first or last.</p>
<p>9. Have space between items and text.</p>
<p>The data template for these results could use some spacing between the album art and the text.</p>
<p>My guess is that this is another example of hard-coding font values instead of using the standard PhoneTextLargeStyle or PhoneTextNormalStyle with a TextBlock. That would add a nice left margin of 12px back into the UI.</p>
<p>And another quick example, this is a list page from the app that has some of the same underlying potential spacing issues:</p>
<p><img src="http://media.jeff.wilcox.name/blog/2012/AnotherList.png" /></p>
<p>And now, the best page in the app!</p>
<p><img src="http://media.jeff.wilcox.name/blog/2012/PlaybackPage.png" /></p>
<p>This is the playback experience and page. It rocks. It’s smooth, visually awesome, has good information, and is styled on the in-app Music+Videos UI. If I had to nit-pic, I might want to put 6- or 12- pixels of margin spacing on top between the artist name and song title at the top, but it’s nice.</p>
<h2>Marketplace Application Tile</h2>
<p>When I looked up Metro Radio using the Web Marketplace, the icon was … hardly there. This might be on purpose, but it’s really not a great branding experience – my guess is this either is a take on, or based on, the regular app icon, which adjusts itself to the accent color of the phone (hence a transparent background color).</p>
<p>Trouble with using the same asset is that the Web Marketplace, the Zune Marketplace, and even in some situations the regular Marketplace app on the phone, don’t do the same replacement with accent colors – so you get a visually difficult to see tile.</p>
<h3>On-the-phone</h3>
<p>This looks great. It’s important to realize that the different asset sets and sizes are used in different places – whether web marketplace, app, etc., you should always try and submit your best icon forward if you can!</p>
<p><img src="http://media.jeff.wilcox.name/blog/2012/MetroRadioOnPhone.png" /></p>
<h3>Web Marketplace</h3>
<p><img src="http://media.jeff.wilcox.name/blog/2012/WebMarketplaceTile.png" /></p>
<p>Here you can see the hard-to-see tile for the app.</p>
<p><strong>Suggested Fix: </strong>Always use a background color (easy if you’re layering in Photoshop or a similar tool) for your actual marketplace submission’s tile.</p>
<h3>Zune Marketplace</h3>
<p><img src="http://media.jeff.wilcox.name/blog/2012/ZuneMR.png" /></p>
<p>Same icon issue here.</p>
<p>Hope this is useful. Thanks Mustafa for letting me write this post! And I should note, I’m publishing this without running it by him – he’s completely possible that some of these things were intentional design choices. If so, sorry if I have not agreed with them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2012/01/metroradio-design/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>A simple Windows Phone control for reading QR codes</title>
		<link>http://www.jeff.wilcox.name/2012/01/wpqr-control/</link>
		<comments>http://www.jeff.wilcox.name/2012/01/wpqr-control/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 00:05:09 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Control Development]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2012/01/wpqr-control/</guid>
		<description><![CDATA[A Windows Phone visual control that uses the camera to read a QR code.]]></description>
			<content:encoded><![CDATA[<p>There are great libraries out there written or ported to C# that let us developers rock by standing on the shoulders of giants. Here’s one such project.</p>
<p>A phone developer who’s also an enthusiast of foursquare suggested a feature that I should add in a future release, and provided some sample code based on the <a href="http://code.google.com/p/zxing/">zxing barcode library</a> and the <a href="http://silverlightzxing.codeplex.com/">Silverlight port of it</a>. I’m working on adding the new feature soon.</p>
<p>In the process I realized it would be a good and quick opportunity to ship such a simple but useful control to the phone development community, so I’ve gone ahead and pushed that control refactoring and implementation to GitHub, check it out: <a href="https://github.com/jeffwilcox/wpqr-control">https://github.com/jeffwilcox/wpqr-control</a>&#160;</p>
<p>Special thanks to Michael Osthege (<a href="http://twitter.com/theCake">@theCake</a>, <a href="http://kuchenzeit.wordpress.com/">blog</a>) for providing the initial contact, sample, and encouragement.</p>
<p>The control is nice:</p>
<ul>
<li>Drop it on the design surface</li>
<li>Wire up the ScanComplete event (and optionally the Error event)</li>
<li>The control handles all the underlying image manipulation, scanning work, PhotoCamera initialization, etc.</li>
</ul>
<p>Here’s what a simple sample app looks like in use. The control includes default border thickness and coloring properties that use the accent color and provide a nice visual separator:</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ReadingQR" border="0" alt="ReadingQR" src="http://www.jeff.wilcox.name/wp-content/uploads/2012/01/ReadingQR.jpg" width="685" height="514" /></p>
<p>Technically the control will expand to its container size, but I prefer the squared-off 400&#215;400 grid myself.</p>
<h3>Building the sample app</h3>
<p>All I did to build this app was drop the control into a new Windows Phone app project and wire it up. Here’s how.</p>
<h4>References and XMLNS</h4>
<p>Add either a project reference (if you cloned the git repo) <em>or</em> build the project and include references to assemblies, both the zxing library plus this control library.</p>
<p>To your XAML page where you’d like to use the control, make sure to include a namespace. Here’s what I used:</p>
<pre><font size="2" face="Consolas">xmlns:jwqr=&quot;clr-namespace:JeffWilcox.Controls;assembly=JeffWilcox.Controls.QR&quot;</font></pre>
<h4>Add the control</h4>
<p>I added this XAML to my MainPage’s ContentPanel area:</p>
<pre class="xml" name="code">&lt;jwqr:QRCodeScanner
    ScanComplete=&quot;QRCodeScanner_ScanComplete&quot;
    Error=&quot;QRCodeScanner_Error&quot;
    Width=&quot;400&quot;
    Height=&quot;400&quot;/&gt;</pre>
<h4>Implement code behind</h4>
<p>The event handlers are easy enough. In my case, I went for these (just throwing exceptions):</p>
<pre class="csharp" name="code">private void QRCodeScanner_ScanComplete(object sender, JeffWilcox.Controls.ScanCompleteEventArgs e)
{
    ApplicationTitle.Text = e.Result;
}

private void QRCodeScanner_Error(object sender, JeffWilcox.Controls.ScanFailureEventArgs e)
{
    throw e.Exception;
}</pre>
<h4>Run the project on a Windows Phone</h4>
<p>Hit F5! When you hover over a QR code, you should see its embedded text appear in place of the application title (top of the page).</p>
<h4>Future/Improvements</h4>
<p>I’d like to maybe add a sound when the scan is successful, but right now, nothing like that.</p>
<p>Eventually I may package this up as a NuGet package, but I’m not ready to prep the right spec files plus figure out how to properly attribute the sub-libraries at this time. So fork the <a href="https://github.com/jeffwilcox/wpqr-control">GitHub</a> version in the meantime! License is Apache 2.0 for both this library as well as the underlying zxing project.</p>
<p>(Looking to display codes? A few years back I briefly talked about the QR code system used by the sweet Starbucks mobile app on the iPhone. I implemented a prototype for Silverlight and Windows Phone that lets you render a QR code on the app’s surface, thanks to a nice QR code library. That <a href="http://www.jeff.wilcox.name/2010/03/windowsphone-barcode/">post is here</a>.)</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2012/01/wpqr-control/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>My new Windows Phone Emulator theme&#8211;simple and sleek</title>
		<link>http://www.jeff.wilcox.name/2011/12/my-new-windows-phone-emulator-theme/</link>
		<comments>http://www.jeff.wilcox.name/2011/12/my-new-windows-phone-emulator-theme/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 23:24:08 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/12/my-new-windows-phone-emulator-theme/</guid>
		<description><![CDATA[Back in April I shared my custom Windows Phone Emulator theme/skin files that made the emulator look like an AT&#38;T phone, the Samsung Focus. I recently realized that the newer Windows Phone Marketing resources on the MSDN site include a much nicer looking chassis mock-up, without branding, and thought I would move to start using [...]]]></description>
			<content:encoded><![CDATA[<p>Back in April I <a href="http://www.jeff.wilcox.name/2011/04/focus-theme/">shared my custom Windows Phone Emulator theme</a>/skin files that made the emulator look like an AT&amp;T phone, the Samsung Focus. I recently realized that the newer <a href="http://create.msdn.com/en-us/education/basics/marketing">Windows Phone Marketing resources on the MSDN site</a> include a much nicer looking chassis mock-up, without branding, and thought I would move to start using something based on it for my development work &amp; presentations that I give.</p>
<p>I’m sharing this with the community, I hope you enjoy! It makes the emulator look great I must say.</p>
<p><a href="http://media.jeff.wilcox.name/blog/MyMangoChassisEmulatorTheme.zip"><img src="http://media.jeff.wilcox.name/blog/MyMangoEmulator.jpg" /></a></p>
<h3>Download and install the theme</h3>
<ul>
<li><a href="http://media.jeff.wilcox.name/blog/MyMangoChassisEmulatorTheme.zip">Download a zip file of these these resources</a> (158 KB)</li>
<li>Ensure the emulator is closed</li>
<li>Locate the emulator directory – usually something like <font size="2" face="Consolas"><strong>C:\Program Files (x86)\Microsoft XDE\1.0\</strong></font></li>
<li>Backup the existing WM7_Skin.xml file if you may want to go back</li>
<li>Extract the files into the emulator directory – note that you will need administrative permissions to overwrite the files</li>
<li>Start up the emulator!</li>
</ul>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/12/my-new-windows-phone-emulator-theme/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>MPNS module for Node: A simple push notification helper for the cloud</title>
		<link>http://www.jeff.wilcox.name/2011/12/node-mpns/</link>
		<comments>http://www.jeff.wilcox.name/2011/12/node-mpns/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 05:01:06 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/12/node-mpns/</guid>
		<description><![CDATA[One of the fun projects I’ve been working on recently related to my app has been bringing online a cloud to handle sending push notifications processing. I’m using Node.js for this and have a ton of people enjoying the beta push experience right now: toasts, live tiles, etc. Tonight I pushed to GitHub ‘mpns’, a [...]]]></description>
			<content:encoded><![CDATA[<p>One of the fun projects I’ve been working on recently related to my app has been bringing online a cloud to handle sending push notifications processing. I’m using <a href="http://nodejs.org/">Node.js</a> for this and have a ton of people enjoying the beta push experience right now: toasts, live tiles, etc.</p>
<p>Tonight I pushed to GitHub ‘mpns’, a simple interface and helper to the Microsoft Push Notification Service (MPNS). It essentially takes the simple properties for your live tile update or toast, packages it in a simple XML payload, and then posts it to the subscription endpoint.</p>
<p>It isn’t a lot of code, but I sure hope it helps others who may be experimenting with other platforms while building a great push experience. If you’re using Azure, the Windows Phone team has already provided some awesome content here – <a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/01/14/windows-push-notification-server-side-helper-library.aspx">Yochay has previously posted</a> about a <a href="http://create.msdn.com/en-us/education/catalog/article/pnhelp-wp7">Windows Push Notification Server Side Helper Library</a>.</p>
<blockquote><p>This module is on NPM as &#8216;mpns&#8217; or you clone or submodule it from GitHub: <a href="https://github.com/jeffwilcox/mpns">https://github.com/jeffwilcox/mpns</a></p>
</blockquote>
<h4>Here’s some simple usage information that I’ve also posted to GitHub.</h4>
<h3>Load in the module</h3>
<pre class="js" name="code">var mpns = require('mpns');</pre>
<h3>Create a new notification</h3>
<p>You can create a new notification object (either of type live tile or toast). Raw notifications are not yet supported.</p>
<p>Property names for the notification object directly correlate to the names used in the MPNS XML payload as documented on MSDN. Properties can either be set directly on the object (such as toast.text1) or by passing the values in as options to the constructor.</p>
<pre class="js" name="code">options =   { text1: 'Hello!'
            , text2: 'Great to see you today.'
            };

var toast = new mpns.toast(options);</pre>
<h3>Sending a notification</h3>
<p>To send a notification simply call the <code>send</code> method on the object. The first parameter is the HTTP URI to the MPNS endpoint of the client you&#8217;d like to send the notification to. You may provide an optional callback function as well.</p>
<pre class="js" name="code">toast.send('http://sn1.notify.live.net/throttledthirdparty/01.00/YOUR_ENDPOINT_HERE');</pre>
<p>You can also use the other syntax. Let&#8217;s send a live tile update!</p>
<pre class="js" name="code">var toast = new mpns.liveTile();
toast.title: 'My App';
toast.backgroundUri: 'http://sample.com/image.png';
toast.send('http://sn1.notify.live.net/throttledthirdparty/01.00/YOUR_ENDPOINT_HERE', function(err,res) {
    if (err) console.dir(err);
    else console.dir(res);
});</pre>
<h3>Results object information</h3>
<p>A results object is passed back through the callback and has important information from MPNS.</p>
<ul>
<li><code>deviceConnectionStatus</code>: The device status as reported by the service. </li>
<li><code>notificationStatus</code>: The status of your provided notification. </li>
<li><code>subscriptionStatus</code>: The status of the subscription URI. </li>
</ul>
<p>The object will also contain all the key fields for your toast or live tile update, plus the pushType. This makes it easy to store this information in a history log somewhere in the ether.</p>
<h3>Handling Errors</h3>
<p>It is very important as a consumer that you store appropriate actionable data about failed push notification attempts. As a result, the callback&#8217;s first parameter (err) is set to the standard results object as well as a few additional fields depending on the returned status code from the server.</p>
<p>Remember to take action on that information in order to be a good MPNS citizen. These values may be set in the error object and of interest to you:</p>
<ul>
<li><code>minutesToDelay</code>: If this is present, it is the suggested minimum amount of time that you should wait until making another request to the same subscription URI. For HTTP 412s, for example, the minimum time is one hour and so the returned value defaults to 61. </li>
<li><code>shouldDeleteChannel</code>: If this is set to <code>true</code>, the channel is gone according to MPNS. Delete it from your channel/subscription database and never look back. </li>
<li><code>error</code>: If an error is captured while trying to make the HTTP request, this will be set to that error callback instance. </li>
</ul>
<h3>A note about Windows Phone 7.5</h3>
<p>This module permits sending toasts and tiles specific to Mango. If you include the <code>param</code> field when sending a push to a 7.0 (first Windows Phone release) phone, unfortunately it may not be received, or will error out the subscription.</p>
<p>Take care when registering your subscription channels with your cloud service to include the application platform version of the app (7.1 for Mango apps). To rock, maybe also grab the OS version and deployed app version. That information can be helpful when supporting customers.</p>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/12/node-mpns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>November release of the Silverlight for Windows Phone Toolkit</title>
		<link>http://www.jeff.wilcox.name/2011/11/nov2011phonetoolkit/</link>
		<comments>http://www.jeff.wilcox.name/2011/11/nov2011phonetoolkit/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 23:47:56 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/11/nov2011phonetoolkit/</guid>
		<description><![CDATA[Today we pushed the button and published the November 2011 release of the Silverlight for Windows Phone Toolkit. This is a bug-fixing release and addresses a number of important issues as reported by customers on the product’s CodePlex site. For this release the team focused entirely on reported issues, important blockers for people, and we’ve [...]]]></description>
			<content:encoded><![CDATA[<p>Today we pushed the button and published the <a href="http://silverlight.codeplex.com/releases/view/75888">November 2011 release of the Silverlight for Windows Phone Toolkit</a>. This is a bug-fixing release and addresses a number of important issues as reported by customers on the product’s <a href="http://silverlight.codeplex.com/">CodePlex site</a>.</p>
<p>For this release the team focused entirely on reported issues, important blockers for people, and we’ve been sharing updates in near-real-time through the Source Control part of the CodePlex site.</p>
<h3>Download the Nov 2011 release</h3>
<blockquote><p><a href="http://silverlight.codeplex.com/releases/view/75888#DownloadId=304100"><strong>Download the MSI</strong></a>      <br /><a href="http://nuget.org/List/Packages/SilverlightToolkitWP"><strong>Get the package through NuGet</strong></a></p>
<p><a href="http://silverlight.codeplex.com/releases/view/75888#DownloadId=304099">Download the Samples and Source</a>      <br /><a href="http://silverlight.codeplex.com/releases/view/75888">View the release notes and download page</a>      <br /><a href="http://silverlight.codeplex.com/SourceControl/BrowseLatest">Browse the Source on CodePlex</a></p>
</blockquote>
<h3>Changes in this release</h3>
<p>Here is a summary listing of the changes in this release:</p>
<h4>Larger changes</h4>
<ul>
<li>ListPicker once again works in a ScrollViewer</li>
<li>LongListSelector bug fixes around OutOfRange exceptions, wrong ordering of items, grouping issues, and scrolling events. ItemTuple is now refactored to be the public type LongListSelectorItem to provide users better access to the values in selection changed handlers.</li>
<li>PerformanceProgressBar binding fix for IsIndeterminate (item 9767 and others)</li>
<li>There is no longer a GestureListener dependency with the ContextMenu, WrapPanel, and ListPicker</li>
<li>The GestureListener should be considered deprecated for all Windows Phone 7.1 SDK development. There is no direct replacement at this time, though the platform now supports events such as Tap right on visual elements.</li>
</ul>
<h4>Other improvements</h4>
<ul>
<li>Updates the ExpanderView sample so that each individual item has its own tilt effect.</li>
<li>Fixes PhoneTextBox bugs 9342 and 9345</li>
<li>PhoneTextBox hides actionitem when empty</li>
<li>ListPicker can be in horizontally scrollable views.</li>
<li>ListPicker now only supports Tap for activation (before it supported any touch that began in bounds and stayed in bounds)</li>
<li>The LongListSelector&#8217;s Background color now is used for the picker grid to enable better app/brand styling</li>
<li>LongListSelector state name correction</li>
<li>Comments added to clarify that ListPicker does not support UIElements directly by design since the framework only permits one instance of a UI Element in the tree at a time</li>
<li>ExpanderView visual glitch fixed (9525)</li>
<li>Additional null checks in ContextMenu visual state change methods</li>
<li>ListPicker SelectedItems is now settable</li>
<li>Small fixes to ToggleSwitch</li>
<li>A startup crash correction in the gesture listener.</li>
<li>The ExpanderView sample is documented better</li>
<li>LockablePivot&#8217;s IsLocked property is now a dependency property</li>
<li>RelativeTimerConverter fixes a UTC bug and no longer throws on future dates</li>
<li>Fixes some reported issues with VB.NET samples</li>
<li>Fixed a ToggleSwitchButton reanimation issue.</li>
<li>Owner is a public property now on ContextMenu</li>
<li>Handle listpicker selected item with a null items</li>
<li>Fixes sample issues when building.</li>
<li>Fixes build warnings.</li>
</ul>
<p>Hope you enjoy the new release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/11/nov2011phonetoolkit/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Drive your application&#8217;s navigation through templated HyperlinkButtons and smart data binding to app-wide URIs</title>
		<link>http://www.jeff.wilcox.name/2011/10/hyperlinkbutton-empty-style-for-phone/</link>
		<comments>http://www.jeff.wilcox.name/2011/10/hyperlinkbutton-empty-style-for-phone/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 20:32:01 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/10/hyperlinkbutton-empty-style-for-phone/</guid>
		<description><![CDATA[A majority of the navigation throughout my application’s many pages and experiences are powered by the HyperlinkButton control. It’s fun and easy to data bind, and something I pointed out in a Channel 9 video that was being recorded this morning. I wanted to share this simple method with others – it’s so easy to [...]]]></description>
			<content:encoded><![CDATA[<p>A majority of the navigation throughout my application’s many pages and experiences are powered by the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.hyperlinkbutton(VS.95).aspx">HyperlinkButton</a> control. It’s fun and easy to data bind, and something I pointed out in a Channel 9 video that was being recorded this morning.</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/HyperlinkButtonOverlays.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="HyperlinkButtonOverlays" border="0" alt="HyperlinkButtonOverlays" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/HyperlinkButtonOverlays_thumb.png" width="680" height="586" /></a></p>
<p>I wanted to share this simple method with others – it’s so easy to re-template HB, and it removes the need to have code-behind for handling touches on buttons and other visual elements. It’s also a good way to create large hit-target friendly places for your users’ to touch.</p>
<p>I even make it more simple by exposing a ‘LocalUri’ property on almost all of my data objects, navigating to the proper contextual page for the item, complete with the identifying data in the URI, so that the new page can work from anywhere. It’s fun and quick to data bind.</p>
<p>HyperlinkButton Benefits</p>
<ul>
<li>No code behind is needed to navigate to pages within your application or even a web page in Internet Explorer</li>
<li>Easy to data bind the NavigateUri if you expose a local navigation Uri property on your model / view model / data bound objects</li>
<li>Mimics the Windows Phone’s metro UI that offers similar concepts throughout the People hubs and other apps</li>
<li>Saves lots of useless code for calling NavigationService.Navigate</li>
<li>Cuts down on bugs since your data objects provide their own app navigation URIs, so you can make bug fixes and changes in a centralized place</li>
</ul>
<h3>Large touch targets</h3>
<p>One thing I di was enlarge the touch targets. I make sure that the hyperlink button is stretched to the width of the phone, so you can touch the item even easier. In the image above, if you imagine a poorer implementation, the hyperlink button might end right at the edge of the “here now” text, making it more difficult to touch:</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/badExample.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="badExample" border="0" alt="badExample" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/badExample_thumb.png" width="333" height="78" /></a></p>
<p>Instead I make sure the item is stretched so there’s more space for someone to interact by setting HorizontalAlignment to Stretch on the control, etc.</p>
<h4>Touch target testing made easy</h4>
<p>An easy way to test your touch targets while developing is to temporarily modify your central “EmptyButtonStyle” style and have the Grid background set to Yellow (or another color) temporarily. Then you can walk through your application and easily see the touch targets your hyperlink buttons are exposing.</p>
<h3>Tilt effect</h3>
<p>Make sure to use the <a href="http://silverlight.codeplex.com/">Silverlight for Windows Phone Toolkit’s TiltEffect</a>. Since HyperlinkButton derives from ButtonBase, you will get the nice tilt effect for free this way when you use it on your pages.</p>
<h3>Styling the inner content</h3>
<p>Things that I look for when placing content inside such a hyperlink button includes alignment, spacing (6, 12, 24px offsets), and coloring. I try and mimic much of the user interface that I see throughout the Windows Phone’s main apps, as well as using the standard Styles and static resources provided in the framework.</p>
<p>The idea of my “EmptyButtonStyle” is that whatever content you put inside <em>is</em> the control, otherwise it has no visuals.</p>
<p>A common piece of XAML might look like this:</p>
<pre class="xml" name="code">&lt;HyperlinkButton
    NavigateUri=&quot;{Binding HereNow.LocalUri}&quot;
    Margin=&quot;0,12,0,0&quot;
    HorizontalAlignment=&quot;Stretch&quot;
    HorizontalContentAlignment=&quot;Left&quot;
    Style=&quot;{StaticResource EmptyButtonStyle}&quot;&gt;
    &lt;StackPanel&gt;
        &lt;TextBlock
            Style=&quot;{StaticResource PhoneTextLargeStyle}&quot;
            Text=&quot;here now&quot; /&gt;
        &lt;TextBlock
            Style=&quot;{StaticResource PhoneTextNormalStyle}&quot;
            Foreground=&quot;{StaticResource PhoneAccentBrush}&quot;
            Text=&quot;{Binding HereNow.Text, Converter={StaticResource Cap}, ConverterParameter=lowercase}&quot; /&gt;
    &lt;/StackPanel&gt;
&lt;/HyperlinkButton&gt;</pre>
<h3>My HyperlinkButton style (also works with Button)</h3>
<p>This is the template that I use. By placing it in my App.xaml file, it is accessible anywhere throughout my application, making it easy and quick to use. I actually expose both a Style and a ControlTemplate in my app, but the Style should be fine for most folks.</p>
<pre class="xml" name="code">&lt;Style x:Key=&quot;EmptyButtonStyle&quot; TargetType=&quot;primitives:ButtonBase&quot;&gt;
    &lt;Setter Property=&quot;Background&quot; Value=&quot;Transparent&quot; /&gt;
    &lt;Setter Property=&quot;Padding&quot; Value=&quot;0&quot; /&gt;
    &lt;Setter Property=&quot;Template&quot;&gt;
        &lt;Setter.Value&gt;
            &lt;ControlTemplate TargetType=&quot;primitives:ButtonBase&quot;&gt;
                &lt;Border Background=&quot;{TemplateBinding Background}&quot;
                    Padding=&quot;{TemplateBinding Padding}&quot;&gt;
                    &lt;ContentPresenter
                    HorizontalAlignment=&quot;{TemplateBinding HorizontalContentAlignment}&quot;
                    VerticalAlignment=&quot;{TemplateBinding VerticalContentAlignment}&quot;
                    Content=&quot;{TemplateBinding Content}&quot;
                    ContentTemplate=&quot;{TemplateBinding ContentTemplate}&quot;/&gt;
                &lt;/Border&gt;
            &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
&lt;/Style&gt;</pre>
<p>Don’t forget to set the xmlns primitives at the top of your App.xaml (or page’s XAML):</p>
<pre class="xml" name="code">xmlns:primitives=&quot;clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows&quot;</pre>
<p>Since it actually targets ButtonBase, you can use it with regular Buttons, as well as hyperlink buttons. Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/10/hyperlinkbutton-empty-style-for-phone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ScreenShots.cs: How to capture screenshots of your app on your device</title>
		<link>http://www.jeff.wilcox.name/2011/10/screenshots-cs-how-to-capture-screenshots-of-your-app-on-your-device/</link>
		<comments>http://www.jeff.wilcox.name/2011/10/screenshots-cs-how-to-capture-screenshots-of-your-app-on-your-device/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 15:06:20 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/10/screenshots-cs-how-to-capture-screenshots-of-your-app-on-your-device/</guid>
		<description><![CDATA[One thing that’s surprisingly hard to do on the Windows Phone is take screenshots of your application when it is running. Here’s a really simple solution that I coded up while working with some customers – you just give it an interval of time and it’ll take screenshots every few seconds, storing the resulting image [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that’s surprisingly hard to do on the Windows Phone is take screenshots of your application when it is running. Here’s a really simple solution that I coded up while working with some customers – you just give it an interval of time and it’ll take screenshots every few seconds, storing the resulting image as a JPEG in isolated storage.</p>
<p>This is useful for apps that need to be running on a real device, or if you need to capture transitions or difficult-to-reproduce actions.</p>
<h3>Using ScreenShots.cs</h3>
<p>Drop the code into your project, or use NuGet. Then, open up App.xaml.cs (where the performance counters and other debug viz tools are) and add this code to enable the screenshots:</p>
<pre class="csharp" name="code">ScreenShots.BeginTakingPictures();</pre>
<p>Of course you could also add it just to a specific page.</p>
<p>The default interval for captures is every 2 seconds, but you can optionally provide a value for that, too. For example, to take two pictures a second,</p>
<pre class="csharp" name="code">ScreenShots.BeginTakingPictures(0.5);</pre>
<p>Reminder: don’t ship with this as you’ll fill your phone’s storage with captures! I’d recommend commenting out the code most of the time. You could also add screen shot capability in a hidden debug screen in your app, etc.</p>
<h3>Getting the screenshots from isolated storage</h3>
<p>To actually get the screenshots, you can use the “isolated storage tool&quot; that is hidden away in the new 7.1 SDK. From a command prompt, just run ISETool.exe:</p>
<blockquote>
<p>pushd C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool</p>
<p>ISETool ts de &lt;GUID&gt;</p>
</blockquote>
<p>You can also provide a location to store the assets. I believe it uses the current directory otherwise.</p>
<p>You can get your app ID from the WMAppManifest.xml file that’s in your project’s Properties folder.</p>
<p>Another option is to use <a href="http://www.nachmore.com/2011/windows-phone-power-tools-1-1/">Oren’s nice Windows Phone Power Tools</a> (<a href="http://wptools.codeplex.com/">CodePlex link</a>) to super easily do this (I highly recommend this):</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="CaptureTool" border="0" alt="CaptureTool" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/CaptureTool.jpg" width="535" height="378" /></p>
<h3>Get ScreenShot.cs</h3>
<p>I’ve published to NuGet this source file:</p>
<ul>
<li>Make sure you have NuGet (<a href="http://www.nuget.org/">http://www.nuget.org/</a>) </li>
<li>Grab <a href="http://nuget.org/List/Packages/ScreenShots.cs">ScreenShots.cs</a> (Install-Package ScreenShots.cs)</li>
</ul>
<p>Or here’s the source:</p>
<pre class="csharp" name="code">//
// Copyright (c) 2010-2011 Jeff Wilcox
//
// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.IsolatedStorage;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;

namespace System.Windows
{
    /// &lt;summary&gt;
    /// Offers the ability to store images every two seconds into the isolated
    /// storage that can then be retrieved using the isolated storage tool in
    /// the 7.1 SDK.
    /// &lt;/summary&gt;
    public class ScreenShots
    {
        private ScreenShots()
        {
            _isf = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
                _isf.CreateDirectory(&quot;screenshots&quot;);
            }
            catch
            {
                // OK the directory already exists.
            }
        }

        private DispatcherTimer _dt;
        private double _interval;
        private IsolatedStorageFile _isf;
        private static ScreenShots _instance;

        public static void BeginTakingPictures(double interval = 2.0)
        {
            if (_instance == null)
            {
                _instance = new ScreenShots();
                _instance.Start(interval);
            }
            else if (_instance._dt != null)
            {
                _instance._dt.Start();
            }
        }

        public static void Stop()
        {
            if (_instance != null &amp;&amp; _instance._dt != null)
            {
                _instance._dt.Stop();
            }
        }

        private void Start(double interval)
        {
            _interval = interval;

            if (_dt == null)
            {
                _dt = new DispatcherTimer();
                _dt.Interval = TimeSpan.FromSeconds(_interval);
                _dt.Tick += OnTick;
                _dt.Start();
            }
        }

        private void OnTick(object sender, EventArgs e)
        {
            var ui = Application.Current.RootVisual;
            try
            {
                if (ui != null)
                {
                    FrameworkElement fe = ui as FrameworkElement;
                    if (fe != null)
                    {
                        var width = fe.ActualWidth;
                        var height = fe.ActualHeight;

                        WriteableBitmap wb = new WriteableBitmap(ui,
                            new TranslateTransform());
                        wb.Render(ui, new TranslateTransform());
                        byte[] bb = EncodeToJpeg(wb);

                        string filename = &quot;screenshots\\&quot;
                            + DateTime.Now.Ticks
                            .ToString(CultureInfo.InvariantCulture)
                            + &quot;.jpg&quot;;
                        using (var st = _isf.CreateFile(filename))
                        {
                            st.Write(bb, 0, bb.Length);
                        }

                        Debug.WriteLine(&quot;Saved screenshot to &quot; + filename);
                    }
                }
            }
            catch (Exception)
            {
            }
        }

        public byte[] EncodeToJpeg(WriteableBitmap wb)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                wb.SaveJpeg(
                    stream,
                    wb.PixelWidth,
                    wb.PixelHeight,
                    0,
                    85);
                return stream.ToArray();
            }
        }
    }
}</pre>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/10/screenshots-cs-how-to-capture-screenshots-of-your-app-on-your-device/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>MetroGridHelper: A helpful debugging assistant for designers and developers alike</title>
		<link>http://www.jeff.wilcox.name/2011/10/metrogridhelper/</link>
		<comments>http://www.jeff.wilcox.name/2011/10/metrogridhelper/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 22:46:30 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/10/metrogridhelper/</guid>
		<description><![CDATA[A helpful feature for developers and designers to overlay a metro-friendly grid on top of your Windows Phone application.]]></description>
			<content:encoded><![CDATA[<p>You’ve heard me preach it before: fix those margins, align, and try and make your apps as beautiful and inspiring as you can (see also: <a href="http://www.jeff.wilcox.name/2011/03/metro-design-guide-v1/">my designer tips for developers</a>).</p>
<p>On Thursday, I stopped by the Windows Phone Design Team’s beautiful studio space here on campus. It’s a really creative space, packed with fun people, chill music, and a genuine desire to see even better, more beautiful apps in the marketplace.</p>
<p>While sitting with two of the UX designers, <a href="http://twitter.com/#!/corrinab">Corrina</a> and <a href="http://twitter.com/#!/arturot">Arturo</a>, and talking about some of these design principles, I just happened to be introduced to a nifty, albeit simple, gridline/grid that the team’s been using for some time while working on the Windows Phone. It’s just a set of red squares, 25&#215;25 pixels, offset 12 pixels from one another, and all contained within a page padding of 24px. (Again: the magical Metro number is 12-based on those edges)</p>
<p>The design typically will use a Photoshop layer containing these squares, or maybe some XAML inserted on top of a page in an app, to work on alignment, visualizing the grid, etc., and making tweaks.</p>
<p>I got to thinking: it would be nice if this could be just like the <a href="http://msdn.microsoft.com/en-us/library/gg588380(v=vs.92).aspx">performance counters</a> that we have for the Windows Phone: at debug time, you could opt into overlaying this grid on top of the frame of the entire app, being omnipresent. I coded up a quick implementation during that meeting and here it is!</p>
<p>To use the counter, simply open up the <strong>App.xaml.cs</strong> file (where the other performance counters are) and add this in. I’d recommend just enabling it when you want to do a quick design pass. You can use this then both with apps on your phone as well as the emulator; it’s helpful in the emulator since you can then screenshot the UI and share that with your friends and family who can critique you on your pixel placement.</p>
<pre class="csharp" name="code">// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
{
    // Display the current frame rate counters.
    Application.Current.Host.Settings.EnableFrameRateCounter = true;

    // Display the metro grid helper.
    MetroGridHelper.IsVisible = true;</pre>
<p>Here’s what it looks like at runtime in a very simple app:</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="PhoneMetro" border="0" alt="PhoneMetro" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/PhoneMetro.png" width="480" height="800" /></p>
<p>In this example, I have one of the classic Windows Phone design “bugs”: one of the TextBlocks has just been inserted, without using the appropriate standard phone style. As a result, it has a Margin value of “0” instead of being 12 pixels offset from the left. It’s more clear now with the squares, since you can see the misalignment easily.</p>
<p>I’ve also added simple static properties for <strong>Opacity</strong> and <strong>Color</strong> if you’d rather not use the Red default color and ~0.15 opacity on the squares. The IsVisible property can be flipped off at runtime, but beware that the grid is still present in the visual tree once you add it – so there will be a performance hit (don’t ship an app that uses the grid in release builds).</p>
<h3>Get the source</h3>
<p>I’ve published the source file on NuGet – that’s a really easy way to get the file into your project, and if I make any fixes or add features in the future, it’ll be easy for you to get those changes:</p>
<ul>
<li>Make sure you have NuGet installed (<a href="http://www.nuget.org/">http://www.nuget.org/</a>) </li>
<li>Install the package using the console or package manager. It is called <a href="http://nuget.org/List/Packages/MetroGridHelper"><strong>MetroGridHelper</strong></a>
<p><font style="background-color: #ffff00" size="2" face="Consolas"><strong>PM&gt; Install-Package MetroGridHelper</strong></font></li>
</ul>
<p>Or you can drop this source code into a new file of your project, MetroGridHelper.cs:</p>
<pre class="csharp" name="code">// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace System.Windows
{
    /// &lt;summary&gt;
    /// A utility class that overlays a designer-friendly grid on top of the
    /// application frame, for use similar to the performance counters in
    /// App.xaml.cs. The color and opacity are configurable. The grid contains
    /// a number of squares that are 24x24, offset with 12px gutters, and all
    /// 24px away from the edge of the device.
    /// &lt;/summary&gt;
    public static class MetroGridHelper
    {
        private static bool _visible;
        private static double _opacity = 0.15;
        private static Color _color = Colors.Red;
        private static List&lt;Rectangle&gt; _squares;
        private static Grid _grid;

        /// &lt;summary&gt;
        /// Gets or sets a value indicating whether the designer grid is
        /// visible on top of the application's frame.
        /// &lt;/summary&gt;
        public static bool IsVisible
        {
            get
            {
                return _visible;
            }
            set
            {
                _visible = value;
                UpdateGrid();
            }
        }

        /// &lt;summary&gt;
        /// Gets or sets the color to use for the grid's squares.
        /// &lt;/summary&gt;
        public static Color Color
        {
            get { return _color; }
            set
            {
                _color = value;
                UpdateGrid();
            }
        }

        /// &lt;summary&gt;
        /// Gets or sets a value indicating the opacity for the grid's squares.
        /// &lt;/summary&gt;
        public static double Opacity
        {
            get { return _opacity; }
            set
            {
                _opacity = value;
                UpdateGrid();
            }
        }

        /// &lt;summary&gt;
        /// Updates the grid (if it already has been created) or initializes it
        /// otherwise.
        /// &lt;/summary&gt;
        private static void UpdateGrid()
        {
            if (_squares != null)
            {
                var brush = new SolidColorBrush(_color);
                foreach (var square in _squares)
                {
                    square.Fill = brush;
                }
                if (_grid != null)
                {
                    _grid.Visibility = _visible ? Visibility.Visible : Visibility.Collapsed;
                    _grid.Opacity = _opacity;
                }
            }
            else
            {
                BuildGrid();
            }
        }

        /// &lt;summary&gt;
        /// Builds the grid.
        /// &lt;/summary&gt;
        private static void BuildGrid()
        {
            _squares = new List&lt;Rectangle&gt;();

            var frame = Application.Current.RootVisual as Frame;
            if (frame == null || VisualTreeHelper.GetChildrenCount(frame) == 0)
            {
                Deployment.Current.Dispatcher.BeginInvoke(BuildGrid);
                return;
            }

            var child = VisualTreeHelper.GetChild(frame, 0);
            var childAsBorder = child as Border;
            var childAsGrid = child as Grid;
            if (childAsBorder != null)
            {
                // Not a pretty way to control the root visual, but I did not
                // want to implement using a popup.
                var content = childAsBorder.Child;
                if (content == null)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(BuildGrid);
                    return;
                }
                childAsBorder.Child = null;
                Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
                {
                    Grid newGrid = new Grid();
                    childAsBorder.Child = newGrid;
                    newGrid.Children.Add(content);
                    PrepareGrid(frame, newGrid);
                });
            }
            else if (childAsGrid != null)
            {
                PrepareGrid(frame, childAsGrid);
            }
            else
            {
                Debug.WriteLine(&quot;Dear developer:&quot;);
                Debug.WriteLine(&quot;Unfortunately the design overlay feature requires that the root frame visual&quot;);
                Debug.WriteLine(&quot;be a Border or a Grid. So the overlay grid just isn't going to happen.&quot;);
                return;
            }
        }

        /// &lt;summary&gt;
        /// Does the actual work of preparing the grid once the parent frame is
        /// in the visual tree and we have a Grid instance to work with for
        /// placing the chilren.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;frame&quot;&gt;The phone application frame.&lt;/param&gt;
        /// &lt;param name=&quot;parent&quot;&gt;The parent grid to insert the sub-grid into.&lt;/param&gt;
        private static void PrepareGrid(Frame frame, Grid parent)
        {
            var brush = new SolidColorBrush(_color);

            _grid = new Grid();
            _grid.IsHitTestVisible = false;

            // To support both orientations, unfortunately more visuals need to
            // be used. An alternate implementation would be to react to the
            // orientation change event and re-draw/remove squares.
            double width = frame.ActualWidth;
            double height = frame.ActualHeight;
            double max = Math.Max(width, height);

            for (int x = 24; x &lt; /*width*/ max; x += 37)
            {
                for (int y = 24; y &lt; /*height*/ max; y += 37)
                {
                    var rect = new Rectangle
                    {
                        Width = 25,
                        Height = 25,
                        VerticalAlignment = System.Windows.VerticalAlignment.Top,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Margin = new Thickness(x, y, 0, 0),
                        IsHitTestVisible = false,
                        Fill = brush,
                    };
                    _grid.Children.Add(rect);
                    _squares.Add(rect);
                }
            }

            _grid.Visibility = _visible ? Visibility.Visible : Visibility.Collapsed;
            _grid.Opacity = _opacity;

            // For performance reasons a single surface should ideally be used
            // for the grid.
            _grid.CacheMode = new BitmapCache();

            // Places the grid into the visual tree. It is never removed once
            // being added.
            parent.Children.Add(_grid);
        }
    }
}</pre>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/10/metrogridhelper/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Resizing images to square, aspect-ratio friendly bits with Node, Express, and ImageMagick</title>
		<link>http://www.jeff.wilcox.name/2011/10/node-express-imagemagick-square-resizing/</link>
		<comments>http://www.jeff.wilcox.name/2011/10/node-express-imagemagick-square-resizing/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 22:19:45 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Express]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/10/node-express-imagemagick-square-resizing/</guid>
		<description><![CDATA[I’ve been playing around with Node.js a little more recently and wanted to share a little short lesson I had. A quick little break from the phone client… As part of the cloud environment for my application, I have a service that dynamically resizes a given image from Foursquare into a Windows Phone tile size [...]]]></description>
			<content:encoded><![CDATA[<p><em>I’ve been playing around with Node.js a little more recently and wanted to share a little short lesson I had. A quick little break from the phone client…</em></p>
<p>As part of the cloud environment for my application, I have a service that dynamically resizes a given image from Foursquare into a Windows Phone tile size (173&#215;173 pixels). This is used for the “pin to start” feature of 4th and Mayor.</p>
<p>The initial implementation of this service was done in PHP.</p>
<p>However, the new version of my cloud infrastructure is powered by Node.js for the most part, and I ran into some fun problems trying to get ImageMagick to properly resize images to be aspect-aware. I am using Express for servicing notifications and other endpoints.</p>
<h3>How the resized image is used</h3>
<p>Here’s an image from a Foursquare user of Microsoft Building 40, where my office is right now. I like to keep it pinned to my start screen, and the source image from fsq is actually much larger and not properly sized or cropped for tile display.</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/Pinned4th.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Pinned4th" border="0" alt="Pinned4th" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/Pinned4th_thumb.png" width="466" height="417" /></a></p>
<p>When the pinned tile is created, the remote URI points to the 4thandmayor.com cloud presence, and then server-side I resize the Foursquare image provided in the query string. (I also validate that it’s actually an image from there, etc.)</p>
<h3>Resizing images using node-imagemagick</h3>
<p>I’m wanting to use the <a href="https://github.com/rsms/node-imagemagick/">node-imagemagick module</a> with Node to do the resizing (similar to what PHP was doing with ImageMagick before). It really just shells out to the ImageMagick ‘convert’ program.</p>
<p>There is a built-in “resize” function, however I don’t exactly want to use that: here’s what happens when I resize the image the standard way. I just assumed that it would figure out a good size and crop. It’s been a while since I used this stuff in college!</p>
<pre class="js" name="code">var im = require(&quot;imagemagick&quot;);
im.resize({
    srcData : img,
    strip : false,
    width : 173,
    height : 173
}, function(err, stdout, stderr)
{
    if (err){
        redirectToStandardTile(res);
    } else {
        res.contentType(&quot;image/jpeg&quot;);
        res.end(stdout, 'binary');
    }
});</pre>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/173tall.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="173tall" border="0" alt="173tall" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/173tall_thumb.jpg" width="130" height="173" /></a></p>
<p>The aspect ratio is maintained.</p>
<h3>Trying to crop the image instead</h3>
<p>There’s a separate crop function as well, but it works only on files, no streams. I’d like to not use temporary files if I can and instead just pipe around the raw image bytes. There is also a thumbnail command built into ImageMagick, but I don’t want to reinvent the wheel and not be able to use the helpful node library created by <a href="https://github.com/rsms">Rasmus</a>.</p>
<h3>Trying the width x height ! option</h3>
<p>You can also force to be a specific size, such as this, by appending an exclamation point to the height (as a string literal). Not good for me (the photo is stretched):</p>
<pre class="js" name="code">var im = require(&quot;imagemagick&quot;);
im.resize({
    srcData : img,
    strip : false,
    width : 173,
    height : &quot;173!&quot; // force the sizing.
}, function(err, stdout, stderr)
{
    if (err){
        redirectToStandardTile(res);
    } else {
        res.contentType(&quot;image/jpeg&quot;);
        res.end(stdout, 'binary');
    }
});</pre>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/173aspectforced.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="173aspectforced" border="0" alt="173aspectforced" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/173aspectforced_thumb.jpg" width="173" height="173" /></a> </p>
<h3>Using resize plus extents to create a square 173&#215;173 thumbnail</h3>
<p>Instead, I decided to append custom arguments for ImageMagick’s convert program, and finally came up with a combination of extent values, etc., that work for my needs. Here’s what finally worked for me:</p>
<ul>
<li>Using the hat appended to the height value (173^ in a string literal instead of 173) </li>
<li>Including the gravity argument </li>
<li>Setting the extent to be the square 173&#215;173 area of interest </li>
</ul>
<pre class="js" name="code">// Resize a photo for use in a live tile or secondary place tile.
app.get('/tile.php', function (req, res) {
    var original = req.param(&quot;i&quot;);
    if (original) {
        getImage(original, function (err, img) {
            if (!err &amp;&amp; img) {
                var im = require(&quot;imagemagick&quot;);
                im.resize({
                    srcData : img,
                    strip : false,
                    width : 173,
                    height : &quot;173^&quot;,
                    customArgs: [
                         &quot;-gravity&quot;, &quot;center&quot;
                        ,&quot;-extent&quot;, &quot;173x173&quot;
                        ]
                }, function(err, stdout, stderr)
                {
                    if (err){
                        redirectToStandardTile(res);
                    } else {
                        res.contentType(&quot;image/jpeg&quot;);
                        res.end(stdout, 'binary');
                    }
                });
            } else {
                redirectToStandardTile(res);
            }
        });
    }
});

function redirectToStandardTile(res) {
    res.redirect(&quot;http://www.4thandmayor.com/app/genericTile.png&quot;);
}

function getImage(uri, callback) { // (err, res)
    request(
    {
        encoding: 'binary',
        uri: uri,
    }, function (error, response, body) {
        if (!error &amp;&amp; response.statusCode == 200) {
            callback(null, body);
        } else {
            callback(error, null);
        }
    });
}</pre>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/173tile.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="173tile" border="0" alt="173tile" src="http://www.jeff.wilcox.name/wp-content/uploads/2011/10/173tile_thumb.jpg" width="173" height="173" /></a></p>
<p>This implementation includes the Express code, in case you were wondering about doing that part. I’m attaching to the same former PHP URI for this functionality so that I don’t have to update paths and can continue to serve older versions of the app as appropriate.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/10/node-express-imagemagick-square-resizing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A note about remote URIs in Windows Phone secondary tiles</title>
		<link>http://www.jeff.wilcox.name/2011/09/a-note-about-remote-uris-in-windows-phone-secondary-tiles/</link>
		<comments>http://www.jeff.wilcox.name/2011/09/a-note-about-remote-uris-in-windows-phone-secondary-tiles/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 18:19:38 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=848</guid>
		<description><![CDATA[One of my favorite features in Mango is the ability for developers to let users pin a deep linking secondary tile to their start screen. It’s a simple concept but really opens up a lot of new opportunities for apps-within-an-app, shortcuts to oft-used functionality, plus many other innovations. In 4th &#38; Mayor, I use these [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite features in Mango is the ability for developers to let users pin a deep linking secondary tile to their start screen. It’s a simple concept but really opens up a lot of new opportunities for apps-within-an-app, shortcuts to oft-used functionality, plus many other innovations.</p>
<p>In 4th &amp; Mayor, I use these to allow people to pin places to the start, and also to check-in a lot quicker. In my current released version, I actually found out after-the-fact about a remote URI bug, and wanted to share my notes on this.</p>
<p>If you’re looking for the basic reference on this deep-linking feature, do refer to the “<a href="http://msdn.microsoft.com/en-us/library/hh202979(v=VS.92).aspx">Create, Delete, and Update Tiles for Windows Phone</a>” entry on MSDN.</p>
<h3>What’s the issue with remote URIs?</h3>
<p>As best I can tell, the situation is: adding a secondary tile with a relative URI (pointing to an app’s content, such as SomeImage.png, that is packaged within the .Xap) is OK, and that secondary tile will always be present.</p>
<p>However, if you use a remote URI (such as a dynamically generated background image, or from a database or social network), that secondary tile is only present for that current device’s uptime: if you restart the device (or the battery dies, etc.), when you come back, the secondary tiles will no longer be present.</p>
<p>Users should still be able to re-pin any of their favorite secondary tiles to the start screen again. However, it turns out there is a bug here unfortunately: the secondary tile is still present in the ActiveTiles collection, and the OS seems to believe that it is still there, even though it is not.</p>
<p>The workaround is to search for the existing identical secondary tile and delete it, before re-pinning it, in your apps. This does mean that it’s not possible to tell whether a secondary tile with a remote URI is truly pinned or not – it will look pinned in the ActiveTiles collection but the user will not actually have the item pinned.</p>
<h3>Using a remote URI</h3>
<p>If you just use a remote URI (absolute), you will experience one-time pin ability; after that, and a device restart, it won’t be possible to re-pin the same page without first deleting the entry.</p>
<h3>Using a remote URI, working around re-pin issues</h3>
<p>Here is the code I’ve used to workaround these issues, effectively deleting the tile first, and re-pinning, only when using an absolute URI:</p>
<pre class="c-sharp" name="code">private void OnPinButtonPressed(object sender, RoutedEventArgs e)
{
    var backgroundImage = new Uri(&quot;http://tiles.4thandmayor.com/CrownBackground.png&quot;, UriKind.Absolute);

    var tile  = ShellTile.ActiveTiles
        .FirstOrDefault(x =&gt; x.NavigationUri == NavigationService.CurrentSource);

    // Only if this is a remote background image URI do we need to
    // delete and re-pin the secondary tile.
    if (tile != null &amp;&amp; backgroundImage.IsAbsoluteUri)
    {
        tile.Delete();

        var newTile = new StandardTileData
        {
            BackgroundImage = backgroundImage,
            Title = &quot;Secondary Tile&quot;,
        };

        ShellTile.Create(NavigationService.CurrentSource, newTile);
    }
}</pre>
<p><strong>9/29/11 1:40 PM PST note</strong>: It’s been pointed out to me that I don’t know how to code. The code above will re-pin, but not initially pin. A little more boolean logic is needed. I’ll try and update later, but the concept remains.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/09/a-note-about-remote-uris-in-windows-phone-secondary-tiles/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Friday at //BUILD/: Jeff Wilcox on Windows Phone Performance</title>
		<link>http://www.jeff.wilcox.name/2011/09/build-wp-performance/</link>
		<comments>http://www.jeff.wilcox.name/2011/09/build-wp-performance/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 21:02:57 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2011/09/build-wp-performance/</guid>
		<description><![CDATA[It’s an exciting week here at //BUILD/, things are off to a good start. Now that the sessions are public, I wanted to let my readers know that I am giving a talk on Friday about Windows Phone Performance. Windows Phone application performance and optimization 9/16/11 from 12:30 PM to 1:30 PM Room: Marriott Orange [...]]]></description>
			<content:encoded><![CDATA[<p>It’s an exciting week here at //BUILD/, things are off to a good start. Now that the sessions are public, I wanted to let my readers know that I am giving a talk on Friday about Windows Phone Performance.</p>
<p><img src="http://www.buildwindows.com/themes/buildtheme/content/build_logo_small.png" /></p>
<p><strong><em>Windows Phone application performance and optimization</em></strong>    <br />9/16/11 from 12:30 PM to 1:30 PM    <br />Room: Marriott Orange County 4</p>
<p>Here’s a link to the <a href="http://channel9.msdn.com/events/BUILD/BUILD2011/APP-827T">session page</a> on C9.</p>
<p>The talk will cover:</p>
<ul>
<li>Performance counters and performance basics</li>
<li>The new Windows Phone profiler</li>
<li>Strategies for improving app performance</li>
<li>General Q&amp;A session at the end</li>
</ul>
<p>Note to MIX 11 attendees: this talk is very similar to my MIX presentation, though the app is slightly different.</p>
<p>Hope to see you at the talk!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2011/09/build-wp-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

