How to Perform RSS Reader in Windows(UWP) 10 App

Create new Windows 10 project and give suitable name.

In windows 10 default SyndicationClient helps you to feed RSS service.

Design view will be designed as like the following XAML code:

  1. <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">  
  2.     <Grid>  
  3.         <Grid.RowDefinitions>  
  4.             <RowDefinition Height="Auto" />  
  5.             <RowDefinition Height="*" />  
  6.             <RowDefinition Height="*" /> </Grid.RowDefinitions>  
  7.         <Grid.ColumnDefinitions>  
  8.             <ColumnDefinition></ColumnDefinition>  
  9.             <ColumnDefinition Width="Auto"></ColumnDefinition>  
  10.         </Grid.ColumnDefinitions>  
  11.         <TextBox Grid.Row="0" Name="Value" Margin="20" VerticalAlignment="Center" />  
  12.         <Button x:Name="feedClick" Click="feedClick_Click" Content="Feed" Grid.Column="1" Grid.Row="0"></Button>  
  13.         <ScrollViewer Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="20" BorderThickness="0">  
  14.             <ItemsControl Name="Display">  
  15.                 <ItemsControl.ItemTemplate>  
  16.                     <DataTemplate>  
  17.                         <StackPanel>  
  18.                             <TextBlock TextWrapping="Wrap" Text="{Binding Path=Title.Text}" /> </StackPanel>  
  19.                     </DataTemplate>  
  20.                 </ItemsControl.ItemTemplate>  
  21.             </ItemsControl>  
  22.         </ScrollViewer>  
  23.         <ProgressRing x:Name="testring" Grid.Row="2"></ProgressRing>  
  24.     </Grid>  
  25. </Grid>  
Now go to code behind and create new instance of SyndicationClient and SyndicationFeed:
  1. SyndicationClient client = new SyndicationClient();  
  2. SyndicationFeed feed = await client.RetrieveFeedAsync(uri);  
Using RetrievedFeedAsync pass the url which you want to feed:

Using foreach you can manipulate the feed items:
  1. oreach (SyndicationItem item in feed.Items)  
  2. {  
  3.    list.Items.Add(item);  
  4. }  
Here I create one helper class to perform RSS fedd.

The full source code should be like this:
  1. private async void load(ItemsControl list, Uri uri)  
  2. {  
  3.     SyndicationClient client = new SyndicationClient();  
  4.     SyndicationFeed feed = await client.RetrieveFeedAsync(uri);  
  5.     if (feed != null)  
  6.     {  
  7.         foreach(SyndicationItem item in feed.Items)  
  8.         {  
  9.             list.Items.Add(item);  
  10.         }  
  11.     }  
  12. }  
  13. public void Go(ref ItemsControl list, string value)  
  14. {  
  15.     try  
  16.     {  
  17.         load(list, new Uri(value));  
  18.     }  
  19.     catch  
  20.     {}  
  21.     list.Focus(FocusState.Keyboard);  
  22. }  
  23. }  
  24. private void feedClick_Click(object sender, RoutedEventArgs e)  
  25. {  
  26.     helperRSS.Go(ref Display, Value.Text);  
  27. }  
Now run the application and enter your RSS feed Url in the given textbox.

Output

Output

For Source Code.

Ebook Download
View all
Learn
View all