Animating Windows Phone Listboxes: Listing 1

Loading runtime data from Flickr.

public MainPage()
{
    InitializeComponent();

    Loaded += MainPageLoaded;
}

private void MainPageLoaded(object sender, RoutedEventArgs e)
{
    var wc = new WebClient();
    wc.OpenReadCompleted += FlickrDownloadCompleted;
    wc.OpenReadAsync(new Uri("http://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1"));
}

private void FlickrDownloadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    var serializer = new DataContractJsonSerializer(typeof(FlickrData));
    var data = serializer.ReadObject(e.Result) as FlickrData;

    Dispatcher.BeginInvoke(() =>{
                                    DataContext = data;
                                });
}

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus

Featured

Subscribe on YouTube