<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns: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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Comyoucom</title>
	
	<link>http://www.comyoucom.com</link>
	<description />
	<lastBuildDate>Sun, 18 Nov 2012 18:40:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/comyoucom" /><feedburner:info uri="comyoucom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>comyoucom</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Windows Phone 8 SDK Available</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/zMg5rGQ32iA/</link>
		<comments>http://www.comyoucom.com/windows-phone-8-sdk-available/#comments</comments>
		<pubDate>Wed, 31 Oct 2012 13:02:09 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Windows Phone 8]]></category>
		<category><![CDATA[Windows 8 Phone]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=254</guid>
		<description><![CDATA[Yesterday the SDK for Windows Phone 8 was finally announced at Build 2012. It shares part of the code-base with Windows 8, and the SDK is pretty similar with the Windows 8 one. This is good news for developers, since it will be pretty easy to migrate Windows Phone Apps...]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/10/Family3_thumb_48D531AF.png" alt="Windows 8 Phone" title="Windows 8 Phone" width="620" height="367" class="aligncenter size-full wp-image-255" /></p>
<p>Yesterday the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=35471" target="_blank">SDK for Windows Phone 8</a> was finally announced at <a href="http://www.buildwindows.com" target="_blank">Build 2012</a>. It shares part of the code-base with Windows 8, and the SDK is pretty similar with the Windows 8 one. This is good news for developers, since it will be pretty easy to migrate Windows Phone Apps to Windows Store Apps and vice versa.</p>
<p>As an individual developer you can <strong>register to develop apps for Windows Phone for only $8 before the 7th of November</strong>.</p>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/windows-phone-8-sdk-available/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-8-sdk-available%2F&amp;text=Windows+Phone+8+SDK+Available&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/windows-phone-8-sdk-available/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-8-sdk-available%2F&amp;name=Windows+Phone+8+SDK+Available" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-8-sdk-available%2F&amp;title=Windows+Phone+8+SDK+Available" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-8-sdk-available%2F&amp;title=Windows+Phone+8+SDK+Available" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/zMg5rGQ32iA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/windows-phone-8-sdk-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/windows-phone-8-sdk-available/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=windows-phone-8-sdk-available</feedburner:origLink></item>
		<item>
		<title>App Bar icons for Windows 8 Metro</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/-z_ZnKhHCSM/</link>
		<comments>http://www.comyoucom.com/app-bar-icons-for-windows-8-metro/#comments</comments>
		<pubDate>Fri, 06 Jul 2012 10:17:10 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Windows 8 Metro]]></category>
		<category><![CDATA[appbar]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[Windows 8]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=242</guid>
		<description><![CDATA[These are the icons available by default for the App Bar: Share]]></description>
			<content:encoded><![CDATA[<p>These are the icons available by default for the App Bar:</p>
<div id="attachment_243" class="wp-caption alignnone" style="width: 568px"><a href="http://www.comyoucom.com/wp-content/uploads/2012/07/app_bar_icons.png"><img src="http://www.comyoucom.com/wp-content/uploads/2012/07/app_bar_icons-1024x501.png" alt="" title="app_bar_icons" width="558" height="273" class="size-large wp-image-243" /></a>
<p class="wp-caption-text">Click to see a large version of the image.</p>
</div>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/app-bar-icons-for-windows-8-metro/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-bar-icons-for-windows-8-metro%2F&amp;text=App+Bar+icons+for+Windows+8+Metro&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/app-bar-icons-for-windows-8-metro/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-bar-icons-for-windows-8-metro%2F&amp;name=App+Bar+icons+for+Windows+8+Metro" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-bar-icons-for-windows-8-metro%2F&amp;title=App+Bar+icons+for+Windows+8+Metro" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-bar-icons-for-windows-8-metro%2F&amp;title=App+Bar+icons+for+Windows+8+Metro" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/-z_ZnKhHCSM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/app-bar-icons-for-windows-8-metro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/app-bar-icons-for-windows-8-metro/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=app-bar-icons-for-windows-8-metro</feedburner:origLink></item>
		<item>
		<title>App Settings in Windows 8 WinRT using Callisto</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/EOz9EdQY56k/</link>
		<comments>http://www.comyoucom.com/app-settings-in-windows-8-winrt-using-callisto/#comments</comments>
		<pubDate>Mon, 02 Jul 2012 18:22:42 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Windows 8 Metro]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Callisto]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Settings]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[WinRT]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=218</guid>
		<description><![CDATA[As I am currently working in a Windows 8 Metro app, I needed to implement several Settings Flyouts. I didn&#8217;t want to reinvent the wheel, so I decided to use Callisto toolkit. 1. Installing Callisto from NuGet: Right click in your project -> Manage NuGet Packages&#8230; 2. Adding custom settings...]]></description>
			<content:encoded><![CDATA[<p>As I am currently working in a Windows 8 Metro app, I needed to implement several <a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh770544.aspx">Settings Flyouts</a>. I didn&#8217;t want to reinvent the wheel, so I decided to use <a href="https://github.com/timheuer/Callisto">Callisto toolkit</a>.</p>
<h3>1. Installing Callisto from NuGet:</h3>
<p>Right click in your project -> Manage NuGet Packages&#8230;</p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/07/callisto.png" alt="" title="callisto" width="604" height="405" class="alignleft size-full wp-image-222" /></p>
<h3>2. Adding custom settings to your App:</h3>
<p>As I am using the same settings menu in the whole app, I can register it in my Application class. In the <strong>App Class</strong>:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnLaunched<span style="color: #008000;">&#40;</span>LaunchActivatedEventArgs args<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Do not repeat app initialization when already running, just ensure that</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// the window is active</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">PreviousExecutionState</span> <span style="color: #008000;">==</span> ApplicationExecutionState<span style="color: #008000;">.</span><span style="color: #0000FF;">Running</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Window<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Activate</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Settings</span><br />
&nbsp; &nbsp; SettingsPane<span style="color: #008000;">.</span><span style="color: #0000FF;">GetForCurrentView</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CommandsRequested</span> <span style="color: #008000;">+=</span> Settings_CommandsRequested<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Etcetera</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>I need to implement an Event Handler to provide the OS with my new Settings menu items.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Settings_CommandsRequested<span style="color: #008000;">&#40;</span>SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Settings Wide</span><br />
&nbsp; &nbsp; SettingsCommand settingsw <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SettingsCommand<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;SettingsW&quot;</span>, <span style="color: #666666;">&quot;Settings Wide&quot;</span>, <span style="color: #008000;">&#40;</span>x<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SettingsFlyout settings <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SettingsFlyout<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; settings<span style="color: #008000;">.</span><span style="color: #0000FF;">FlyoutWidth</span> <span style="color: #008000;">=</span> Callisto<span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SettingsFlyout</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SettingsFlyoutWidth</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Wide</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; settings<span style="color: #008000;">.</span><span style="color: #0000FF;">HeaderText</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Settings Wide&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; settings<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span> <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CallistoSettings<span style="color: #008000;">.</span><span style="color: #0000FF;">SettingsViews</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SettingsWide</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; settings<span style="color: #008000;">.</span><span style="color: #0000FF;">IsOpen</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; args<span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ApplicationCommands</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>settingsw<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>As you can notice in the code, the <strong>Content </strong>is a User Control. So I can edit it in Blend, and it&#8217;s much easier to make it look nice.</p>
<h3><a href='http://www.comyoucom.com/wp-content/uploads/2012/07/CallistoSettings.zip'>Download sample source code</a></h3>
<p><strong>Some screen-shoots:</strong></p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/07/settings.png" alt="" title="settings" width="321" height="387" class="alignnone size-full wp-image-223" /><br />
<img src="http://www.comyoucom.com/wp-content/uploads/2012/07/narrow.png" alt="" title="narrow" width="357" height="498" class="alignnone size-full wp-image-226" /><br />
<img src="http://www.comyoucom.com/wp-content/uploads/2012/07/about.png" alt="" title="about" width="361" height="394" class="alignnone size-full wp-image-225" /><br />
<img src="http://www.comyoucom.com/wp-content/uploads/2012/07/wide.png" alt="" title="wide" width="400" class="alignnone size-full wp-image-224" /></p>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/app-settings-in-windows-8-winrt-using-callisto/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-settings-in-windows-8-winrt-using-callisto%2F&amp;text=App+Settings+in+Windows+8+WinRT+using+Callisto&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/app-settings-in-windows-8-winrt-using-callisto/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-settings-in-windows-8-winrt-using-callisto%2F&amp;name=App+Settings+in+Windows+8+WinRT+using+Callisto" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-settings-in-windows-8-winrt-using-callisto%2F&amp;title=App+Settings+in+Windows+8+WinRT+using+Callisto" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fapp-settings-in-windows-8-winrt-using-callisto%2F&amp;title=App+Settings+in+Windows+8+WinRT+using+Callisto" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/EOz9EdQY56k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/app-settings-in-windows-8-winrt-using-callisto/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/app-settings-in-windows-8-winrt-using-callisto/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=app-settings-in-windows-8-winrt-using-callisto</feedburner:origLink></item>
		<item>
		<title>Implementing a custom DataTemplateSelector in WinRT</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/LDcUr09PNpw/</link>
		<comments>http://www.comyoucom.com/implementing-a-custom-datatemplateselector-in-winrt/#comments</comments>
		<pubDate>Tue, 26 Jun 2012 14:23:47 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Windows 8 Metro]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=205</guid>
		<description><![CDATA[In one of the projects that I am currently working on I needed to implement this. I needed this because I am using the ItemsControlto display a list of Items. The problem that I had is that I have several type of objects in my list, and I wanted to...]]></description>
			<content:encoded><![CDATA[<p>In one of the projects that I am currently working on I needed to implement this. I needed this because I am using the <strong>ItemsControl</strong>to display a list of Items. The problem that I had is that I have several type of objects in my list, and I wanted to use a different template for each of them.</p>
<h2>1. Markup for a standard ItemsControl</h2>
<p>- Define the DataTemplate as a static resource:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Page.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DataTemplate</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;TempA&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Border</span> <span style="color: #000066;">Background</span>=<span style="color: #ff0000;">&quot;Red&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Title}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Border<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Page.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>- Declare your Items Control to use the Data Template:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemsControl</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;items&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ItemsSource</span>=<span style="color: #ff0000;">&quot;{Binding Items}&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ItemsTemplate</span>=<span style="color: #ff0000;">&quot;{StaticResource TempA}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></div>
<h2>2. Implement a DataTemplateSelector to use several Templates in an ItemsControl</h2>
<p>- Implement the selector to use a different template based in the object type:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ItemsTemplateSelector <span style="color: #008000;">:</span> DataTemplateSelector<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> DataTemplate TemplateA <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> DataTemplate TemplateB <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> DataTemplate SelectTemplateCore<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> item, DependencyObject container<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>item <a href="http://www.google.com/search?q=is+msdn.microsoft.com"><span style="color: #008000;">is</span></a> ObjectTypeA<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> TemplateA<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>item <a href="http://www.google.com/search?q=is+msdn.microsoft.com"><span style="color: #008000;">is</span></a> ObjectTypeB<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> TemplateB<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SelectTemplate</span><span style="color: #008000;">&#40;</span>item, container<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>- Declare your DataTemplates in Resources</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Page.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DataTemplate</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;TempA&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Border</span> <span style="color: #000066;">Background</span>=<span style="color: #ff0000;">&quot;Red&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Title}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Border<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DataTemplate</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;TempB&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Border</span> <span style="color: #000066;">Background</span>=<span style="color: #ff0000;">&quot;Blue&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Title}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Border<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Page.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>- Declare your DataTemplateSelector in Resources</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;views:ItemsTemplateSelector</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;itemsTemplateSelector&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">TemplateA</span>=<span style="color: #ff0000;">&quot;{StaticResource TempA}&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">TemplateB</span>=<span style="color: #ff0000;">&quot;{StaticResource TempB}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></div>
<p>- Update the ItemsControl to use your DataTemplateSelector</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemsControl</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;items&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ItemsSource</span>=<span style="color: #ff0000;">&quot;{Binding Items}&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ItemTemplateSelector</span>=<span style="color: #ff0000;">&quot;{StaticResource itemsTemplateSelector}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></div>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/implementing-a-custom-datatemplateselector-in-winrt/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fimplementing-a-custom-datatemplateselector-in-winrt%2F&amp;text=Implementing+a+custom+DataTemplateSelector+in+WinRT&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/implementing-a-custom-datatemplateselector-in-winrt/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fimplementing-a-custom-datatemplateselector-in-winrt%2F&amp;name=Implementing+a+custom+DataTemplateSelector+in+WinRT" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fimplementing-a-custom-datatemplateselector-in-winrt%2F&amp;title=Implementing+a+custom+DataTemplateSelector+in+WinRT" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fimplementing-a-custom-datatemplateselector-in-winrt%2F&amp;title=Implementing+a+custom+DataTemplateSelector+in+WinRT" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/LDcUr09PNpw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/implementing-a-custom-datatemplateselector-in-winrt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/implementing-a-custom-datatemplateselector-in-winrt/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=implementing-a-custom-datatemplateselector-in-winrt</feedburner:origLink></item>
		<item>
		<title>Search contract in Windows 8 Metro</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/eJJgEm-PMXE/</link>
		<comments>http://www.comyoucom.com/search-contract-in-windows-8-metro/#comments</comments>
		<pubDate>Thu, 21 Jun 2012 20:00:26 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Windows 8 Metro]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[contracts]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[WinRT]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=179</guid>
		<description><![CDATA[This is a functionality that many apps will need, and the OS is making it very easy to integrate. Metro introduces the concept of Contracts, they are like interfaces to indicate the OS that our app can perform certain functionalities (Search / Share / File Picker). This post will focus...]]></description>
			<content:encoded><![CDATA[<p>This is a functionality that many apps will need, and the OS is making it very easy to integrate. Metro introduces the concept of <strong>Contracts</strong>, they are like interfaces to indicate the OS that our app can perform certain functionalities (Search / Share / File Picker). This post will focus on integrating <strong>SEARCH</strong>.</p>
<p>1. Open your project in Visual Studio 2012, open the App Manifest (Package.appxmanifest). Under the tab &#8220;Declarations&#8221; add Search. </p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/06/1.jpg" alt="" title="App Manifest" width="507" height="382" class="alignnone size-full wp-image-182" /></p>
<p>2. Declare the Search Pane in your App class. If you want to provide search suggestions, also declare the array in the App class.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">sealed</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> App <span style="color: #008000;">:</span> Application<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> SearchPane searchPane<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> suggestionList<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> App<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InitializeComponent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Suspending</span> <span style="color: #008000;">+=</span> OnSuspending<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> async <span style="color: #6666cc; font-weight: bold;">void</span> OnLaunched<span style="color: #008000;">&#40;</span>LaunchActivatedEventArgs args<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Do not repeat app initialization when already running, just ensure that</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// the window is active</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">PreviousExecutionState</span> <span style="color: #008000;">==</span> ApplicationExecutionState<span style="color: #008000;">.</span><span style="color: #0000FF;">Running</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Window<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Activate</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// SearchPane</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">searchPane</span> <span style="color: #008000;">=</span> SearchPane<span style="color: #008000;">.</span><span style="color: #0000FF;">GetForCurrentView</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Suggestion list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; suggestionList <span style="color: #008000;">=</span> DataService<span style="color: #008000;">.</span><span style="color: #0000FF;">GetSearchSuggestions</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; searchPane<span style="color: #008000;">.</span><span style="color: #0000FF;">SuggestionsRequested</span> <span style="color: #008000;">+=</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> TypedEventHandler<span style="color: #008000;">&lt;</span>SearchPane, SearchPaneSuggestionsRequestedEventArgs<span style="color: #008000;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#40;</span>OnSearchPaneSuggestionsRequested<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/* Continue with the window initialization */</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>3. Add the method to provide the search suggestions to the search pane (For simplicity in this sample it is done in the App class too)</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnSearchPaneSuggestionsRequested<span style="color: #008000;">&#40;</span>SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; var queryText <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">QueryText</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>queryText<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; var request <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> suggestion <span style="color: #0600FF; font-weight: bold;">in</span> suggestionList<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>suggestion<span style="color: #008000;">.</span><span style="color: #0000FF;">StartsWith</span><span style="color: #008000;">&#40;</span>queryText, StringComparison<span style="color: #008000;">.</span><span style="color: #0000FF;">CurrentCultureIgnoreCase</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Add suggestion to Search Pane</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request<span style="color: #008000;">.</span><span style="color: #0000FF;">SearchSuggestionCollection</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AppendQuerySuggestion</span><span style="color: #008000;">&#40;</span>suggestion<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Break since the Search Pane can show at most 5 suggestions</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>request<span style="color: #008000;">.</span><span style="color: #0000FF;">SearchSuggestionCollection</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Size</span> <span style="color: #008000;">&gt;=</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>4. Now we need a UI to display the search results. Visual Studio has a template.<br />
This action will also add the method <strong>OnSearchActivated</strong> to the App class to declare the Search Contract, indicating to Windows 8 that our app allows Searching.</p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/06/2.jpg" alt="" title="Search template from VS2012" width="600" height="418" class="alignleft size-full wp-image-184" /></p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
<span style="color: #008080; font-style: italic;">/// Invoked when the application is activated to display search results.</span><br />
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
<span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;args&quot;&gt;Details about the activation request.&lt;/param&gt;</span><br />
<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnSearchActivated<span style="color: #008000;">&#40;</span>Windows<span style="color: #008000;">.</span><span style="color: #0000FF;">ApplicationModel</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Activation</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SearchActivatedEventArgs</span> args<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; App1<span style="color: #008000;">.</span><span style="color: #0000FF;">SearchResultsPage1</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Activate</span><span style="color: #008000;">&#40;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">QueryText</span>, args<span style="color: #008000;">.</span><span style="color: #0000FF;">PreviousExecutionState</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>5. Implement your search functionality and provide the results to the Search Results view:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> LoadState<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">Object</span> navigationParameter, Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">String</span>, <span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&gt;</span> pageState<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; var queryText <span style="color: #008000;">=</span> navigationParameter <span style="color: #0600FF; font-weight: bold;">as</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// TODO: Application-specific searching logic. &nbsp;The search process is responsible for</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp; &nbsp; &nbsp; creating a list of user-selectable result categories:</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp; &nbsp; &nbsp; filterList.Add(new Filter(&quot;&lt;filter name&gt;&quot;, &lt;result count&gt;));</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp; &nbsp; &nbsp; Only the first filter, typically &quot;All&quot;, should pass true as a third argument in</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp; &nbsp; &nbsp; order to start in an active state. &nbsp;Results for the active filter are provided</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp; &nbsp; &nbsp; in Filter_SelectionChanged below.</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// TODO: Add your results</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DefaultViewModel</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Results&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>SearchResult<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SearchResult<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Result 1&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Subtitle <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Subtitl&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Description <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Description&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Image <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; var filterList <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>Filter<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; filterList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Filter<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;All&quot;</span>, <span style="color: #FF0000;">0</span>, <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Communicate results through the view model</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DefaultViewModel</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;QueryText&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">'<span style="color: #008080; font-weight: bold;">\u</span>201c'</span> <span style="color: #008000;">+</span> queryText <span style="color: #008000;">+</span> <span style="color: #666666;">'<span style="color: #008080; font-weight: bold;">\u</span>201d'</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DefaultViewModel</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;CanGoBack&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span>_previousContent <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DefaultViewModel</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Filters&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> filterList<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DefaultViewModel</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;ShowFilters&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> filterList<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>6. Use the search pane, and you will get a list of suggestions as well.</p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/06/3.png" alt="" title="Search Pane" width="605" height="595" class="alignone size-full wp-image-183" /></p>
<p>7. Search results (Not implemented):</p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/06/4-1024x279.png" alt="" title="Search Results" width="620" height="168" class="alignleft size-large wp-image-195" /></p>
<p>Good luck!</p>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/search-contract-in-windows-8-metro/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fsearch-contract-in-windows-8-metro%2F&amp;text=Search+contract+in+Windows+8+Metro&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/search-contract-in-windows-8-metro/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fsearch-contract-in-windows-8-metro%2F&amp;name=Search+contract+in+Windows+8+Metro" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fsearch-contract-in-windows-8-metro%2F&amp;title=Search+contract+in+Windows+8+Metro" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fsearch-contract-in-windows-8-metro%2F&amp;title=Search+contract+in+Windows+8+Metro" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/eJJgEm-PMXE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/search-contract-in-windows-8-metro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/search-contract-in-windows-8-metro/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=search-contract-in-windows-8-metro</feedburner:origLink></item>
		<item>
		<title>Using an existent SQLite database in a Windows 8 Metro app</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/MyCvrA2Uyj8/</link>
		<comments>http://www.comyoucom.com/using-an-existent-sqlite-database-in-a-windows-8-metro-app/#comments</comments>
		<pubDate>Mon, 11 Jun 2012 15:08:49 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Windows 8 Metro]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[WinRT]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=169</guid>
		<description><![CDATA[Currently I am working in an app for Windows 8 Metro, and I need to use a SQLite database. The steps to get it set up are not really straight forward, but Tim Heuer created a really good tutorial. He recommends to use a little wrapper (ORM), called sqlite-net available...]]></description>
			<content:encoded><![CDATA[<p>Currently I am working in an app for Windows 8 Metro, and I need to use a SQLite database. The steps to get it set up are not really straight forward, but <a href="http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx" title="Using SQLite in Windows 8 Metro">Tim Heuer created a really good tutorial</a>. He recommends to use a little wrapper (ORM), called <a href="https://github.com/praeclarum/sqlite-net">sqlite-net available in GitHub</a>. It works pretty well, but the main problem is that only supports databases auto-generated from your class model. That&#8217;s a problem for my use case, since the database that I need to use already exists. I need to create my own mappings. Ouch! For this reason <a href="https://github.com/pedropaf/sqlite-net">I forked the library in GitHub</a> to support custom mappings using two simple annotations:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">&#91;</span>MapToTable<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;StockTable&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Stock<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>MapToColumn<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;StockId&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>PrimaryKey, AutoIncrement<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>MapToColumn<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;StockSymbol&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>MaxLength<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">8</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Symbol <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>This class would try to use a table called &#8216;StockTable&#8217; and the columns would be: StockId, StockSymbol. It is a simple modification that works nicely for my needs. Enjoy it!</p>
<p>Feedback appreciated.</p>
<p><strong>Update:</strong> Now you don&#8217;t need to compile the Dll for SQLite for x86 and x64 WinRT, they are <a href="http://www.sqlite.org/download.html">available to download in the SQLite website</a>.</p>
<p><strong>Update 2: Now you don&#8217;t even need to reference any static DLL, you can just install SQLite as a Visual Studio 2012 extension and it will embed the right DLL depending on the architecture of the build. Reference: <a href="http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx" title="SQLite with windows 8">SQLite with windows 8</a>.</strong></p>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/using-an-existent-sqlite-database-in-a-windows-8-metro-app/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fusing-an-existent-sqlite-database-in-a-windows-8-metro-app%2F&amp;text=Using+an+existent+SQLite+database+in+a+Windows+8+Metro+app&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/using-an-existent-sqlite-database-in-a-windows-8-metro-app/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fusing-an-existent-sqlite-database-in-a-windows-8-metro-app%2F&amp;name=Using+an+existent+SQLite+database+in+a+Windows+8+Metro+app" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fusing-an-existent-sqlite-database-in-a-windows-8-metro-app%2F&amp;title=Using+an+existent+SQLite+database+in+a+Windows+8+Metro+app" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fusing-an-existent-sqlite-database-in-a-windows-8-metro-app%2F&amp;title=Using+an+existent+SQLite+database+in+a+Windows+8+Metro+app" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/MyCvrA2Uyj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/using-an-existent-sqlite-database-in-a-windows-8-metro-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/using-an-existent-sqlite-database-in-a-windows-8-metro-app/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-an-existent-sqlite-database-in-a-windows-8-metro-app</feedburner:origLink></item>
		<item>
		<title>Daylight for Windows Phone – Finally published</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/fOUiL_QumvY/</link>
		<comments>http://www.comyoucom.com/daylight-for-windows-phone-finally-published/#comments</comments>
		<pubDate>Wed, 30 May 2012 23:51:00 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Daylight]]></category>
		<category><![CDATA[Localisation]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=120</guid>
		<description><![CDATA[It has taken two rejections, but I am happy to announce that Daylight is available in the Windows Phone Marketplace. Here is a summary of some things learnt while developing it. 1. Make your life easy using open source libraries from NuGet Following the idea of not reinventing the wheel,...]]></description>
			<content:encoded><![CDATA[<p>It has taken two rejections, but I am happy to announce that <a href="http://windowsphone.com/s?appid=1e736e36-fd44-4c1a-be4e-057b395d6804">Daylight is available in the Windows Phone Marketplace</a>. Here is a summary of some things learnt while developing it.</p>
<h2>1. Make your life easy using open source libraries from NuGet</h2>
<p>Following the idea of not reinventing the wheel, this is the list of libraries used:</p>
<ul>
<li><a href="http://coding4fun.codeplex.com/">Coding4Fun</a>: Set of <strong>controls</strong> (progress overlay, toggle button, colour picker, etc.) and <strong>converters. </strong>Essential for any app.</li>
<li><a href="http://northernlights.codeplex.com/">Northern Lights WP7 Toolkit</a>: This is a library with a set of classes that will simplify the usage of Isolated Storage (persistent cache on the phone), asymmetric encryption, handling of errors sending a report via email, among other things.</li>
<li><a href="http://ylad.codeplex.com/">Your Last About Dialog</a>: To get your app certified by Microsoft you need to include information about the publisher, and a way to contact you. This library gives you that in a <a href="http://msdn.microsoft.com/en-us/library/ff941098(v=vs.92).aspx">Pivot control</a> and you only have to enter de data in a XML file. It supports <strong>localization</strong>.</li>
</ul>
<h2>2. Getting icons to use in the app</h2>
<p>There are many open source collections, but I like these 2:</p>
<p><strong><a href="http://metro.windowswiki.info/">Metro Icons</a></strong>: 130 icons from the Windows Phone 7 preview shown at the Mobile World Congress 2010 in Barcelona.</p>
<p><img class="size-medium wp-image-126 alignnone" title="metro icon pack" src="http://www.comyoucom.com/wp-content/uploads/2012/05/metro-icon-pack-241x300.png" alt="" width="241" height="300" /></p>
<p><strong><a href="http://templarian.com/project_windows_phone_icons/">Templarian Icons</a></strong>: a project started a few months ago to supply creative commons licensed icons to Windows Phone developers. Built specifically for Windows Phone and include vector icons. If you need an icon not included, just mention <strong>@Templarian</strong> on Twitter explaining the icon, and you&#8217;ll get it. Currently there are <strong>more than 600 icons</strong>.</p>
<p><img class="alignnone size-medium wp-image-127" title="Preview of Templarian Icons for Windows Phone 7" src="http://www.comyoucom.com/wp-content/uploads/2012/05/Snap-2012-05-25-at-21.09.05-300x188.png" alt="" width="300" height="188" /></p>
<h2>3. Using Location Services and getting your app certified</h2>
<p>Another requirement by Microsoft to get your app certified when using <strong>Location Services</strong>, is to include a <strong>Privacy Policy</strong> in your app. You also need to let the user disable Location Services from your app.</p>
<p>This is the reason why this app needed a <strong>Settings</strong> section:</p>
<p><img class="alignnone size-medium wp-image-133" title="sett" src="http://www.comyoucom.com/wp-content/uploads/2012/05/sett-180x300.png" alt="" width="180" height="300" /></p>
<p>The correspondent XAML for this is:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;LayoutRoot&quot;</span> <span style="color: #000066;">Background</span>=<span style="color: #ff0000;">&quot;Transparent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid.RowDefinitions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;RowDefinition</span> <span style="color: #000066;">Height</span>=<span style="color: #ff0000;">&quot;Auto&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;RowDefinition</span> <span style="color: #000066;">Height</span>=<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid.RowDefinitions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;StackPanel</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;TitlePanel&quot;</span> <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;12,17,0,28&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;ApplicationTitle&quot;</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Daylight&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">Style</span>=<span style="color: #ff0000;">&quot;{StaticResource PhoneTextNormalStyle}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;PageTitle&quot;</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Settings&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;9,-7,0,0&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">Style</span>=<span style="color: #ff0000;">&quot;{StaticResource PhoneTextTitle1Style}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/StackPanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;StackPanel</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;ContentPanel&quot;</span> <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;12,0,12,0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;toolkit:ToggleSwitch</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;Location&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;EnableLocation&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">Checked</span>=<span style="color: #ff0000;">&quot;EnableLocation_Checked&quot;</span> <span style="color: #000066;">Unchecked</span>=<span style="color: #ff0000;">&quot;EnableLocation_Unchecked&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Privacy policy ....&quot;</span> <span style="color: #000066;">TextWrapping</span>=<span style="color: #ff0000;">&quot;Wrap&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Tap</span>=<span style="color: #ff0000;">&quot;EnableLocation_Contact&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;0 10 0 0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Underline<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;Run</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Email Us&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/Underline<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextBlock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/StackPanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>The code behind, not using MVVM for simplicity in this example:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> Settings <span style="color: #008000;">:</span> PhoneApplicationPage<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> Settings<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>NorthernLights<span style="color: #008000;">.</span><span style="color: #0000FF;">PersistentVariables</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Get</span><span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">?&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;enableLocation&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EnableLocation<span style="color: #008000;">.</span><span style="color: #0000FF;">IsChecked</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EnableLocation<span style="color: #008000;">.</span><span style="color: #0000FF;">IsChecked</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EnableLocation<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span> <span style="color: #008000;">=</span> Localization<span style="color: #008000;">.</span><span style="color: #0000FF;">AppResources</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Off</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> EnableLocation_Checked<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, RoutedEventArgs e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NorthernLights<span style="color: #008000;">.</span><span style="color: #0000FF;">PersistentVariables</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Set</span><span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">?&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;enableLocation&quot;</span>, <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> EnableLocation_Unchecked<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, RoutedEventArgs e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NorthernLights<span style="color: #008000;">.</span><span style="color: #0000FF;">PersistentVariables</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Set</span><span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">?&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;enableLocation&quot;</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> EnableLocation_Contact<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Windows</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Input</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GestureEventArgs</span> e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> EmailComposeTask<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Subject <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Privacy Question&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Body <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Daylight&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;email@comyoucom.com&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<h2>4. Localising your app</h2>
<p>Daylight is currently available in English and Spanish. The first thing that I&#8217;d recommend you to read if you are planning to localize your app is to follow the <a href="http://msdn.microsoft.com/en-us/library/ff967552(v=vs.92).aspx">Best practices for Windows Phone</a>. To set up your app to support localization, you can follow the <a href="http://msdn.microsoft.com/en-us/library/ff637520(v=vs.92).aspx">official documentation</a>, or this good tutorial from <a href="http://windowsphonegeek.com/articles/Localizing-a-Windows-Phone-app-Step-by-Step">windows phone geek</a>.</p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/05/Screenshoot.new_.1-180x300.png" alt="" title="Main in english" width="180" height="300" class="alignleft size-medium wp-image-146" /><img src="http://www.comyoucom.com/wp-content/uploads/2012/05/Screenshoot.new_.1.es_-180x300.png" alt="" title="Main in spanish" width="180" height="300" class="alignnone size-medium wp-image-147" /></p>
<h2>5. Make sure that your app works with the Dark and Light themes</h2>
<p>By default Windows Phone supports two colour themes: dark (black background) and light (white background). Your app must work when the phone is set up to use any of those. You are not obligated to have two colour themes in your app too, but it&#8217;s a nice to have. In order to achieve that, instead using hard-coded styles, you could use the <a href="http://msdn.microsoft.com/en-us/library/ff769552(v=vs.92).aspx">styles that are defined in the phone already</a>.</p>
<p><img src="http://www.comyoucom.com/wp-content/uploads/2012/05/Screenshoot.new_.3-180x300.png" alt="" title="Daylight on light theme" width="180" height="300" class="alignnone size-medium wp-image-159" /></p>
<h3><a href="http://windowsphone.com/s?appid=1e736e36-fd44-4c1a-be4e-057b395d6804">Download Daylight</a></h3>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/daylight-for-windows-phone-finally-published/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fdaylight-for-windows-phone-finally-published%2F&amp;text=Daylight+for+Windows+Phone+%E2%80%93+Finally+published&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/daylight-for-windows-phone-finally-published/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fdaylight-for-windows-phone-finally-published%2F&amp;name=Daylight+for+Windows+Phone+%E2%80%93+Finally+published" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fdaylight-for-windows-phone-finally-published%2F&amp;title=Daylight+for+Windows+Phone+%E2%80%93+Finally+published" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fdaylight-for-windows-phone-finally-published%2F&amp;title=Daylight+for+Windows+Phone+%E2%80%93+Finally+published" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/fOUiL_QumvY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/daylight-for-windows-phone-finally-published/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/daylight-for-windows-phone-finally-published/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=daylight-for-windows-phone-finally-published</feedburner:origLink></item>
		<item>
		<title>Image resize: squared thumbnail in C#</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/16TWaFBGsrI/</link>
		<comments>http://www.comyoucom.com/image-resize-squared-thumbnail-in-c/#comments</comments>
		<pubDate>Thu, 24 May 2012 14:31:13 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=57</guid>
		<description><![CDATA[This is a code snippet that I use and reuse in many projects, I thought that it&#8217;d be useful to publish it. private static bool ResizeSquaredBitmapAndSave&#40;Bitmap bitmap, string destImage, int squaredImageSize&#41; &#123; &#160; &#160; float originalImageWidth = bitmap.Width; &#160; &#160; float originalImageHeight = bitmap.Height; &#160; &#160; int tempHeight = squaredImageSize;...]]></description>
			<content:encoded><![CDATA[<p>This is a code snippet that I use and reuse in many projects, I thought that it&#8217;d be useful to publish it.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> ResizeSquaredBitmapAndSave<span style="color: #008000;">&#40;</span>Bitmap bitmap, <span style="color: #6666cc; font-weight: bold;">string</span> destImage, <span style="color: #6666cc; font-weight: bold;">int</span> squaredImageSize<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">float</span> originalImageWidth <span style="color: #008000;">=</span> bitmap<span style="color: #008000;">.</span><span style="color: #0000FF;">Width</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">float</span> originalImageHeight <span style="color: #008000;">=</span> bitmap<span style="color: #008000;">.</span><span style="color: #0000FF;">Height</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">int</span> tempHeight <span style="color: #008000;">=</span> squaredImageSize<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">int</span> tempWidth <span style="color: #008000;">=</span> squaredImageSize<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">int</span> x_offset <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">int</span> y_offset <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Landscape</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>originalImageWidth <span style="color: #008000;">&gt;=</span> originalImageHeight<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tempWidth <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">float</span><span style="color: #008000;">&#41;</span>squaredImageSize <span style="color: #008000;">*</span> <span style="color: #008000;">&#40;</span>originalImageWidth <span style="color: #008000;">/</span> originalImageHeight<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x_offset <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>tempWidth <span style="color: #008000;">-</span> squaredImageSize<span style="color: #008000;">&#41;</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Portrait</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>originalImageHeight <span style="color: #008000;">&gt;</span> originalImageWidth<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tempHeight <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">float</span><span style="color: #008000;">&#41;</span>squaredImageSize <span style="color: #008000;">*</span> <span style="color: #008000;">&#40;</span>originalImageHeight <span style="color: #008000;">/</span> originalImageWidth<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; y_offset <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>tempHeight <span style="color: #008000;">-</span> squaredImageSize<span style="color: #008000;">&#41;</span> <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; Bitmap thumbnail <span style="color: #008000;">=</span> ResizeBitmap<span style="color: #008000;">&#40;</span>bitmap, <span style="color: #008000;">-</span>x_offset, <span style="color: #008000;">-</span>y_offset,<br />
&nbsp; &nbsp; &nbsp; &nbsp; tempWidth, tempHeight, squaredImageSize, squaredImageSize, Color<span style="color: #008000;">.</span><span style="color: #0000FF;">Transparent</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>thumbnail <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thumbnail<span style="color: #008000;">.</span><span style="color: #0000FF;">Save</span><span style="color: #008000;">&#40;</span>destImage, ImageFormat<span style="color: #008000;">.</span><span style="color: #0000FF;">Png</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thumbnail<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/image-resize-squared-thumbnail-in-c/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fimage-resize-squared-thumbnail-in-c%2F&amp;text=Image+resize%3A+squared+thumbnail+in+C%23&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/image-resize-squared-thumbnail-in-c/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fimage-resize-squared-thumbnail-in-c%2F&amp;name=Image+resize%3A+squared+thumbnail+in+C%23" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fimage-resize-squared-thumbnail-in-c%2F&amp;title=Image+resize%3A+squared+thumbnail+in+C%23" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fimage-resize-squared-thumbnail-in-c%2F&amp;title=Image+resize%3A+squared+thumbnail+in+C%23" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/16TWaFBGsrI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/image-resize-squared-thumbnail-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/image-resize-squared-thumbnail-in-c/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=image-resize-squared-thumbnail-in-c</feedburner:origLink></item>
		<item>
		<title>Windows phone: Loading overlay</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/K4s2f1AeId4/</link>
		<comments>http://www.comyoucom.com/windows-phone-loading-overlay/#comments</comments>
		<pubDate>Mon, 14 May 2012 11:29:34 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Coding4Fun]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=99</guid>
		<description><![CDATA[Yesterday I just submitted my first windows phone app: Daylight, to the market. I have used several libraries for different purposes, but to create the &#8220;Loading&#8221; overlay that looks like the original one, I have used Coding4Fun Toolkit for windows phone. 1. Install Coding4Fun libraries using NuGet VS &#62; Tools...]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-100 alignright" style="margin-left: 20px; margin-right: 0px;" title="Loading overlay" src="http://www.comyoucom.com/wp-content/uploads/2012/05/loading.overlay-180x300.png" alt="Loading overlay" width="180" height="300" /></p>
<p>Yesterday I just submitted my first windows phone app: <a title="Daylight" href="http://www.comyoucom.com/daylight/">Daylight</a>, to the market. I have used several libraries for different purposes, but to create the &#8220;Loading&#8221; overlay that looks like the original one, I have used <a title="Coding4Fun" href="http://coding4fun.codeplex.com/" target="_blank">Coding4Fun Toolkit for windows phone</a>.</p>
<p><strong>1. Install Coding4Fun libraries using NuGet</strong></p>
<p>VS &gt; Tools &gt; Library Package Manager &gt; Package Manager Console</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">PM &gt; Install-Package Coding4Fun.Phone.Controls.Complete</div></div>
<p><strong>2. Add references to the namespaces in the XAML that you want to add the overlay</strong></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xmlns:slToolkit =&quot;clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit&quot;<br />
xmlns:c4f=&quot;clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls&quot;<br />
xmlns:Converters=&quot;clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls&quot;</div></div>
<p><strong>3. Add resources</strong></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phone:PhoneApplicationPage.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Converters:BooleanToVisibilityConverter</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;">&quot;BoolToVisibilityConverter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phone:PhoneApplicationPage.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p><strong>4. Overlay markup</strong></p>
<p>The app is using a Grid with 2 rows as main layout, the overlay is using the same layout to cover the whole screen:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">&lt;!-- Loading Overlay --&gt;</span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c4f:ProgressOverlay</span> <span style="color: #000066;">Canvas.ZIndex</span>=<span style="color: #ff0000;">&quot;1000&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;progressOverlay&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">Visibility</span>=<span style="color: #ff0000;">&quot;{Binding Path=OverlayVisibility, Converter={StaticResource BoolToVisibilityConverter}}&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">Grid.RowSpan</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">Opacity</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">d:IsLocked</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">d:IsHidden</span>=<span style="color: #ff0000;">&quot;True&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c4f:ProgressOverlay.Content<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;StackPanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;slToolkit:PerformanceProgressBar</span> <span style="color: #000066;">IsIndeterminate</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">HorizontalAlignment</span>=<span style="color: #ff0000;">&quot;Center&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Loading<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextBlock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/StackPanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/c4f:ProgressOverlay.Content<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/c4f:ProgressOverlay<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p><strong>5. ViewModel attribute that will set the overlay to visible or collapsed</strong></p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> OverlayVisibility <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></div>
<p>Enjoy Coding4Fun!</p>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/windows-phone-loading-overlay/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-loading-overlay%2F&amp;text=Windows+phone%3A+Loading+overlay&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/windows-phone-loading-overlay/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-loading-overlay%2F&amp;name=Windows+phone%3A+Loading+overlay" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-loading-overlay%2F&amp;title=Windows+phone%3A+Loading+overlay" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fwindows-phone-loading-overlay%2F&amp;title=Windows+phone%3A+Loading+overlay" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/K4s2f1AeId4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/windows-phone-loading-overlay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/windows-phone-loading-overlay/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=windows-phone-loading-overlay</feedburner:origLink></item>
		<item>
		<title>SSL on Elastic Load Balancer (ELB) in AWS using MVC and IIS</title>
		<link>http://feedproxy.google.com/~r/comyoucom/~3/JOXFawMydJ0/</link>
		<comments>http://www.comyoucom.com/ssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis/#comments</comments>
		<pubDate>Mon, 07 May 2012 15:08:16 +0000</pubDate>
		<dc:creator>Pedro Alonso</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[elb]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://www.comyoucom.com/?p=60</guid>
		<description><![CDATA[Recently we decided to host a campaign website in AWS using EC2. The site had to run only under SSL / HTTPS, so we needed to redirect the users trying to use HTTP to the HTTPS protocol. That can be set up on IIS using the rewrite module, because this...]]></description>
			<content:encoded><![CDATA[<p>Recently we decided to host a campaign website in AWS using EC2. The site had to run only under SSL / HTTPS, so we needed to redirect the users trying to use HTTP to the HTTPS protocol. That can be set up on IIS using the rewrite module, because this solution didn’t work. We ended up doing the redirect in code.</p>
<p>The way that the <strong>cluster is set up</strong> is:<br />
ELB listen to HTTPS (443), forwarding to HTTP (80) on the instance.<br />
ELB listen to HTTPS (80), forwarding to HTTP (80) on the instance. <strong>In this case we want to redirect the user to HTTPS</strong>.</p>
<p>The communication between the Load Balancer and the instance is clear HTTP. On each request we need to check if the user is using a secure connection, otherwise, we need to redirect him:</p>
<p><strong>Global.asax:</strong></p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> Application_BeginRequest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>SslHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">IsSecureConnection</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>HealthcheckRequest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Redirect</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;https://www.home.com&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Notice, that if the request is from the ELB to the Health-check URL we don’t want to redirect, it would cause an infinite loop.</p>
<p>The way that the Elastic Load Balancer notify the instance the protocol that the user used to make the request is setting the HTTP Header: &#8220;X-Forwarded-Proto&#8221;.</p>
<p><strong>SSL Helper</strong>, this would work locally and also on AWS:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> SslHelper<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsSecureConnection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> IsSecureInAws<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">||</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsSecureConnection</span><span style="color: #008000;">;</span><br />
&nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsSecureInAws<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;X-Forwarded-Proto&quot;</span><span style="color: #008000;">&#93;</span>, <span style="color: #666666;">&quot;https&quot;</span>, StringComparison<span style="color: #008000;">.</span><span style="color: #0000FF;">OrdinalIgnoreCase</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Helper method to filter the health-check requests from ELB</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> HealthcheckRequest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToLower</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EndsWith</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/healthcheck&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Another thing to notice when you’re running a cluster behind ELB is that if you want to log the original request IP of the user, that is also set in a HTTP header, and this helper method would suffice to get it:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> FetchUserIP<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> ip <span style="color: #008000;">=</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;X-Forwarded-For&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>ip<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; ip <span style="color: #008000;">=</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UserHostAddress</span><span style="color: #008000;">;</span><br />
&nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> ip<span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><g:plusone size="medium" count="false" href="http://www.comyoucom.com/ssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis/"></g:plusone></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.comyoucom.com%2Fssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis%2F&amp;text=SSL+on+Elastic+Load+Balancer+%28ELB%29+in+AWS+using+MVC+and+IIS&amp;via=comyoucom" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><a name="fb_share" type="button" share_url="http://www.comyoucom.com/ssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis/" href="http://www.facebook.com/sharer.php">Share</a></span><span class="mr_social_sharing"><a href="http://www.tumblr.com/share/link?url=http%3A%2F%2Fwww.comyoucom.com%2Fssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis%2F&amp;name=SSL+on+Elastic+Load+Balancer+%28ELB%29+in+AWS+using+MVC+and+IIS" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/tumblr.png" alt="Share on Tumblr" title="Share on Tumblr"/></a></span><span class="mr_social_sharing"><a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.comyoucom.com%2Fssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis%2F&amp;title=SSL+on+Elastic+Load+Balancer+%28ELB%29+in+AWS+using+MVC+and+IIS" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/delicious.png" alt="Save on Delicious" title="Save on Delicious"/></a></span><span class="mr_social_sharing"><a href="http://digg.com/submit?url=http%3A%2F%2Fwww.comyoucom.com%2Fssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis%2F&amp;title=SSL+on+Elastic+Load+Balancer+%28ELB%29+in+AWS+using+MVC+and+IIS" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.comyoucom.com/wp-content/plugins/social-sharing-toolkit/images/buttons/digg.png" alt="Digg This" title="Digg This"/></a></span></div>
<img src="http://feeds.feedburner.com/~r/comyoucom/~4/JOXFawMydJ0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.comyoucom.com/ssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.comyoucom.com/ssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ssl-on-elastic-load-balancer-elb-in-aws-using-mvc-and-iis</feedburner:origLink></item>
	</channel>
</rss>
