Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code for the Rss reading Application that I am working on. Everything works fine just that i am only able to show the title and the summary of the Rss Feed and not the Images alongside and while displaying the summary if there are images in the summary then they come written as '6&4%' something similar. Please Help me sort this out and please help me add images to my app.
thank you.

here is the xaml
<!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1"  MaxWidth="480" MaxHeight="545">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80*" />
                <ColumnDefinition Width="320*" />
                <ColumnDefinition Width="80*" />
            </Grid.ColumnDefinitions>
            <Grid.Background>
                <ImageBrush ImageSource="/CampusGhanta;component/bg.png" />
            </Grid.Background>
            <ListBox x:Name="MainList" ItemsSource="{Binding FeedItems}" Margin="2,0,0,6" SelectionChanged="ListBox_SelectionChanged" removed="Transparent" Grid.ColumnSpan="3">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel  Margin="80,40,80,40" OpacityMask="#FFEB2727" Visibility="Visible">
                            <StackPanel.Background>
                                <RadialGradientBrush Opacity="0.3">
                                    <GradientStop Color="Black" Offset="0.549" />
                                    <GradientStop Color="Red" Offset="1" />
                                </RadialGradientBrush>
                            </StackPanel.Background>
                            <Image Source="{Binding ., Converter={StaticResource SyndicationToImageConverter}}" Width="48" Height="48" VerticalAlignment="Top" Stretch="UniformToFill" Margin="0,12,0,0" />
                            <TextBlock FontSize="48" x:Name="ItemName" Text="{Binding ItemTitle}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="Yellow"  TextWrapping="Wrap"></TextBlock>
                            <TextBlock  x:Name="ItemDetails" Text="{Binding ItemDetails}" Style="{StaticResource PhoneTextSubtleStyle}" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap"></TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>



the view model class


C#
using System;
using System.ComponentModel;

namespace CampusGhanta.ViewModel
{
    public class ItemModel : INotifyPropertyChanged
    {
        private string itemTitle;
        public string ItemTitle
        {
            get { return itemTitle; }
            set
            {
                if (value != itemTitle)
                {
                    itemTitle = value;
                    NotifyPropertyChanged("ItemTitle");
                }
            }
        }

        private string itemDetails;
        public string ItemDetails
        {
            get { return itemDetails; }
            set
            {
                if (value != itemDetails)
                {
                    itemDetails = value;
                    NotifyPropertyChanged("ItemDetails");
                }
            }
        }


        private string itemLink;
        public string ItemLink
        {
            get { return itemLink; }
            set
            {
                if (value != itemLink)
                {
                    itemLink = value;
                    NotifyPropertyChanged("ItemLink");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}


the feeddata class

C#
using System.ServiceModel;
using System.ServiceModel.Syndication;
using System.Diagnostics;
using System.Xml;
using System.Net;
using System.IO;


namespace CampusGhanta.FeedHelper
{
    public class FeedData
    {
        public ObservableCollection<string> FeedList { get; set; }

        public static void GetItems()
        {
            App.Model.FeedItems.Clear();

            foreach (string item in App.Data.FeedList)
            {
                WebClient client = new WebClient();
                client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                client.DownloadStringAsync(new Uri(item));
            }
        }

        static void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Result))
            {
                XmlReader reader = XmlReader.Create(new StringReader(e.Result));
                SyndicationFeed feed = SyndicationFeed.Load(reader);

                foreach (SyndicationItem sItem in feed.Items)
                {
                    if ((sItem != null) && (sItem.Summary != null) && (sItem.Title != null))
                    {
                        App.Model.FeedItems.Add(
                            new ViewModel.ItemModel()
                            {

                                ItemDetails = sItem.Summary.Text,
                                ItemTitle = sItem.Title.Text,
                                Img = sItem.Summary.Text,
                                ItemLink = sItem.Links[0].Uri.ToString()

                            }
                                );
                    }
                }
            }
        }
    }
}
Posted
Comments
[no name] 24-Sep-13 1:15am    
the ascii codes I have decoded using HttpUtility.HtmlDecode(). So that is done..Now i just need to figure out the way to add an iamge. And the Image src is listed in the content:encoded tag under CDATA ... so here is the link ro the rss please see and Help me . Thank you.

http://wwww.campusghanta.com/feed

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900