this
这个问题给了我80%的所需。对我来说,“问题”是我的XML结构不同,我不太确定如何使用Linq来获得我需要的东西。
我的XML看起来是这样的(顺便说一下,它是由ConvertTo XML PowerShell Cmdlet生成的)
<?xml version="1.0"?>
<Objects>
<Object>
<Property Name="Name">CompiledCode.ps1</Property>
<Property Name="LastWriteTime">5/21/2009 6:59:16 PM</Property>
</Object>
<Object>
<Property Name="Name">ComputerDrawing.ps1</Property>
<Property Name="LastWriteTime">1/13/2010 7:52:44 AM</Property>
</Object>
</Objects>
我正试图绑定到Silverlight数据网格,以便列名为“Name”和“LastWriteTime”,行将具有属性标记中的值。对于第一个,名称是Compiled Code.ps1,LastWriteTime是“5/21/2009 6:59:16 PM”
上述问题的答案是这样的
private Status GetStatus(XElement el)
{
Status s = new Status();
s.Description = el.Attribute("Description").Value;
s.Date = DateTime.Parse(el.Attribute("Date").Value);
return s;
}
我创建了自己的一个名为Scripts的类,它有一个名称和日期,但是我试图找出填充我的datagrid需要哪些元素或属性。