Tags: | Categories: Blog Posted by admin on 3/22/2010 2:35 PM | Comments (1)


image_thumb_7433D110[1]

Installation tips.

If Visual Studio 2010 Professional or higher is already installed on your development computer, an add-in for Visual Studio 2010 Professional is automatically installed as well.

The installation took an hour on a Windows 7 with 4 GB of RAM and rebooted the computer once. Something tells me the installer still needs some work.

image

 

Let’s Write some code

Everything installed, let’s check if Visual Studio 2008 still works with Silverlight 3 first. CHECKED!

Of course the first thing I checked is the location API, and does not work in the emulator. Also the WebBrowser control does not support Silverlight 3 when surfing the web with items in Silverlight, nor JavaScript.

I referenced a few Silverlight 4 dlls and they work without being compiled if the System.Windows.Browser.dll is references as well, you won’t be able to use any UI component from those dlls, yet the functionality will still be there!

The Location API in Windows Phone 7 does not work in the emulator, so this code will never return a geo coordinates.

 /// <summary>
        /// Helper method to start up the location data acquisition
        /// </summary>
        /// <param name="accuracy">The accuracy level </param>
        private void StartLocationService(GeoPositionAccuracy accuracy)
        {
            // Reinitialize the GeoCoordinateWatcher
            StatusTextBlock.Text = "starting, " + accuracyText;
            watcher = new GeoCoordinateWatcher(accuracy);
            watcher.MovementThreshold = 20;

            // Add event handlers for StatusChanged and PositionChanged events
            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
            watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);

            // Start data acquisition
            watcher.Start(); 
        }

Using the WebClient class the way Scott Guthrie did returns this exception for some reason when making a request.

image 

The SyndicationFeed from the dll  System.ServiceModel.Syndication is not there for you to reference so you need to reference the one in Silverlight 3.0, everything works to parse the atom if you are using the search API at twitter.

image

You may also get an error to reinstall the Visual Studio 2010 for Windows Phone, just close the emulator and try again, you won’t have to reinstall it

After all those problems I had an app running!!

 private void buttonDisplay_Click(object sender, RoutedEventArgs e)
        {
            WebClient client = new WebClient();
           
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            client.OpenReadAsync(new Uri("http://search.twitter.com/search.atom?q=" + textBoxUrl.Text));
            
        }

        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
             if (e.Error != null)
                return;

             SyndicationFeed feed = SyndicationFeed.Load(XmlReader.Create(e.Result));

             listBox1.ItemsSource = from tweet in feed.Items
                                    select new TwitterItem
                                    {
                                        ImageSource = tweet.Links[1].Uri.AbsoluteUri,                                                      
                                        Message = tweet.Title.Text,
                                        UserName = tweet.Authors[0].Name
                                    };
        }

Resources Links

http://developer.windowsphone.com/windows-phone-7-series/

http://geeks.netindonesia.net/blogs/risman/archive/2010/03/16/mix-10-windows-phone-developer-tools-ctp.aspx

http://channel9.msdn.com/posts/LauraFoy/First-Look-Windows-Phone-7-Series-Hands-on-Demo/

http://www.earthware.co.uk/blog/index.php/2010/03/writing-a-bing-maps-location-aware-application-for-windows-phone-7-series/

Comments

on 3/24/2010 3:36 PM

Pingback from Twitter Trackbacks for Playing with Windows Phone Developer Tools CTP : Al Pascual [alpascual.com] on Topsy.com


Comments are closed