<?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>Damian&#039;s Blog</title>
	<atom:link href="http://damianblog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://damianblog.com</link>
	<description>.NET from Geneva, Switzerland</description>
	<lastBuildDate>Fri, 30 Sep 2011 23:25:01 +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>Evernote 2.0 for Windows Phone 7.5 (Mango) released</title>
		<link>http://damianblog.com/2011/09/24/evernote-20-released/</link>
		<comments>http://damianblog.com/2011/09/24/evernote-20-released/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 13:39:12 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[Evernote]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/?p=410</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="420" height="315"><param name="movie" value="http://www.youtube.com/v/DvKcK5Or1LM?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/DvKcK5Or1LM?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/09/24/evernote-20-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presentation at the Evernote Trunk Conference on developing the Evernote Windows Phone client</title>
		<link>http://damianblog.com/2011/09/23/etc-presentation/</link>
		<comments>http://damianblog.com/2011/09/23/etc-presentation/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 14:38:13 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[Evernote]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/?p=399</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="640" height="320"><param name="movie" value="http://www.youtube.com/v/_viLV4nzOWw?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/_viLV4nzOWw?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="640" height="320" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/09/23/etc-presentation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Elephants love mangoes – a look behind our Windows Phone 7 client</title>
		<link>http://damianblog.com/2011/08/02/evernote-wp7/</link>
		<comments>http://damianblog.com/2011/08/02/evernote-wp7/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 07:42:07 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/?p=395</guid>
		<description><![CDATA[I wrote this article for the Evernote Tech Blog last month, summarizing my experience developing the Windows Phone Evernote client: http://blog.evernote.com/tech/2011/06/28/look-behind-evernote-wp7/]]></description>
			<content:encoded><![CDATA[<p>I wrote this article for the Evernote Tech Blog last month, summarizing my experience developing the Windows Phone Evernote client: <a href="http://blog.evernote.com/tech/2011/06/28/look-behind-evernote-wp7/">http://blog.evernote.com/tech/2011/06/28/look-behind-evernote-wp7/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/08/02/evernote-wp7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTC Gingerbread&#8211;automatically switching from Wifi  to costly data connection</title>
		<link>http://damianblog.com/2011/05/30/htc-gingerbreadautomatically-switching-from-wifi-to-costly-data-connection/</link>
		<comments>http://damianblog.com/2011/05/30/htc-gingerbreadautomatically-switching-from-wifi-to-costly-data-connection/#comments</comments>
		<pubDate>Mon, 30 May 2011 14:17:23 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/05/30/htc-gingerbreadautomatically-switching-from-wifi-to-costly-data-connection/</guid>
		<description><![CDATA[I have an HTC Incredible S, and it’s a very nice phone indeed. I recently upgraded Android 2.3.3 (Gingerbread), and discovered that the Wifi connection was dropping in places at home where it had a perfectly usable (albeit weak) Wifi signal.&#160; Places where previously it had worked. I fiddled with my Wifi base station, repositioning [...]]]></description>
			<content:encoded><![CDATA[<p>I have an <a href="http://www.htc.com/www/product/incredibles/overview.html">HTC Incredible S</a>, and it’s a very nice phone indeed.</p>
<p>I recently upgraded <a href="http://developer.android.com/sdk/android-2.3-highlights.html">Android 2.3.3</a> (Gingerbread), and discovered that the Wifi connection was dropping in places at home where it had a perfectly usable (albeit weak) Wifi signal.&#160; Places where previously it had worked.</p>
<p>I fiddled with my Wifi base station, repositioning it, to no avail.</p>
<p>Finally I googled and found that <a href="http://forum.xda-developers.com/archive/index.php/t-1058450.html">HTC had decided to switch from Wifi to data if the Wifi signal dropped below a certain strength (88dbm)</a>.&#160; How nice of them to decide on my behalf that I wanted to switch from my (free) Wifi to my (expensive) data plan, even though I still had a perfectly usable (and free) Wifi connection – one that worked perfectly well in the previous OS version.</p>
<p>This is annoying for a couple of reasons.&#160; Firstly I can now run up horrendous data plan charges even though I’m within range of my Wifi.&#160; Secondly, I have services I run on my local Wifi (IP Cams, remote control software) that can no longer connect when I’m off my Wifi.</p>
<p>I’ve been a big HTC fan for a long time, and have gone through many of their ‘phones.&#160; This is a big disappointment for me – it stinks of paternalism/arrogance – deciding what is best for me without giving me a chance to override it.&#160; I am sure that it isn’t arrogance/paternalism – I am sure it made perfectly good engineering sense, perhaps because less battery will be consumed on data than on Wifi when on a weak link, but <strong>give me a choice</strong>.</p>
<p>I contacted HTC support and was told that yes, this behavior is new and that no, there was no way to downgrade – the suggestion was to switch off the Data connection when I was at home. Right, as if I will remember to do that.</p>
<p>I’ve ended up installing <a href="http://tasker.dinglisch.net/">Tasker</a>, and setting up a rule to switch off my Data connection when within range of my home Wifi.&#160; Not ideal, but it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/05/30/htc-gingerbreadautomatically-switching-from-wifi-to-costly-data-connection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to: Windows 7 incoming VPN from Android</title>
		<link>http://damianblog.com/2011/05/26/android-vpn-to-windows7/</link>
		<comments>http://damianblog.com/2011/05/26/android-vpn-to-windows7/#comments</comments>
		<pubDate>Thu, 26 May 2011 17:37:42 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/05/26/android-vpn-to-windows7/</guid>
		<description><![CDATA[A couple of weeks ago I tried to get my HTC Incredible S, running Gingerbread to connect via VPN to my Windows 7 box.&#160; I failed, but today I succeeded.&#160; This is how. I created the incoming VPN on Windows 7 by following instructions I found on the web: Open the Network and Sharing Center [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I tried to get my HTC Incredible S, running Gingerbread to connect via VPN to my Windows 7 box.&#160; I failed, but today I succeeded.&#160; This is how.</p>
<p>I created the incoming VPN on Windows 7 by following instructions I found on the web:</p>
<h5>Open the Network and Sharing Center</h5>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb.png" width="244" height="150" /></a></p>
<h5>Click on Change Adapter Settings</h5>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image1.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="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb1.png" width="197" height="214" /></a></p>
<h5>Press Alt-F, and select New Incoming Connection</h5>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image2.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="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb2.png" width="181" height="244" /></a></p>
<h5>Configure the incoming connection</h5>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image3.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="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb3.png" width="244" height="180" /></a><a href="http://damianblog.com/wp-content/uploads/2011/05/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb4.png" width="244" height="180" /></a><a href="http://damianblog.com/wp-content/uploads/2011/05/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb5.png" width="244" height="180" /></a></p>
<h5>Change the IPV4 properties to specify a DHCP range</h5>
<p>Make sure the range you specify is on your LAN, and out of the range served by your DHCP server (you can updated your DHCP server to exclude this range).</p>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb6.png" width="416" height="330" /></a></p>
<h5>Check the firewall</h5>
<p>I went to Advanced Settings under Windows Firewall, clicked on Inbound Rules, clicked on the Local Port column to sort by that column, and then verified that the line for port 1723 was set up and enabled (Routing and Remote Access (PPTP-In).</p>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image7.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="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb7.png" width="556" height="98" /></a></p>
<h5>Set up port forwarding</h5>
<p>I then went to my Router configuration, and set up port forwarding, so that external connections to port 1723 were forwarded to the machine I just configured (which is always allocated the same IP address by the router):</p>
<p><a href="http://damianblog.com/wp-content/uploads/2011/05/image8.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="image" border="0" alt="image" src="http://damianblog.com/wp-content/uploads/2011/05/image_thumb8.png" width="561" height="365" /></a></p>
<p>Now my Android device can connect to my internal VPN using the default settings.&#160; You’ll need to know your external IP address.&#160; You can find it using tools like <a href="http://www.whatismyip.com/">http://www.whatismyip.com/</a> but it may change.&#160; I have mine set up using <a href="http://www.dyndns.com/">http://www.dyndns.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/05/26/android-vpn-to-windows7/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>GoBackAction&#8211;a Windows Phone Behavior to navigate back</title>
		<link>http://damianblog.com/2011/04/11/gobackaction/</link>
		<comments>http://damianblog.com/2011/04/11/gobackaction/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 09:37:09 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/04/11/gobackaction/</guid>
		<description><![CDATA[Behaviors are a great way to encapsulate functionality that can be used in a drag-and-drop environment such as Expression Blend. Out of the box you get a NavigateToPageAction, but I couldn’t see an easy way to navigate backwards to the previous page using any of the built-in behaviors.&#160; I wanted to let the user click [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://expression.microsoft.com/en-us/library/ff979326(Expression.40).aspx">Behaviors</a> are a great way to encapsulate functionality that can be used in a drag-and-drop environment such as Expression Blend.</p>
<p>Out of the box you get a <a href="http://expression.microsoft.com/en-us/library/ff979325(Expression.40).aspx">NavigateToPageAction</a>, but I couldn’t see an easy way to navigate backwards to the previous page using any of the built-in behaviors.&#160; I wanted to let the user click on an item in a list, and then have the Phone automatically navigate to the previous page.</p>
<p>So here it is, the world’s simplest behavior:</p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7358a70-34fe-4a5e-98e8-5a8b7d625dac" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;">[<span style="color:#00008b">DefaultTrigger</span>(<span style="color:#0000ff">typeof</span> (<span style="color:#00008b">ButtonBase</span>), <span style="color:#0000ff">typeof</span> (<span style="color:#00008b">System</span>.<span style="color:#00008b">Windows</span>.<span style="color:#00008b">Interactivity</span>.<span style="color:#00008b">EventTrigger</span>), <span style="color:#a31515">&quot;Click&quot;</span>)]<br /> [<span style="color:#00008b">DefaultTrigger</span>(<span style="color:#0000ff">typeof</span> (<span style="color:#00008b">UIElement</span>), <span style="color:#0000ff">typeof</span> (<span style="color:#00008b">System</span>.<span style="color:#00008b">Windows</span>.<span style="color:#00008b">Interactivity</span>.<span style="color:#00008b">EventTrigger</span>), <span style="color:#a31515">&quot;MouseLeftButtonDown&quot;</span>)]<br /> <span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#00008b">GoBackAction</span> : <span style="color:#00008b">TriggerAction</span>&lt;<span style="color:#00008b">FrameworkElement</span>&gt;<br /> {<br />     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">Invoke</span>(<span style="color:#0000ff">object</span> parameter)<br />     {<br />         <span style="color:#0000ff">var</span> rootFrame = <span style="color:#00008b">Application</span>.<span style="color:#800080">Current</span>.<span style="color:#800080">RootVisual</span> <span style="color:#0000ff">as</span> <span style="color:#00008b">PhoneApplicationFrame</span>;<br />         <span style="color:#0000ff">if</span>(rootFrame !=<span style="color:#0000ff">null</span>)<br />         {<br />             rootFrame.<span style="color:#008b8b">GoBack</span>();<br />         }<br />     }<br /> }</div>
</p></div>
</p></div>
<p> Once you’ve built this class in your project, if you open your project in Expression Blend you should see the GoBackAction listed in the Behaviors section of the Assets tab.&#160; You can then drag the behavior onto a UI element, define the event that should trigger the action, and then when the event occurs you should be automatically navigated backwards.</p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/04/11/gobackaction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adapting Fluid List Animation to work with the LongListSelector</title>
		<link>http://damianblog.com/2011/04/04/fluidlonglistselector/</link>
		<comments>http://damianblog.com/2011/04/04/fluidlonglistselector/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 09:33:06 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/04/04/fluidlonglistselector/</guid>
		<description><![CDATA[Colin Eberhardt at ScottLogic has been doing some excellent work showing how we can make our own UIs animate in a fluid manner similar to the built in Microsoft UIs on Windows Phone. His Fluid List Animation is particularly neat, and I thought I’d apply it to the UI I’m developing, specifically on a couple [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.scottlogic.co.uk/blog/colin/">Colin Eberhardt</a> at <a href="http://www.scottlogic.co.uk/">ScottLogic</a> has been doing some excellent work showing how we can make our own UIs animate in a fluid manner similar to the built in Microsoft UIs on Windows Phone.</p>
<p>His <a href="http://www.scottlogic.co.uk/blog/colin/2011/03/metro-in-motion-fluid-list-animation/">Fluid List Animation</a> is particularly neat, and I thought I’d apply it to the UI I’m developing, specifically on a couple of <a href="http://www.windowsphonegeek.com/articles/wp7-longlistselector-in-depth--part1-visual-structure-and-api">LongListSelectors</a> that I embed in Pivots.</p>
<p>Unfortunately his code didn’t work on the LongListSelector out of the box because although Colin went out of his way to make it work with any ItemsControl, the LongListSelector is not an ItemsControl.&#160; Fortunately his code was well commented, and it was trivial to modify it to work with the LongListSelector.</p>
<p>All the changes are in the OnIsPivotAnimatedChanged method in the ListAnimation class.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3e5fd280-1a4e-4af4-91a5-7e406fc8d1df" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">OnIsPivotAnimatedChanged</span>(<span style="color:#00008b">DependencyObject</span> d, <span style="color:#00008b">DependencyPropertyChangedEventArgs</span> args)<br /> {<br /> <span style="color:#008000">//  ItemsControl list = d as ItemsControl;</span><br />     <span style="color:#00008b">LongListSelector</span> list = d <span style="color:#0000ff">as</span> <span style="color:#00008b">LongListSelector</span>;</div>
</p></div>
</p></div>
<p>Next find the section that starts with the comment “locate the stack panel that hosts the items” and replace the code that follows it (up to and including the for loop) with:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:88d9aae0-2b03-4920-adc1-815f4a456398" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">var</span> itemsInView = list.<span style="color:#008b8b">GetItemsWithContainers</span>(<span style="color:#0000ff">true</span>, <span style="color:#0000ff">true</span>);</p>
<p> <span style="color:#0000ff">foreach</span> (<span style="color:#00008b">ContentPresenter</span> item <span style="color:#0000ff">in</span> itemsInView)<br /> {<br />     <span style="color:#0000ff">var</span> localItem = item;<br />     list.<span style="color:#800080">Dispatcher</span>.<span style="color:#008b8b">BeginInvoke</span>(() =&gt;<br />     {<br />         <span style="color:#0000ff">var</span> animationTargets = localItem.<span style="color:#008b8b">Descendants</span>().<span style="color:#008b8b">Where</span>(p =&gt; <span style="color:#008b8b">GetAnimationLevel</span>(p) &gt; -1);<br />         <span style="color:#0000ff">foreach</span> (<span style="color:#00008b">FrameworkElement</span> target <span style="color:#0000ff">in</span> animationTargets)<br />         {<br />             <span style="color:#008000">// trigger the required animation</span><br />             <span style="color:#008b8b">GetAnimation</span>(target, fromRight).<span style="color:#008b8b">Begin</span>();<br />         }<br />     });<br /> }</div>
</p></div>
</p></div>
<p>The key is the call to GetItemsWithContainers – the first parameter indicates we only want items that are in view, and the second indicates we want the containers (hence the ContentPresenter type in the foreach).</p>
<p>That’s it – Colin did all the hard work – I just adapted it – all kudos to him.</p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/04/04/fluidlonglistselector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>So you think you&#8217;ve finished implementing that new Windows Phone 7 page?</title>
		<link>http://damianblog.com/2011/03/25/windows-phone-7-page-checklist/</link>
		<comments>http://damianblog.com/2011/03/25/windows-phone-7-page-checklist/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 00:31:38 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/03/25/windows-phone-7-page-checklist/</guid>
		<description><![CDATA[So you think you’ve finished implementing that new Windows Phone 7 page? Have you checked that you: are using resources for all user-visible strings? have made sure the page handles rotation properly? handle the Enter key on each TextBox to move to the next TextBox, or submit the page? have set the InputScope on each [...]]]></description>
			<content:encoded><![CDATA[<p>So you think you’ve finished implementing that new Windows Phone 7 page?</p>
<p>Have you checked that you:</p>
<ol>
<li>are using <a href="http://msdn.microsoft.com/en-us/library/ff637520(v=vs.92).aspx">resources</a> for all user-visible strings? </li>
<li>have made sure the page <a href="http://mobileworld.appamundi.com/blogs/andywigley/archive/2010/11/23/windows-phone-7-page-orientation-change-animations.aspx">handles rotation</a> properly? </li>
<li>handle the <a href="http://stackoverflow.com/questions/3295057/determining-the-enter-key-is-pressed-in-a-textbox-in-win-phone-7">Enter key</a> on each TextBox to move to the next TextBox, or submit the page?</li>
<li>have set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.inputscope(v=vs.95).aspx">InputScope</a> on each TextBox? </li>
<li>handle <a href="http://msdn.microsoft.com/en-us/library/ff967548(v=VS.92).aspx">tombstoning</a> properly? </li>
<li>have set up <a href="http://blogs.msdn.com/b/wfaught/archive/2010/11/15/transitions.aspx">Navigation transitions</a>? </li>
<li>have tested with both the Light and Dark <a href="http://msdn.microsoft.com/en-us/library/ff402557(v=VS.92).aspx">Themes</a>? </li>
<li>are using the <a href="http://msdn.microsoft.com/en-us/library/ff769552(v=vs.92).aspx">built-in resources</a> for text styles? </li>
<li><a href="http://blog.toetapz.com/2010/11/17/handling-the-back-button-with-a-popup-open-on-windows-phone-7/">override the Back button</a> press if you are displaying popups?</li>
</ol>
<p>What have I missed?</p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/03/25/windows-phone-7-page-checklist/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Storing WP7 recorded audio as WAV format streams</title>
		<link>http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/</link>
		<comments>http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 13:56:04 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/</guid>
		<description><![CDATA[The Microsoft audio recording example shows how to record audio, but it just gets a PCM encoded stream of samples – if you want to send this audio stream off somewhere else, to be played later, it needs a proper header. Below I show you how to use a couple of methods I’ve written (WriteWavHeader [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://msdn.microsoft.com/en-us/library/gg442302(v=VS.92).aspx">Microsoft audio recording example</a> shows how to record audio, but it just gets a <a href="http://en.wikipedia.org/wiki/Pulse-code_modulation">PCM</a> encoded stream of samples – if you want to send this audio stream off somewhere else, to be played later, it needs a <a href="https://ccrma.stanford.edu/courses/422/projects/WaveFormat/">proper header</a>.</p>
<p>Below I show you how to use a couple of methods I’ve written (WriteWavHeader and UpdateWavHeader), and I include their implementation.</p>
<p>Assuming you start with the Microsoft sample, when you initiate the audio recording you initialize a memory stream into which the samples will be written:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9378e5f4-964a-44b0-bf86-3dcd215f4a98" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">StartRecording</span>()<br /> {<br />     <span style="color:#800080">_microphone</span>.<span style="color:#800080">BufferDuration</span> = <span style="color:#00008b">TimeSpan</span>.<span style="color:#008b8b">FromMilliseconds</span>(500);</p>
<p>     <span style="color:#008000">// Allocate memory to hold the audio data</span><br />     <span style="color:#800080">_recordingBuffer</span> = <span style="color:#0000ff">new</span> <span style="color:#0000ff">byte</span>[<span style="color:#800080">_microphone</span>.<span style="color:#008b8b">GetSampleSizeInBytes</span>(<span style="color:#800080">_microphone</span>.<span style="color:#800080">BufferDuration</span>)];</p>
<p>     <span style="color:#800080">_recordingStream</span>.<span style="color:#008b8b">SetLength</span>(0);</p>
<p>     <span style="color:#008b8b">WriteWavHeader</span>(<span style="color:#800080">_recordingStream</span>, <span style="color:#800080">_microphone</span>.<span style="color:#800080">SampleRate</span>);</p>
<p>     <span style="color:#800080">_microphone</span>.<span style="color:#008b8b">Start</span>();<br /> }</div>
</p></div>
</p></div>
<p>Note the call to WriteWavHeader to write the wav header to the start of the audio stream.
<p>When the recording finishes, you update the header (because we need to fill in fields based on the data length):</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1af5857b-b019-4c8e-87e6-120ebe697205" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">StopRecording</span>()<br /> {<br />     <span style="color:#800080">_microphone</span>.<span style="color:#008b8b">Stop</span>();<br />     <span style="color:#008b8b">UpdateWavHeader</span>(<span style="color:#800080">_recordingStream</span>);<br /> }</div>
</p></div>
</p></div>
<p>Here are the implementations of the WriteWavHeader and UpdateWavHeader methods.&#160; The comments come from this <a href="https://ccrma.stanford.edu/courses/422/projects/WaveFormat/">web page</a> describing the wav header file format.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:432cf64c-cd4b-492e-899d-78f470be6d8c" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">WriteWavHeader</span>(<span style="color:#00008b">Stream</span> stream, <span style="color:#0000ff">int</span> sampleRate)<br /> {<br />     <span style="color:#0000ff">const</span> <span style="color:#0000ff">int</span> <span style="color:#800080">bitsPerSample</span> = 16;<br />     <span style="color:#0000ff">const</span> <span style="color:#0000ff">int</span> <span style="color:#800080">bytesPerSample</span> = <span style="color:#800080">bitsPerSample</span> / 8;<br />     <span style="color:#0000ff">var</span> encoding = <span style="color:#00008b">System</span>.<span style="color:#00008b">Text</span>.<span style="color:#00008b">Encoding</span>.<span style="color:#800080">UTF8</span>;</p>
<p>     <span style="color:#008000">// ChunkID Contains the letters &quot;RIFF&quot; in ASCII form (0x52494646 big-endian form).</span><br />     stream.<span style="color:#008b8b">Write</span>(encoding.<span style="color:#008b8b">GetBytes</span>(<span style="color:#a31515">&quot;RIFF&quot;</span>), 0, 4);</p>
<p>     <span style="color:#008000">// </span><span style="color:#00008b">NOTE this will be filled in later</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>(0), 0, 4);</p>
<p>     <span style="color:#008000">// Format Contains the letters &quot;WAVE&quot;(0x57415645 big-endian form).</span><br />     stream.<span style="color:#008b8b">Write</span>(encoding.<span style="color:#008b8b">GetBytes</span>(<span style="color:#a31515">&quot;WAVE&quot;</span>), 0, 4);</p>
<p>     <span style="color:#008000">// Subchunk1ID Contains the letters &quot;fmt &quot; (0x666d7420 big-endian form).</span><br />     stream.<span style="color:#008b8b">Write</span>(encoding.<span style="color:#008b8b">GetBytes</span>(<span style="color:#a31515">&quot;fmt &quot;</span>), 0, 4);</p>
<p>     <span style="color:#008000">// Subchunk1Size 16 for PCM.  This is the size of therest of the Subchunk which follows this number.</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>(16), 0, 4);</p>
<p>     <span style="color:#008000">// AudioFormat PCM = 1 (i.e. Linear quantization) Values other than 1 indicate some form of compression.</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>((<span style="color:#0000ff">short</span>)1), 0, 2);</p>
<p>     <span style="color:#008000">// NumChannels Mono = 1, Stereo = 2, etc.</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>((<span style="color:#0000ff">short</span>)1), 0, 2);</p>
<p>     <span style="color:#008000">// SampleRate 8000, 44100, etc.</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>(sampleRate), 0, 4);</p>
<p>     <span style="color:#008000">// ByteRate =  SampleRate * NumChannels * BitsPerSample/8</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>(sampleRate * <span style="color:#800080">bytesPerSample</span>), 0, 4);</p>
<p>     <span style="color:#008000">// BlockAlign NumChannels * BitsPerSample/8 The number of bytes for one sample including all channels.</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>((<span style="color:#0000ff">short</span>)(<span style="color:#800080">bytesPerSample</span>)), 0, 2);</p>
<p>     <span style="color:#008000">// BitsPerSample    8 bits = 8, 16 bits = 16, etc.</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>((<span style="color:#0000ff">short</span>)(<span style="color:#800080">bitsPerSample</span>)), 0, 2);</p>
<p>     <span style="color:#008000">// Subchunk2ID Contains the letters &quot;data&quot; (0x64617461 big-endian form).</span><br />     stream.<span style="color:#008b8b">Write</span>(encoding.<span style="color:#008b8b">GetBytes</span>(<span style="color:#a31515">&quot;data&quot;</span>), 0, 4);<br />     <br />     <span style="color:#008000">// </span><span style="color:#00008b">NOTE to be filled in later</span><br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>(0), 0, 4);<br /> }</p>
<p> <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">UpdateWavHeader</span>(<span style="color:#00008b">Stream</span> stream)<br /> {<br />     <span style="color:#0000ff">if</span> (!stream.<span style="color:#800080">CanSeek</span>) <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#00008b">Exception</span>(<span style="color:#a31515">&quot;Can&#39;t seek stream to update wav header&quot;</span>);</p>
<p>     <span style="color:#0000ff">var</span> oldPos = stream.<span style="color:#800080">Position</span>;</p>
<p>     <span style="color:#008000">// ChunkSize  36 + SubChunk2Size</span><br />     stream.<span style="color:#008b8b">Seek</span>(4, <span style="color:#00008b">SeekOrigin</span>.<span style="color:#800080">Begin</span>);<br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>((<span style="color:#0000ff">int</span>)stream.<span style="color:#800080">Length</span> - 8), 0, 4);</p>
<p>     <span style="color:#008000">// Subchunk2Size == NumSamples * NumChannels * BitsPerSample/8 This is the number of bytes in the data.</span><br />     stream.<span style="color:#008b8b">Seek</span>(40, <span style="color:#00008b">SeekOrigin</span>.<span style="color:#800080">Begin</span>);<br />     stream.<span style="color:#008b8b">Write</span>(<span style="color:#00008b">BitConverter</span>.<span style="color:#008b8b">GetBytes</span>((<span style="color:#0000ff">int</span>)stream.<span style="color:#800080">Length</span> - 44), 0, 4);</p>
<p>     stream.<span style="color:#008b8b">Seek</span>(oldPos, <span style="color:#00008b">SeekOrigin</span>.<span style="color:#800080">Begin</span>);<br /> }</div>
</p></div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Windows Phone 7 Watermark on PasswordBox</title>
		<link>http://damianblog.com/2011/01/21/wp7-password-watermark/</link>
		<comments>http://damianblog.com/2011/01/21/wp7-password-watermark/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 23:31:08 +0000</pubDate>
		<dc:creator>damian</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://damianblog.com/2011/01/21/wp7-password-watermark/</guid>
		<description><![CDATA[For my textboxes I’ve been using a modified version Johan Danforth’s Watermark behaviour (binding the watermark text to a ViewModel property instead of hardcoding the text), but when I needed to do something similar for a PasswordBox I thought I was stuck. I’ve come up with an incredibly basic, simple solution that seems to work [...]]]></description>
			<content:encoded><![CDATA[<p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/3a1Zuz_5n6I?rel=0" frameborder="0" allowFullScreen></iframe>
<p>For my textboxes I’ve been using a modified version <a href="http://weblogs.asp.net/jdanforth/archive/2010/09/17/silverlight-watermark-textbox-behavior.aspx">Johan Danforth’s Watermark</a> behaviour (binding the watermark text to a ViewModel property instead of hardcoding the text), but when I needed to do something similar for a PasswordBox I thought I was stuck.</p>
<p>I’ve come up with an incredibly basic, simple solution that seems to work well. Instead of just having a PasswordBox, I also have a TextBox <strong>behind</strong> it which I make invisible when the PasswordBox has content, or has focus.&#160; Because the watermark TextBox is behind the PasswordBox, it never gets focus: it is purely visual.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f914b246-537f-47d2-9523-368d515e78dd" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">&lt;</span><span style="color:#00008b">Grid</span><span style="color:#0000ff">&gt;</span><br />     <span style="color:#0000ff">&lt;</span><span style="color:#00008b">TextBox</span><span style="color:#ff0000"> </span><span style="color:#800080">x</span><span style="color:#0000ff">:</span><span style="color:#00008b">Name</span><span style="color:#0000ff">=&quot;</span><span style="color:#800080">PasswordWatermark</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#800080">TextWrapping</span><span style="color:#0000ff">=&quot;</span><span style="color:#800080">Wrap</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#800080">Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#00008b">Binding</span><span style="color:#ff0000"> </span><span style="color:#800080">Labels</span><span style="color:#0000ff">.</span><span style="color:#800080">password</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> </span><span style="color:#800080">Mode</span><span style="color:#0000ff">=</span><span style="color:#800080">OneTime}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#800080">Foreground</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> PhoneTextBoxReadOnlyBrush}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#800080">IsHitTestVisible</span><span style="color:#0000ff">=&quot;False&quot;/&gt;</span><br />     <span style="color:#0000ff">&lt;</span><span style="color:#00008b">PasswordBox</span><span style="color:#ff0000"> </span><span style="color:#800080">x</span><span style="color:#0000ff">:</span><span style="color:#00008b">Name</span><span style="color:#0000ff">=&quot;</span><span style="color:#800080">Password</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#ff00ff">LostFocus</span><span style="color:#0000ff">=&quot;</span><span style="color:#008b8b">PasswordLostFocus</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#800080">Opacity</span><span style="color:#0000ff">=&quot;0&quot;</span><span style="color:#ff0000"> </span><span style="color:#ff00ff">GotFocus</span><span style="color:#0000ff">=&quot;</span><span style="color:#008b8b">PasswordGotFocus</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> </span><span style="color:#800080">Password</span><span style="color:#0000ff">=&quot;{</span><span style="color:#00008b">Binding</span><span style="color:#ff0000"> </span><span style="color:#800080">Password</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> </span><span style="color:#800080">Mode</span><span style="color:#0000ff">=</span><span style="color:#800080">TwoWay}</span><span style="color:#0000ff">&quot;/&gt;</span><br /> <span style="color:#0000ff">&lt;/</span><span style="color:#00008b">Grid</span><span style="color:#0000ff">&gt;</span></div>
</p></div>
</p></div>
<p>In the code-behind I hide/show the watermark TextBox and the PasswordBox as appropriate.&#160; Note that I show and hide them by changing their opacity, not by setting their visibility.&#160; </p>
<p>Because the PasswordBox is in front of the the watermark Textbox, when the user clicks in that area he always clicks on the PasswordBox, even if it is invisible.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:28118c84-7573-4e48-9dd1-912e7915bf0f" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">PasswordLostFocus</span>(<span style="color:#0000ff">object</span> sender, <span style="color:#00008b">RoutedEventArgs</span> e)</li>
<li style="background: #f3f3f3">{</li>
<li>    <span style="color:#008b8b">CheckPasswordWatermark</span>();</li>
<li style="background: #f3f3f3">}</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">CheckPasswordWatermark</span>()</li>
<li>{</li>
<li style="background: #f3f3f3">    <span style="color:#0000ff">var</span> passwordEmpty = <span style="color:#0000ff">string</span>.<span style="color:#008b8b">IsNullOrEmpty</span>(<span style="color:#800080">Password</span>.<span style="color:#800080">Password</span>);</li>
<li>    <span style="color:#800080">PasswordWatermark</span>.<span style="color:#800080">Opacity</span> = passwordEmpty ? 100 : 0;</li>
<li style="background: #f3f3f3">    <span style="color:#800080">Password</span>.<span style="color:#800080">Opacity</span> = passwordEmpty ? 0 : 100;</li>
<li>}</li>
<li style="background: #f3f3f3">&nbsp;</li>
<li><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> <span style="color:#008b8b">PasswordGotFocus</span>(<span style="color:#0000ff">object</span> sender, <span style="color:#00008b">RoutedEventArgs</span> e)</li>
<li style="background: #f3f3f3">{</li>
<li>    <span style="color:#800080">PasswordWatermark</span>.<span style="color:#800080">Opacity</span> = 0;</li>
<li style="background: #f3f3f3">    <span style="color:#800080">Password</span>.<span style="color:#800080">Opacity</span> = 100;</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<p>When populating the PasswordBox, you can call CheckPasswordWatermark() to show/hide the watermark as appropriate.</p>
]]></content:encoded>
			<wfw:commentRss>http://damianblog.com/2011/01/21/wp7-password-watermark/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

