如何从UIElementCollection中选择一个属性=某个值的子项?
我有一个UniformGrid
,有许多Button
作为Children
。 每个Button
都有一个带ID的Tag
,例如(dumbed down code):
MyUniformGrid.Children.Add(new Button { Margin = new Thickness(5), Tag = Query.GetUInt32("id"), Width = 200 });
如何选择ID为87的子Button
对象? (例如)
当我输入MyUniformGrid.Children.
时,Intellisense没有弹出Linq方法MyUniformGrid.Children.
(在using System.Linq;
添加之后using System.Linq;
)。
干得好:
var MyButton = MyUniformGrid.Children. OfType
Linq不能直接在MyUniformGrid.Children
上运行,因为UIElementCollection
实现了IEnumerable
,而不是IEnumerable
。 因此OfType
。
上述就是C#学习教程:如何从UIElementCollection中选择一个属性=某个值的子项?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1013094.html