我使用此代码将 xml 结果解析为 listpicker 控件:
if (e.Error != null)
return;
XElement xmlItems = XElement.Parse(e.Result);
var list = new List<auth>();
foreach (var response in xmlItems.Descendants("result"))
{
var nom = (string)response.Element("nom").Value;
var id = (string)response.Element("id").Value;
list.Add(new auth
{
state = nom,
id = id,
});
}
this.defaultPicker.ItemsSource = list;
this.defaultPicker.DisplayMemberPath = "state";
<response><status>OK</status><result><id>1</id><nom>ARIANA</nom></result><result><id>2</id><nom>BEJA</nom></result>.....</response>
它只返回第一项,但是当我单击列表时,它会将我带到 auth 类的路径列表!请问有什么想法吗?