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

<channel>
	<title>Many Niches &#187; WP7</title>
	<atom:link href="http://www.manyniches.com/tag/wp7/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.manyniches.com</link>
	<description>Jack of All Trades, Master of Some</description>
	<lastBuildDate>Mon, 14 Nov 2011 21:12:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Building the Platform, One Dev at a Time</title>
		<link>http://www.manyniches.com/windows-phone/building-the-platform-one-dev-at-a-time/</link>
		<comments>http://www.manyniches.com/windows-phone/building-the-platform-one-dev-at-a-time/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 03:47:01 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[wp7dev]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/windows-phone/building-the-platform-one-dev-at-a-time/</guid>
		<description><![CDATA[Last week when I read Jamie’s excoriation of the Blackberry Playbook dev platform (so many people forwarded it to me), it made me sad.&#160; Sad because a developer was hitting friction on a platform on which he clearly wanted to develop apps. Tyler Lessard from RIM responded to this open air criticism, and I give [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fbuilding-the-platform-one-dev-at-a-time%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fbuilding-the-platform-one-dev-at-a-time%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="left">Last week when I read <a href="http://blog.jamiemurai.com/2011/02/you-win-rim/">Jamie’s excoriation of the Blackberry Playbook dev platform</a> (so many people forwarded it to me), it made me sad.&#160; Sad because a developer was hitting friction on a platform on which he clearly wanted to develop apps.</p>
<p align="left"><a href="http://devblog.blackberry.com/2011/02/thanks-for-the-open-letter-to-rim-developer-relations/">Tyler Lessard from RIM responded</a> to this open air criticism, and I give him points for his embracing this publicly.&#160; I look forwarded to meeting Tyler at some point in the future.</p>
<p>There are some in the community that said Jamie was bitching and moaning.&#160; He was.&#160; They say he gave up too easily.&#160; Perhaps.&#160; This issue does elucidate a more pressing issue, which is the plethora of choices available to the discerning developer, and the decreasing ability to get it wrong if you are a platform provider.&#160; Further, with Twitter and blogs being so public – they are forever etched in stone people! (i.e. the search index) – it’s hard for a platform provider to not to feel like they are under constant and heavy fire.</p>
<p>Yet, the very tools which quickly bring scorn and ire to some can provide for a happy ending to others.&#160; In just under 4 hours, I was able to reach out to someone in another country, whom I have never met, and had never heard of prior to last week, and prompt him to action.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2011/02/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 3px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.manyniches.com/wp-content/uploads/2011/02/image_thumb1.png" width="444" height="88" /></a></p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2011/02/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 3px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.manyniches.com/wp-content/uploads/2011/02/image_thumb2.png" width="444" height="86" /></a></p>
<p>Even if we build the platform one developer at a time, that’s one more developer than we had last week.&#160; Every developer matters.&#160; Every. Single. One.&#160; I effing love my job.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/windows-phone/building-the-platform-one-dev-at-a-time/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Windows Weekly &amp; DotNetRocks</title>
		<link>http://www.manyniches.com/windows-phone/windows-weekly-dotnetrocks/</link>
		<comments>http://www.manyniches.com/windows-phone/windows-weekly-dotnetrocks/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 23:31:37 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[.net rocks]]></category>
		<category><![CDATA[leo laporte]]></category>
		<category><![CDATA[paul thurrott]]></category>
		<category><![CDATA[windows weekly]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[wp7dev]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/windows-phone/windows-weekly-dotnetrocks/</guid>
		<description><![CDATA[It’s not often I find myself kerfuffled, but that’s what happened when I was permitted to be a guest to discuss Windows Phone 7 on Windows Weekly, hosted by Leo Laporte and Paul Thurrott.&#160; I’ve been a long time listener of several of the TWiT network podcasts, and fondly remember staying up late in grad [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fwindows-weekly-dotnetrocks%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fwindows-weekly-dotnetrocks%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img style="margin: 0px 5px 5px 0px; display: inline" title="" alt="" align="left" src="http://twit.tv/files/imagecache/coverart/coverart/podcast_17_3.jpg" width="120" height="120" />It’s not often I find myself kerfuffled, but that’s what happened when I was permitted to be a guest to discuss <a href="http://twit.tv/ww174">Windows Phone 7 on Windows Weekly</a>, hosted by <a href="http://www.leoville.com">Leo Laporte</a> and <a href="http://www.winsupersite.com">Paul Thurrott</a>.&#160; I’ve been a long time listener of several of the TWiT network podcasts, and fondly remember staying up late in grad school to catch <a href="http://en.wikipedia.org/wiki/Dev_Null">Dev Null on “The Site”</a> on MSNBC.&#160; It was a lively conversation, and I have received many emails from people I don’t know with their thoughts on the show and WP7.&#160; I love hearing from the community, and really look forward to meeting more developers building cool apps and games.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/09/image6.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 5px 5px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.manyniches.com/wp-content/uploads/2010/09/image_thumb6.png" width="244" height="58" /></a>We also sponsored a couple of <a href="http://www.dotnetrocks.com/">.Net Rocks</a> shows with Carl and Richard (<a href="http://www.dotnetrocks.com/default.aspx?showNum=595">show 1</a>) so that we could talk about the tools release, but more importantly so that we could enable 6 developers to talk about what they are building for Windows Phone 7.&#160; We really wanted to give a microphone to devs doing cool stuff; specifically guys who are working without the aid of PR firms and other means to get the opportunity to promote themselves.&#160; We know that there are going to be many apps built for Windows Phone 7 by small teams, and we really want to help get them noticed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/windows-phone/windows-weekly-dotnetrocks/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Seattle Area Developers &#8211; GDGT Event</title>
		<link>http://www.manyniches.com/windows-phone/seattle-area-developers-gdgt-event/</link>
		<comments>http://www.manyniches.com/windows-phone/seattle-area-developers-gdgt-event/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 15:05:44 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[epic]]></category>
		<category><![CDATA[GDGT]]></category>
		<category><![CDATA[nerdosity]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[wp7dev]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/windows-phone/seattle-area-developers-gdgt-event/</guid>
		<description><![CDATA[Stop the presses!&#160; I’ve got some news.&#160; The great team at GDGT is coming to Seattle, and they are having a bit of a party and meetup.&#160; There should be a great deal of nerdosity going on there, which is awesome in its own right.&#160; This will be further accentuated by the fact that the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fseattle-area-developers-gdgt-event%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fseattle-area-developers-gdgt-event%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;"><iframe src="http://www.facebook.com/widgets/like.php?href=http://www.manyniches.com/windows-phone/seattle-area-developers-gdgt-event/" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe></div>
<p>Stop the presses!&#160; I’ve got some news.&#160; The great team at <a href="http://www.facebook.com/event.php?eid=135148676504452">GDGT is coming to Seattle</a>, and they are having a bit of a party and meetup.&#160; There should be a great deal of nerdosity going on there, which is awesome in its own right.&#160; This will be further accentuated by the fact that the Windows Phone 7 team will be there to show off some devices.</p>
<p>Under normal circumstances, that would be pretty cool.&#160; However, we’re not in the “pretty cool” business here.&#160; I think I have made it clear, we are in the <a href="http://www.manyniches.com/windows-phone/windows-phone-7-device-requests/">epic shit business</a>.&#160; Apparently, the nerdosity is expected to flow especially high at this event, and the request was made for the developer platform team for Windows Phone 7 to make an appearance.&#160; Challenge thrown down.&#160; Challenge accepted.&#160; Challenge contorted into something all together different.</p>
<p>Since announcing the email alias to which you can <a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/07/12/windows-phone-developer-tools-beta-released.aspx">send your device requests</a> (about 2 weeks ago), we’ve been blown away by the response.&#160; We’re still making our way through those requests, getting them into a CRM system and assigning them to our field evangelists.&#160; That’s a tale of logistical complexity for another day.&#160; However, the whole point of having preview devices is to get them into the hands of developers, right?&#160; So we have two things to share.</p>
<p>First, if you are a developer in the area, and want to come to the event, bring your laptops with your Windows Phone 7 XAPs.&#160; We will have phones on site to which you can deploy your code.&#160; You can see it running on a real Windows Phone 7.&#160; You get to share it with the crowd.&#160; That’s not bad, but certainly not epic.&#160; No, no.&#160; Epic is in reserve for those true hackers who show up with the goods.&#160; For those who have got the best XAPs, we are bringing a couple of phones with us, and some developer agreements to sign.&#160; That’s right…the “A” gamers will be walking out with phones on which to continue their coding.</p>
<p>Are you game?&#160; Spread the word, and see you there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/windows-phone/seattle-area-developers-gdgt-event/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>XBox Live on Windows Phone 7</title>
		<link>http://www.manyniches.com/windows-phone/xbox-live-on-windows-phone-7/</link>
		<comments>http://www.manyniches.com/windows-phone/xbox-live-on-windows-phone-7/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 20:55:09 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[xbox]]></category>
		<category><![CDATA[xbox live]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/windows-phone/xbox-live-on-windows-phone-7/</guid>
		<description><![CDATA[Inspired by the always entertaining Mike Klucher, I snapped this pic of my own avatar on my daily use Windows Phone 7.&#160; He talks about the very way I felt when my avatar showed up on my phone this week.&#160; It made me smile.&#160; I even went into the XBox Marketplace to change around some [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fxbox-live-on-windows-phone-7%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fwindows-phone%2Fxbox-live-on-windows-phone-7%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;"><iframe src="http://www.facebook.com/widgets/like.php?href=http://www.manyniches.com/windows-phone/xbox-live-on-windows-phone-7/" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe></div>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/06/XboxLiveWP7.jpg"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="XboxLiveWP7" border="0" alt="XboxLiveWP7" align="left" src="http://www.manyniches.com/wp-content/uploads/2010/06/XboxLiveWP7_thumb.jpg" width="148" height="244" /></a> Inspired by the always entertaining Mike Klucher, I snapped this pic of my own avatar on my daily use Windows Phone 7.&#160; He talks about the very way I felt when my avatar showed up on my phone this week.&#160; It made me smile.&#160; I even went into the XBox Marketplace to change around some clothing options to see how long before it appeared on my phone.&#160; I was not disappointed.</p>
<p>I also felt great sadness because my achievements were so dated.&#160; Not that the system wasn’t working.&#160; No,no.&#160; This was a stark reminder that I haven’t been playing nearly as much XBox as I should be!!&#160; So, off to GameStop I went and picked up my copy of <a href="http://xbox360.ign.com/objects/143/14320288.html">Red Dead Redemption</a>.&#160; I very much plan to use the “hey, it’s Father’s Day” excuse all weekend long.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/windows-phone/xbox-live-on-windows-phone-7/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Windows Phone 7 Series Developer Experience</title>
		<link>http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/</link>
		<comments>http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 16:17:00 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[n00bnotes]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/</guid>
		<description><![CDATA[Today at Mix10, Microsoft released the developer tools for Windows Phone 7 Series.&#160; I’m excited about seeing what apps will get built now that there is general availability of the Windows Phone dev tools.&#160; That’s general availability, as in for everyone! Charlie Kindel (if you aren’t, you really should follow him) was nice enough to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fwindows-phone-7-series-developer-experience%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fwindows-phone-7-series-developer-experience%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/03/image.png"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.manyniches.com/wp-content/uploads/2010/03/image_thumb.png" width="164" height="318" /></a>Today at <a href="http://live.visitmix.com/">Mix10</a>, Microsoft released the developer tools for <a href="http://www.microsoft.com/express/phone">Windows Phone 7 Series</a>.&#160; I’m excited about seeing what apps will get built now that there is <a href="http://www.microsoft.com/express/phone">general availability of the Windows Phone dev tools</a>.&#160; That’s general availability, as in for everyone!</p>
<p><a href="http://blogs.msdn.com/ckindel">Charlie Kindel</a> (if you aren’t, <a href="http://www.twitter.com/ckindel">you really should follow him</a>) was nice enough to get me access to the tools about 3 weeks ago, despite the fact that he and his team have had plenty on their plate since going public with WP7.&#160; I have spent some time in the last few winks building and tinkering.</p>
<p>A little background on my dev skills.&#160; I can write basic applications, and have been known to favor Python when trying out new ideas.&#160; I have dabbled a bit with our ASP.NET MVC (<a href="http://weblogs.asp.net/scottgu/archive/2010/03/11/asp-net-mvc-2-released.aspx">MVC v2 just released</a> – way to go guys!!) and taught myself enough C# to be dangerous.&#160; What coding I do, I do for fun and in my free time.&#160; I call it my nocturnal nerdiness, and have been logging some of my projects using the <a href="http://www.manyniches.com/category/n00b-notes/">n00bnotes tag</a>.&#160; Prior to 3 weeks ago, I had never written one line of Silverlight (or WPF for that matter) code, nor any XAML.&#160; I was really excited to have the opportunity to build apps for this mobile platform, as I once tried to get along with iPhone development, and while it’s clear that Apple has created tools that developers seem to love, I couldn’t get along with ObjectiveC.&#160; That’s a me issue, and not a statement about ObjectiveC.&#160; I get along famously with Python, but me and Ruby are not friends.&#160; That’s just the way my brain works.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/03/image1.png"><img style="border-right-width: 0px; margin: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="right" src="http://www.manyniches.com/wp-content/uploads/2010/03/image_thumb1.png" width="164" height="324" /></a>With that as a preamble, I wanted to share what I have created in just the last 3 weeks, working largely in what spare time I could find when not doing my day job or dealing with an recalcitrant 8 month old girl who refuses to sleep.&#160; The main thing I want people to take away from this is that it in <strong>incredibly</strong> <strong>easy to built apps for Windows Phone 7</strong>.&#160; If I can figure it out, anyone can.&#160; The team has delivered a great development experience built on top of Visual Studio Express.&#160; When you fire up the development environment, everything you need is there and you are ready to go.&#160; It was a pretty painless experience to get the environment up and running, and it includes templates for Silverlight apps as well as XNA games.&#160; While I have only been able to deploy to an actual phone once, the emulator felt like a software version of the phone.</p>
<p>Over the next few days of Mix10, I am going to put up a few posts about my experiences with the development tools, highlighting some of the blockers I hit, how I solved them, and for some of them, how I should have solved them, which I eventually fixed during code refactoring.</p>
<p>In the meantime, I wanted to share a link to the current version of the code.&#160; This is my <a href="http://www.manyniches.com/wp-content/uploads/2010/03/FriendLinks1.zip">FriendLinks application, built for Windows Phone 7</a> [UPDATE: 3/24/10 – oh the joy of forgetting to remove commented code with your twitter pass.&#160; Ooops…code updated.]&#160; You will need the <a href="http://www.microsoft.com/express/phone">development tools</a> in order to open, edit view.&#160; The only disclaimer I make is that the code works.&#160; Not all of it is pretty, and in some places I haven’t gone back to fix things I fixed elsewhere (i.e. walking XML for Bit.ly versus for Twitter).</p>
<p>This specific post is about some of the things that gave me the biggest problems in getting started.&#160; The app that I built is pretty simple.&#160; It’s meant to allow you to connect to Twitter, pull down your friend timeline, and parse the timeline looking for URLs sent by people you follow.&#160; I use Twitter for content discovery, and this is my ultimate time waster app.&#160; When you click on a link the listbox, some additional calls are made via the <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation">Bit.ly API</a>, and the <a href="http://help.tweetmeme.com/2009/04/07/api-documentation/">TweetMeme API</a>, to get additional information like the number of retweets that article has, the title of the page referenced and the number of clicks as tracked by Bit.ly.</p>
<p> <span id="more-377"></span>
</p>
<h1>Making Async Calls to Web Services</h1>
<p>Wow, what a huge pain this was <strong>for me</strong> to figure out.&#160; When you do some web searching about how to connect to web services in C#, you will invariably find yourself staring at content about <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx">WebClient class</a>.&#160; I couldn’t make this work for me, and now that I am 3 weeks into it, I can’t remember what the specific issue was.&#160; Something about Twitter not doing Basic Auth correctly, and needing to set the username and password in the header, necessitating the use of <a href="http://msdn.microsoft.com/en-us/library/system.net.networkcredential.aspx">NetwrokCredentials</a>.</p>
<p>In any event, I had to use the HttpWebRequest.&#160; This is where things got challenging for me, since I had never done any async programming in C# or Silverlight.&#160; [Apologies for the wonky formatting in the code samples, but I have a narrow blog and the style isn’t doing auto wrap]</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatuses()
{
    NetworkCredential nc = <span class="kwrd">new</span> NetworkCredential { UserName =</pre>
<p>
  </p>
<pre class="csharpcode">                          _username, Password = _password };

    <span class="kwrd">string</span> url = <span class="str"><a href="http://twitter.com/statuses/friends_timeline.xml?">http://twitter.com/statuses/friends_timeline.xml?</a></span></pre>
<p>
  </p>
<pre class="csharpcode"><span style="color: #006080">                              </span> + <span class="str">&quot;count=&quot;</span> + _count + (_sinceID &gt; 0 ?</pre>
<p>
  </p>
<pre class="csharpcode">                               <span class="str">&quot;&amp;since_id=&quot;</span> + _sinceID : <span class="str">&quot;&quot;</span>);
    System.Net.HttpWebRequest request =</pre>
<p>
  </p>
<pre class="csharpcode">                              (HttpWebRequest)HttpWebRequest.Create(url);
    request.Method = <span class="str">&quot;GET&quot;</span>;

    <span class="kwrd">if</span> (_username != <span class="kwrd">null</span> &amp;&amp; _password != <span class="kwrd">null</span>)
    {
        request.Credentials = nc;
    }

    IAsyncResult token = request.BeginGetResponse(</pre>
<p>
  </p>
<pre class="csharpcode"><span class="kwrd">                                  new</span> AsyncCallback(GetStatusesCallBack),</pre>
<p>
  </p>
<pre class="csharpcode">                                  request);

}</pre>
<p>Sorting out how to correctly get the async call done, and then set up the callback, was where I completely threw a rod.&#160; Basically, you need to set up a web request to happen on its own thread, and then you need to assign a delegate function to process the response.&#160; Figuring out how to do this took me 2 days, mostly because I didn’t know what questions to ask, or what terms to use when searching online, and in this specific case, only code that I did discover was useless for me because I was trying to learn something new and didn’t understand the samples I found.</p>
<p>Looking at the call, you may notice that I am using the REST API from Twitter, and setting the since_id and count variables to ensure that I am getting the data that I want.&#160; This is so I can reuse this function to make subsequent calls while the app is running and only get the new tweets.&#160; Twitter makes things pretty easy to get the data you want.</p>
<p>Here’s how you handle the async callback function to actually issue the HTTP request and process the data which comes back:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatusesCallBack(IAsyncResult result)
{
    <span class="kwrd">bool</span> foundNewSinceID = <span class="kwrd">false</span>;

    <span class="kwrd">try</span>
    {

        WebResponse response = ((HttpWebRequest)result.AsyncState)</pre>
<p>
  </p>
<pre class="csharpcode">                                       .EndGetResponse(result);
        StreamReader reader = <span class="kwrd">new</span> StreamReader(response</pre>
<p>
  </p>
<pre class="csharpcode">                                       .GetResponseStream());
        <span class="kwrd">string</span> responseString = reader.ReadToEnd();</pre>
<p><!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; } &#8211;></p>
<p>[note – this is a code snippet, and won’t work without closing that try{} and having an associated catch block]&#160; What you end up with in the responseString is well formatted XML returned from Twitter.&#160; Once I understood how to make these async calls, I was able to write any number of functions which handled getting data from other web services.</p>
<h1>XML Processing</h1>
<p>Oh man, what a complete cluster this was for me.&#160; The <a href="http://apiwiki.twitter.com/Twitter-API-Documentation">Twitter API is well documented</a>, and so I figured it would be pretty easy to parse the XML.&#160; Unfortunately, I didn’t know what was available to me in Silverlight on Windows Phone 7 Series, so I started by asking Bing.</p>
<p>First things first, especially for those who are not well versed in Silverlight or Visual Studio.&#160; If you want to parse XML, do yourself a huge favor and add a reference (“Project/Add Reference”) to System.Xml.Linq in your project.&#160; Do that first.&#160; With that, you can use XDocument.&#160; Do it not, and you will have code that looks like this (focus on the while loop at the bottom):</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatusesCallBack(IAsyncResult result)
{
    <span class="kwrd">string</span> _name = <span class="kwrd">null</span>;
    <span class="kwrd">string</span> _status = <span class="kwrd">null</span>;
    <span class="kwrd">long</span> _tweetID = 0;

    <span class="kwrd">bool</span> foundNewSinceID = <span class="kwrd">false</span>;

    <span class="rem">//need to set header for the sinceid and num replies</span>
    <span class="kwrd">try</span>
    {
        WebResponse response = ((HttpWebRequest)result</pre>
<p>
  </p>
<pre class="csharpcode">                                    .AsyncState).EndGetResponse(result);
        StreamReader reader = <span class="kwrd">new</span> StreamReader(response</pre>
<p>
  </p>
<pre class="csharpcode">                                    .GetResponseStream());
        <span class="kwrd">string</span> responseString = reader.ReadToEnd();

        XmlReader xreader = XmlReader.Create(<span class="kwrd">new</span></pre>
<p>
  </p>
<pre class="csharpcode">                                    StringReader(responseString));

        <span class="kwrd">while</span> (xreader.Read())
        {
            <span class="kwrd">if</span> (xreader.NodeType == XmlNodeType.Element</pre>
<p>
  </p>
<pre class="csharpcode">                           &amp;&amp; xreader.Name == <span class="str">&quot;text&quot;</span>)
            {
                _status = CheckForLinks(xreader.ReadInnerXml());
            }

            <span class="kwrd">if</span> (xreader.NodeType == XmlNodeType.Element</pre>
<p>
  </p>
<pre class="csharpcode">                            &amp;&amp; xreader.Name == <span class="str">&quot;name&quot;</span>)
            {
                _name = xreader.ReadInnerXml();
            }</pre>
<p><!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; } &#8211;></p>
<p>Let’s talk about what’s going on here.&#160; It turns out that if you <a href="http://www.bing.com/search?q=.net+read+XML&amp;form=QBRE&amp;qs=n">ask Bing “.net read XML,”</a> you will get posts and articles that talk about how to use XmlReader.&#160; The first 10 links that come back all seem to point to this as a pattern for reading XML in .NET.&#160; Not knowing what I was doing, I figured that this was the way to do it.&#160; And so I set about building the code that would read XML and check for certain elements along the way.</p>
<p>This is not the right way to do this.&#160; Absolutely, unequivocally not the right way.&#160; As in, please, please, please don’t put yourself through this.&#160; Never mind that if you get back poorly formed XML you have problems.&#160; Or that sometimes the reader just decides not to work correctly.&#160; Or you get some weird data back, and you throw an exception, which is non-deterministic to find because the bug only surfaced when <a href="http://twitter.com/davemcclure">Dave McClure posted something strange</a> in his stream.&#160; Oh, and the fact that Twitter use an “id” both for users and status, which makes the stream read a bit strange and easy to get the wrong value for statusID or userID.&#160; Or that you end up with an unwieldy set of IF statements to parse your XML.&#160; So to recap, don’t read XML this way.&#160; Bad.&#160; Very bad.</p>
<p>The right way to do things is to put the resposeString into an XDocument, and then perform a LINQ query against it.&#160; You gain access to the XDocument via System.Xml.Linq, which is why I suggested adding that as a reference to your project.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatusesCallBack(IAsyncResult result)
{
    <span class="kwrd">bool</span> foundNewSinceID = <span class="kwrd">false</span>;

    <span class="kwrd">try</span>
    {

        WebResponse response = ((HttpWebRequest)result</pre>
<p>
  </p>
<pre class="csharpcode">                                        .AsyncState).EndGetResponse(result);
        StreamReader reader = <span class="kwrd">new</span> StreamReader(response</pre>
<p>
  </p>
<pre class="csharpcode">                                        .GetResponseStream());
        <span class="kwrd">string</span> responseString = reader.ReadToEnd();

        XDocument twitterXML = XDocument.Parse(responseString);

        var twitObjs = from x <span class="kwrd">in</span> twitterXML.Descendants(<span class="str">&quot;status&quot;</span>)
                      select <span class="kwrd">new</span>
        {
            tweetId = x.Element(<span class="str">&quot;id&quot;</span>).Value,
            text = x.Element(<span class="str">&quot;text&quot;</span>).Value,
            name = x.Element(<span class="str">&quot;user&quot;</span>).Element(<span class="str">&quot;name&quot;</span>).Value,
            profile_image_url = x.Element(<span class="str">&quot;user&quot;</span>)</pre>
<p>
  </p>
<pre class="csharpcode">                                        .Element(<span class="str">&quot;profile_image_url&quot;</span>).Value,
            userId = x.Element(<span class="str">&quot;user&quot;</span>).Element(<span class="str">&quot;id&quot;</span>).Value
        };</pre>
<p><!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; } &#8211;></p>
<p>Isn’t that just so much prettier?&#160; I had used LINQ before, but it was to access SQL objects, and for whatever reason I didn’t think to use LINQ to XML.&#160; Shame on me.&#160; n00bnotes hall of fame for sure.</p>
<h1>Exceptions on the UI Thread</h1>
<p>This one is very simple to understand and fix once you know what is going on, but a complete pain if you don’t understand why.&#160; The “why” is that there is one UI thread in Silverlight.&#160; If you want to update anything that is UI related, and your code isn’t being executed by the UI (for example, a delegate callback function), then you need to get that code onto the UI thread.&#160; This is very, very simple to do, but I didn’t know how to ask the question to get the answer, and so it took me a little while to find the answer.</p>
<pre class="csharpcode">Dispatcher.BeginInvoke(() =&gt;
{
    <span class="rem">//these are some basic UI changes that you can make once on the UI thread</span>
    grdTweets.Visibility = System.Windows.Visibility.Collapsed;
    grdLogin.Visibility = System.Windows.Visibility.Visible;

    txtPassword.Password = String.Empty;
    twitHelp.SetUserPass(txtUsername.Text, txtPassword.Password);

});</pre>
<p>The lambda function off the Dispatcher is how you get your UI updating code onto the UI thread.&#160; Just put your code in between the {} and you are all good.</p>
<p>My next post will talk about how I built out the listbox, which is the main piece of UI functionality, and the fun and interesting discovery process on how to use data binding.&#160; I now love data binding.&#160; A couple of days ago I hated it with a passion, but mostly because my code was wrong, I didn’t understand exactly what I was doing – more like just enough to sort of make things work, but not quite right enough that I noticed, and didn’t know how to debug.&#160; So much fun. <img src='http://www.manyniches.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

