我正在尝试在表单上列出一个RSS源,我可以使用Feed,但无法在表单上看到数据。 我什么都看不见。除了黑色形式。 RSS表填充了rss feed数据。数据可视化器显示加载到表中的rss数据。
xamal
<DataGrid x:Name="RssGridView" Grid.Column="1" HorizontalAlignment="Left" Grid.Row="1" VerticalAlignment="Top" Height="528" Width="651"
ItemsSource="{Binding}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Title" Binding="{Binding Title}" />
<DataGridTextColumn Header="Decription" Binding="{Binding Decription}" />
<DataGridTextColumn Header="Url" Binding="{Binding Url}" />
</DataGrid.Columns>
代码: public partial class MainWindow:Window {
private GetRssFeedData ConsumeFeed;
private DataTable RssTable;
RssDataset RssSet;
public MainWindow()
{
InitializeComponent();
//Intaltize Rss data table if exist load xml frm file
RssSet = new RssDataset();
RssTable = RssSet.Tables.Add("RssTable");
RssTable.Columns.Add("Title", typeof(string));
RssTable.Columns.Add("Url", typeof(string));
RssTable.Columns.Add("Decription", typeof(string));
RssTable.Columns.Add("PubDate", typeof(string));
ConsumeFeed = new GetRssFeedData();
ConsumeFeed.CallItemHandler += new RssItemHandler(ProcessessRssItem);
ConsumeFeed.CallDownloadHandler += new RSSDownlaodCompleted(CompletedDownload);
try
{
if (File.Exists("RssUrl.xml"))
{
RssSet.ReadXml("RssUrl.xml");
}
else
{
RssSet.WriteXml("RssUrl.xml");
}
SelectRssBox.ItemsSource = RssSet.RssFeeds;
}
catch (Exception EX)
{
MessageBox.Show(EX.Message);
}
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
Window1 GetRss = new Window1();
GetRss.ShowDialog();
RssSet.Clear();
RssSet.ReadXml("RssUrl.xml");
}
private void GetJobsButton_Click(object sender, RoutedEventArgs e)
{
if (SelectRssBox.SelectedValue != null)
{
ConsumeFeed.GetRssFeed(SelectRssBox.SelectedValue.ToString());
}
}
private void ProcessessRssItem(SyndicationItem e)
{
DataRow newRow;
newRow = RssTable.NewRow();
newRow["Title"] = e.Title.Text;
newRow["Url"] = e.Links[0].Uri;
newRow["Decription"] = e.Summary.Text;
newRow["PubDate"] = e.PublishDate.ToString();
RssTable.Rows.Add(newRow);
}
private void CompletedDownload()
{
RssGridView.DataContext = RssTable;
//RssGridView.ItemsSource = RssTable.DefaultView;
}
}
}
答案 0 :(得分:0)
我解决了我的问题
列名是URL而不是Url
下次更改: (我将RSSJobFeed作为数据集的一部分。) RssGridView.ItemsSource = RssSet.RSSJobFeed.DefaultView;