c# WPF数据网格没有显示
本文关键字:显示 网格 数据网 WPF 数据 | 更新日期: 2023-09-27 18:18:56
我试图在表单上列出rss提要,我可以消费提要,但无法看到表单上的数据。我什么也没看见。除了一张黑色的表格。RSS表中填充了RSS提要数据。数据可视化工具显示加载到表中的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>
代码:公共部分类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;
}
}
}
我的问题解决了
列名是URL而不是URL
下一个改变:(我将RSSJobFeed作为数据集的一部分。)RssGridView。