Never mind, solved it! I used this piece of code I found online:
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject objectToSearchThrough) where T : DependencyObject
{
if (objectToSearchThrough != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(objectToSearchThrough); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(objectToSearchThrough, i);
if (child != null && child is T)
{
yield return (T)child;
}
foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}
I used this method in a foreach statement:
foreach(var player in FindVisualChildren<MediaPlayerElement>(Gridview))
{
player.MediaPlayer.Pause();
}