Click here to Skip to main content
15,891,607 members
Articles / Web Development / ASP.NET

A Simple Silverlight RSS Reader

Rate me:
Please Sign up or sign in to vote.
4.74/5 (20 votes)
21 Jun 2010CPOL3 min read 60.1K   1.4K   52  
This is a simple Silverlight RSS Reader which pulls out data from a feed URL.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml;
using RSSReader;
using RSSReader.RSSService;

namespace RSSReader
{
    public partial class UC_RSSReader : UserControl
    {     

        #region Constructor

        public UC_RSSReader()
        {
            InitializeComponent();
        }

        #endregion

        #region Event Handler

        private void FetchRSS_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(RSSFeedUrlTextBox.Text.Trim()) 
                && Uri.IsWellFormedUriString(RSSFeedUrlTextBox.Text.Trim(), UriKind.Absolute))
            {
                LoadingTextBlock.Visibility = Visibility.Visible;
                RSSFeed.Items.Clear();
                RSSReaderServiceClient RSSReaderServiceClient = new RSSReaderServiceClient();
                RSSReaderServiceClient.GetFeedCompleted += new EventHandler<GetFeedCompletedEventArgs>(RSSReaderServiceClient_GetFeedCompleted);
                RSSReaderServiceClient.GetFeedAsync((new Uri(RSSFeedUrlTextBox.Text)).ToString());                
            }
        }

        void RSSReaderServiceClient_GetFeedCompleted(object sender, GetFeedCompletedEventArgs e)
        {
            RSSFeed.ItemsSource = e.Result;
            LoadingTextBlock.Visibility = Visibility.Collapsed;
        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Tata Consultancy Services
India India
I have been working in different .NET Technologies like ASP.NET,WPF,Silverlight for the last few years.I am enjoying my life as a Programmer and spending time with my Family,Friends & Camera.

My Technical Blog


My Photo Blog


Comments and Discussions