var LocationList = from Forms in Root.Descendants(Form)
where
( (string)Forms.Attribute(Id) == FormID &&
(string)Forms.Element(Control).Attribute(Id) == ControlID &&
(string)Forms.Element(Control).Element(Layout).Attribute(direction) == Direction
)
select new{
X =(int)Forms.Element(Control).Element(Layout).Element(Location).Element(x),
Y =(int)Forms.Element(Control).Element(Layout).Element(Location).Element(y),
Width = (int)Forms.Element(Control).Element(Layout).Element(Size).Element(width),
Height = (int)Forms.Element(Control).Element(Layout).Element(Size).Element(height), };以上这句 怎么修改能变成返回一个值
where
( (string)Forms.Attribute(Id) == FormID &&
(string)Forms.Element(Control).Attribute(Id) == ControlID &&
(string)Forms.Element(Control).Element(Layout).Attribute(direction) == Direction
)
select new{
X =(int)Forms.Element(Control).Element(Layout).Element(Location).Element(x),
Y =(int)Forms.Element(Control).Element(Layout).Element(Location).Element(y),
Width = (int)Forms.Element(Control).Element(Layout).Element(Size).Element(width),
Height = (int)Forms.Element(Control).Element(Layout).Element(Size).Element(height), };以上这句 怎么修改能变成返回一个值
SingleOrDefault() //找到多个就报错 找不到就返回null
或者用这样的
var LocationList = Root.Descendants(Form).Where(a=>条件).FirstOrDefaut(b=>new{X=b.....Y=b....})