我正在开发一个显示 XML 文件中的数据并将其显示到 itemgridview 的应用程序。我正在使用拆分应用程序模板。我得到的错误是:
<code>Error: BindingExpression path error: 'rim' property not found on
'System.Runtime.InteropServices.WindowsRuntime.CLRIKeyValuePairImpl`2[
[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, </code>
&
<code>Error: BindingExpression path error: 'carcolor' property not found
on'System.Runtime.InteropServices.WindowsRuntime.CLRIKeyValuePairImpl`2
[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, </code>
Xaml(如果很小,则在新选项卡中打开):http: //i.stack.imgur.com/4r467.png
XML文件(http://nak-tek.com/test/car.xml)
我的ItemsPage.cs代码:
public async void GetXmlAsync()
{
try
{
var client = new HttpClient();
var response = await client.GetAsync("Http://nak-tek.com/test/car.xml");
var text = response.Content.ReadAsStringAsync();
XElement xmlCars = XElement.Parse(text.Result);
IEnumerable<Car> data = from query in xmlCars.Descendants("car")
select new Car
{
carcolor = query.Element("color").Value,
rim = query.Element("rim").Value
};
itemGridView.DataContext = data;
}
catch (Exception)
{ }
}
我的班级汽车.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace App2.Common
{
public class Car
{
public string carcolor {get; set;}
public string rim {get; set;}
}
}