System.Windows.Controls.UIElementCollection
implements IEnumerable
but not IEnumerable<UIElement>
, so the Linq methods do not directly apply since they only work on IEnumerable<T>
instances.
One way is to "extract" the PushPin
s as an IEnumerable<PushPin>
using OfType
:
var pushpin = MyMapUserControl.MyMap
.Children
.OfType<Pushpin>()
.First(p => p.Tag == "FindMeLater");