Windows 10 Universal Windows Platform – RSS Reader

Step 1

Download Visual Studio Community 2015 and install it onto your computer, if it’s already downloaded and installed select Launch to start Visual Studio Community 2015 or if it has already been downloaded and installed then start the application you may also need to Enable your device for development.

10-home

Step 2

Once Visual Studio Community 2015 has started select File, then New, then Project… from the Menu.

10-file-new-project

Step 3

From the New Project window select Visual C# from Installed, Templates then select Blank App (Windows Universal) from the list, then type in a Name and select a Location to save to before selecting Ok to create the Project.

10-new-project

Step 4

Once done select from the Menu, Project, then Add New Item…

10-project-add-new-item

Step 5

From the Add New Item window select Visual C# from Installed then select Code File from the list, then type in the Name as Library.cs before selecting Add to add the file to the Project

10-add-new-item-library

Step 6

Once in the Code View for Library.cs the following should be entered:

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.Web.Syndication;

public class Library
{
    private async void load(ItemsControl list, Uri uri)
    {
        SyndicationClient client = new SyndicationClient();
        SyndicationFeed feed = await client.RetrieveFeedAsync(uri);
        if (feed != null)
        {
            foreach (SyndicationItem item in feed.Items)
            {
                list.Items.Add(item);
            }
        }
    }

    public void Go(ref ItemsControl list, string value, KeyRoutedEventArgs args)
    {
        if (args.Key == Windows.System.VirtualKey.Enter)
        {
            try
            {
                load(list, new Uri(value));
            }
            catch
            {

            }
            list.Focus(FocusState.Keyboard);
        }
    }
}

It should then appear as such:

10-library-rssreader

Step 7

From the Solution Explorer select MainPage.xaml

10-mainpage

Step 8

Select from the Menu, View then Designer

10-designer

Step 9

The Design View will be displayed along with the XAML View and in this below <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> enter the following XAML:

<Grid>
	<Grid.RowDefinitions>
		<RowDefinition Height="Auto"/>
		<RowDefinition Height="*"/>
	</Grid.RowDefinitions>
	<TextBox Grid.Row="0" Name="Value" Margin="20" VerticalAlignment="Center" KeyDown="Go_KeyDown"/>
	<ScrollViewer Grid.Row="1" Margin="20" BorderThickness="0">
		<ItemsControl Name="Display">
			<ItemsControl.ItemTemplate>
				<DataTemplate>
					<StackPanel>
						<HyperlinkButton NavigateUri="{Binding Path=Links[0].Uri}">
							<HyperlinkButton.Content>
								<TextBlock TextWrapping="Wrap" Text="{Binding Path=Title.Text}"/>
							</HyperlinkButton.Content>
						</HyperlinkButton>
						<TextBlock Text="{Binding Path=PublishedDate}"/>
					</StackPanel>
				</DataTemplate>
			</ItemsControl.ItemTemplate>
		</ItemsControl>
	</ScrollViewer>
</Grid>

It should appear as such:

10-xaml-rssreader

Step 10

Select from the Menu, View then Code

10-code

Step 11

Once in the Code View below the public MainPage() { … } the following should be entered:

public Library Library = new Library();

private void Go_KeyDown(object sender, KeyRoutedEventArgs e)
{
	Library.Go(ref Display, Value.Text, e);
}

It should then appear as such:

10-code-rssreader

Step 12

That completes the Windows Universal Application so Save the Project then select the Debug and Simulator option to run the Application

10-simulator

Step 13

Once the Simulator has started the Application should then appear

10-simulator-run-rssreader

Step 14

After the Application has started running you can then type in the URL of any RSS feed then press or tap enter to load it

10-simulator-ran-rssreader

Step 15

To Exit the application select Stop Debugging in Visual Studio Community 2015

10-stop

Step 16

Another option is to run as a Windows Phone application, select Debug and select Emulator 10.0.1.0 WVGA 4 inch 512MB option to run the Application

10-emulator

Step 17

Once the Emulator has started the Application should then appear

10-emulator-run-rssreader

Step 18

After the Application has started running you can then type in the URL of any RSS feed then press or tap enter to load it

10-emulator-ran-rssreader

Step 19

To Exit the application select Stop Debugging in Visual Studio Community 2015

10-stop

Creative Commons License

Advertisements

9 thoughts on “Windows 10 Universal Windows Platform – RSS Reader

  1. It gives me System.Runtime.InteropServices.COMException on Local Machine and DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION on mobile. Any idea ?
    I’ve followed your every single step .

    Like

  2. Hey. Thanks for the little tutorial,really useful. I’m just wondering if you have any tips on how I would go about making it look more elegant. like to even change the background color and add a few textblocks or buttons, thanks.

    Like

    • You can use Expression Blend to do more customisation on things – it comes with Visual Studio Community – some of the stuff I cover is just a basic idea for a Template but you can do anything there and even record actions etc, not used it much myself but is quite powerful!

      Like

    • Some RSS Feeds will provide a text only version of the content so if that’s the case you can use that part of the RSS instead, otherwise it may need the use of a RegEx to remove HTML although this can be tricky to get right, but if just removing rather than parsing this might be ok

      Like

  3. public sealed partial class MainPage : Page
    {
    public MainPage()
    {
    public Library Library = new Library();
    private void Go_KeyDown(Object sender, KeyRoutedEventArgs e)
    {
    Library.Go(ref Display, Value.Text, e);
    }
    }
    }
    I get an error at the curly bracket just below the public MainPage() stating expected } but all bracets are present. Did i miss something?

    Like

    • It should work if the following is placed below “public MainPage() {“, which should already be present:

      public Library Library = new Library();

      private void Go_KeyDown(object sender, KeyRoutedEventArgs e)
      {
      Library.Go(ref Display, Value.Text, e);
      }

      There don’t appear to be any missing curly braces in my code but can try that, in your example there is a missing “}” ie. there should be as many closing braces as opening ones, but just putting that in might make it work

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s