这是我的代码: DataGrid中有一些新行,但它们都是空的。或者我可以使用其他任何Methode?
private void btnFill_Click(object sender, RoutedEventArgs e)
{
var url = string.Empty;
using (var web = new System.Net.WebClient())
{
url = web.DownloadString(txtMainUrl.Text + "/sitemap.xml");
}
var dataTablesummary = new DataTable();
dataTablesummary.Columns.Add("Test", typeof(string));
dataTablesummary.Columns.Add("Check", typeof(bool));
var link = string.Empty;
for (int i = 0; i < url.Length; i++)
{
char letter = url[i];
if (url[i] == '<' && url[i + 1] == 'l' && url[i + 2] == 'o' && url[i + 3] == 'c' && url[i + 4] == '>')
{
i += 5;
do
{
link += url[i];
i++;
} while (url[i] != '<');
dataTablesummary.Rows.Add(link, true);
}
link = string.Empty;
}
gridAdditionalUrls.ItemsSource = dataTablesummary.AsDataView();
}