如何从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