Monday, November 25, 2013

Winrt VisualTreeHelper on GridView

When I use the visual tree helper to get the children items of a GridView the GridViewItemPresenter only has one child which is the first item in the grid view content. The other items are not retrieved. Any Idea why only the first item in the GridView is retrieved?



public static IEnumerable<DependencyObject> GetChildren(this DependencyObject obj)//obj is GridViewItemPresenter
{
var count = VisualTreeHelper.GetChildrenCount(obj);//Count is only 1 but GridView has 4 children??
for (int i = 0; i < count; i++)
{
var child = VisualTreeHelper.GetChild(obj, i);
yield return child;
}
}


No comments:

Post a Comment