0
我正在使用此RSS提要用於我的Windows 8應用程序(c#)http://www.skysports.com/rss/0,20514,11661,00。我可以顯示標題和PubDate,但我被卡在圖像上。c#無法顯示RSS提要的圖像
private async void LoadRSS()
{
SyndicationClient client = new SyndicationClient();
Uri feedUri = new Uri("http://www.skysports.com/rss/0,20514,11661,00.xml");
SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri);
FeedData feedData = new FeedData();
foreach (SyndicationItem item in feed.Items)
{
FeedItem feedItem = new FeedItem();
feedItem.Title = item.Title.Text;
feedItem.PubDate = item.PublishedDate.DateTime;
// Handle the differences between RSS and Atom feeds.
if (feed.SourceFormat == SyndicationFormat.Atom10)
{
feedItem.Content = item.Content.Text;
feedItem.Link = new Uri("http://www.skysports.com" + item.Id);
}
else if (feed.SourceFormat == SyndicationFormat.Rss20)
{
feedItem.Content = item.Summary.Text;
feedItem.Link = item.Links[0].Uri;
}
feedData.Items.Add(feedItem);
}
ItemListView.DataContext = feedData.Items;
}
XAML代碼:
<GridView x:Name="ItemListView" Grid.Column="2" Grid.Row="1" ItemsSource="{Binding}" ItemClick="Sports_ItemClick_1" IsItemClickEnabled="True" SelectionMode="None" >
<GridView.ItemTemplate>
<DataTemplate>
<Grid Width="400" Height="75" Margin="0,0,50,0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75"></ColumnDefinition>
<ColumnDefinition Width="325"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Background="#60BF89">
<Image Source="{Binding ImagePath, Mode=OneWay}" Stretch="None" Margin="5,15,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Width="500"/>
</Border>
<StackPanel Grid.Column="1" VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Foreground="White" Text="{Binding Title}" FontSize="16" Margin="5,0,0,0" TextWrapping="Wrap" />
<TextBlock Foreground="White" Text="{Binding PubDate}" FontSize="12" Margin="5,0,0,0"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
我想在第一列中的圖像。有任何想法嗎??
是的,我離開了這一點,因爲我不知道如何做到這一點。 – user1951083 2013-03-19 09:23:47
:),如果你沒有設置路徑,它將如何顯示圖像。 – TalentTuner 2013-03-19 09:27:51
在DataFeed類中:public Uri ImagePath {get;組; } 所以我想用FeedItem.ImagePath = item.ItemUri; 產生System.Exception – user1951083 2013-03-19 09:35:35