Search
Thursday, October 18, 2018 ..:: Home ::.. Register  Login

Peter Henry on Facebook  Peter Henry on LinkedIn  Peter Henry on Twitter

   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

Want to write your OWN Twitter client for WP7? It's easier than you think!

Mar 22

Written by:
Monday, March 22, 2010 9:25 PM  RssIcon

ScottGu's BlogCheck this out, my first Twitter client for WP7!  Read on for the details (and link to source code so you can try it out).

ScottGu's BlogTonight I thought I would take a crack at ScottGu's Twitter client he "just whipped up" during his MIX 2010 presentation!  Very bold to do that live!  Well, hhhhmmm after seeing what he did, it wasn't really THAT complicated.  Well, at least not once he showed EXACTLY what he did!  WPF/XAML/SL and the WP7 framework make it sooooooo much easier than I had envisioned it in my mind.  If you're like me and want to check this out, GO FOR IT!  ScottGu GIVES you the most complicated parts so you can focus on learning the WP7 basics!  Go for it!  The hardest part is starting!  Here's what half an hour of reading the blog and a bit of creative thinking can do for you!

My first Twitter client for WP7

The key pieces to this?  Actually, it's not the Twitter URL or APIs to grab the data,

			WebClient twitter = new WebClient();
			twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler( twitter_DownloadStringCompleted );
			twitter.DownloadStringAsync(
				new Uri( string.Format( "http://api.twitter.com/1/statuses/user_timeline.xml?screen_name={0}",
					usernameTextBox.Text ) ) );

No, it's actualy the Listbox.ItemTemplate declaration in XAML.

				<ListBox.ItemTemplate>
					<DataTemplate>
						<StackPanel Orientation="Horizontal" Height="100">
							<Image Source="{Binding ImageSource}" Height="73" Width="73" VerticalAlignment="Top" Margin="0, 10, 8,0"/>
							<StackPanel Width="370">
								<TextBlock Text="{Binding UserName}" Foreground="#FFC8AB14" FontSize="28"/>
								<TextBlock Text="{Binding Message}" TextWrapping="Wrap" FontSize="24"/>
							</StackPanel>
						</StackPanel>						
					</DataTemplate>
				</ListBox.ItemTemplate>

Here are a few things I learned tonight while doing this sample:

  • The WP7 emulator ignores the mouse wheel (you'll have to "click and flick" to get the listbox to scroll).
  • While running your WP7 app, VS goes "drunk", what I mean is, there's a haze that goes over it to tell you, that you can't change anything while your app is running, kind of like trying to edit ASP.NET user controls while your web app is running.
  • For some reason the font rendering in the emulator is terrible on my LCD, I have NO idea why?  At first, I thought I didn't have the ClearType Tuner properly configured, but after redoing it for the third straight night in a row, I think it's the emulator.
  • I have TERRIBLE colour coordination!
  • I tried to grab the Montreal Canadiens website to brag about beating the Sens tonight, uuhhhmmmm, my team lost!  DOH!  I'm sure CI, SG, BC, AB, SD and SB are going to rub THAT in tomorrow!

Now that you too can build a Twitter client with VERY LITTLE EFFORT!!!!!!!!  it's time to grab a coffee and get coding!

 

Resources

Source Code: http://www.pchenry.com:8080/svn/blog/trunk/2010/FirstTwitterClient

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement