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
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
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()
}
);
}
}
}
}
}
}