An RSS document (called "feed", "web feed", or "channel") includes full or summarized text, and metadata, like publishing date and author's name. Websites usually use RSS feeds to publish frequently updated information, such as blog entries, news headlines, episodes of audio and video series, or for distributing podcasts. Subscribing to RSS feeds can allow a user to keep track of many different websites in a single news aggregator, which constantly monitors sites for new content, removing the need for the user to manually check them. In the next article we are going to add more features to build our RSS Reader WPF application.RSS ( Really Simple Syndication) is a web feed that allows users and applications to access updates to websites in a standardized, computer-readable format. We also used Expander control to display the description when the post title is clicked. We learned how to display the controls inside the DataTemplate in the design view. In this article we started the implementation of a simple RSS Reader control. The style is defined using the code below:Īnd here is the code that assigns the style to the Border control: We are going to add support for IsMouseOver dependency property and change the background of the Border control. Let's add a little style to our application. You can check out the following article about HtmlTextBlock control. There are few TextBlock controls that provide this functionality. Currently, the TextBlock control does not provide any functionality to display HTML. The screenshot also reflects that HTML is not rendered property on a TextBlock control. Take a look at the screenshot below which shows the description of the post when the post title is clicked. The Expander.Header template is displayed to the user and Expander.Content is displayed to the user when the Expander is expanded. Let's take a look at the code below which is used to setup the Expander control for the Title and description properties. This effect is created using the Expander control. The arrow buttons beside the Title are used to toggle the description. This might be an overkill just to make the items in the DataTemplate appear in the design view but for developers who are not fluent in XAML the above tip can come handy. Now, the design will update and shows the elements contained inside the DataTemplate of the ItemsControl as shown below: The TextBlocks inside the ItemsControl are assigned to the bindable properties,Title and Description. Now, let's see how to bind the feeds resource to the ItemsSource control.Īs, you might have noticed the ItemsSource property of the ItemsControl is set to the StaticResource feeds. We have also assigned some dummy data to the Title and the Description fields. We have defined two feed objects inside the feeds collection. First, here is our Feeds collection.Īnd here is the XAML code which define the Feeds as an static resource: You will also need to assign the Binding Path to the correct property of the nested control to be bound. One of the ways to solve this problem is to expose a collection as a resource and bind that resource to the ItemsControl. Check out the screenshot below which displays the design view when the controls are inside the DataTemplate of the ItemsControl. For simple styling like Background, Foreground, FontSize etc you can use XAML but as soon as it gets complicated then it becomes cumbersome to apply the design features using XAML. This makes it harder to customize the controls using VS or Expression Blend 2. One important thing to note is that the controls inside the DataTemplate are not displayed in the design view. The ItemsControl DataTemplate can easily be customized to display the data is a custom format. ItemsControls is ideal for displaying a list of items. The posts will be displayed using the ItemsControl. Let's start by displaying the post title. The above screenshot is the final design for our RSS Reader application. Now, let's check out the setup for the user interface.īefore we start designing and implementing the user interface it will be a better idea to take a look at the final design. This completes our simple implementation of the RssService and Feed class. The Feed class consists of Title, Url and Description properties as shown below: The above code simply gets the ten latest feeds from the supplied URL and returns them as a List. Here is the implementation of the RssService.cs: Let's start by creating a simple RSS Service which returns latest feeds from a URL. Creating the RSS Service to Return RSS Feeds:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |